

doc
Get usage and health data about your Node.js process
Installation
$ npm i @dnlup/doc
Usage
const Doc = require('@dnlup/doc');
const doc = Doc();
doc.on('data', data => {
doStuffWithCpuUsage(data.cpu)
doStuffWithMemoryUsage(data.memory)
doStuffWithEventLoopDelay(data.eventLoopDelay)
})
API
Doc([options])
Create a new Doc instance with the given options.
options
: Object
. Optional. Configuration objectoptions.sampleInterval
: Number
. Optional. Sample interval (ms), each sampleInterval
ms a data event is emitted. On Node 10 the default value is 500
while on Node >= 12 is 1000
. Under the hood the package uses monitorEventLoopDelay
where available to sample the event loop and this allows to increase the default sample interval on Node >= 12.options.eventLoopOptions
: Object
. Optional. Options to setup monitorEventLoopDelay
events
data
Process data event.
Properties:
Name | Description |
---|
eventLoopDelay | Event loop delay (ms) |
memory | Object containing memory usage stats |
memory.rss | RSS memory (bytes) |
memory.heapTotal | Total heap Memory (bytes) |
memory.heapUsed | Heap memory used (bytes) |
memory.external | Extarnal memory (bytes) |
cpu | Cpu usage percentage |
raw | Object containing raw values |
raw.cpu | Object containing the raw values returned from process.cpuUsage() |
raw.eventLoopDelay | Raw representation of the event loop delay, on Node 10 it is the delay in nanoseconds, on Node >= 12 is a Histogram instance |