notare-monitor
v2.2.0
Published
Node.js Performance Observer - Monitor module
Downloads
51
Readme
notare-monitor -- Node.js observer
Extracted from the notare
module, notare-monitor
provides
a Node.js streams Readable
that monitors and reports on
various Node.js performance metrics.
Example
const { Monitor } = require('notare-monitor');
const { pipeline, Writable } = require('stream');
class myWritable extends Writable {
constructor() {
super({ objectMode: true });
}
_write(chunk, encoding, callback) {
console.log(JSON.stringify(chunk));
callback();
}
}
const monitor = new Monitor();
pipeline(monitor, new myWritable(), (err) => {
if (err) {
console.error('There was an error!');
process.exit(1);
}
});
API
Constructor: Monitor([options])
Create a new 'Monitor
object.
options
(object
)hz
: (number
) An integer between 1 and 1000 that specifies the number of samples per second theMonitor
should generate. The higher this number, the greater the performance impact theMonitor
will have. The default is2
. TheNOTARE_HZ
environment variable may also be used to set this value.handles
: (boolean
) When true, theMonitor
will track and report on the number of async resources in use by Node.js. Enabling this has a measurable performance impact on the Node.js process so it is off by default. Setting theNOTARE_HANDLES
environment variable to1
may also be used to set this value.gc
: (boolean
) When true, theMonitor
will track and report on garbage collection counts and durations. Enabling this has a measurable performance impact on the Node.js process so it is off by default. Setting theNOTARE_GC
environment variable to1
may also be used to set this value.
The Monitor
object extends from Node.js stream.Readable
.
Configuration via Environment Variables
NOTARE_HZ=n
wheren
is the number of samples per second (default2
)NOTARE_HANDLES=1
instructs notare to monitor async hook handle counts (disabled by default)NOTARE_GZ=1
instructs notare to monitor garbage collection (disabled by default)