2.2.0 • Published 5 years ago
notare-monitor v2.2.0
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 theMonitorshould generate. The higher this number, the greater the performance impact theMonitorwill have. The default is2. TheNOTARE_HZenvironment variable may also be used to set this value.handles: (boolean) When true, theMonitorwill 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_HANDLESenvironment variable to1may also be used to set this value.gc: (boolean) When true, theMonitorwill 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_GCenvironment variable to1may also be used to set this value.
The Monitor object extends from Node.js stream.Readable.
Configuration via Environment Variables
NOTARE_HZ=nwherenis the number of samples per second (default2)NOTARE_HANDLES=1instructs notare to monitor async hook handle counts (disabled by default)NOTARE_GZ=1instructs notare to monitor garbage collection (disabled by default)