Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clinicjs/notare-monitor
https://github.com/clinicjs/notare-monitor
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/clinicjs/notare-monitor
- Owner: clinicjs
- License: other
- Created: 2020-05-11T20:17:30.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-24T20:47:54.000Z (about 4 years ago)
- Last Synced: 2024-10-22T22:50:07.198Z (3 months ago)
- Language: TypeScript
- Size: 38.1 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
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
```js
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 the `Monitor` should generate. The higher this
number, the greater the performance impact the `Monitor` will have.
The default is `2`. The `NOTARE_HZ` environment variable may also be
used to set this value.
* `handles`: (`boolean`) When true, the `Monitor` 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 the `NOTARE_HANDLES` environment variable to `1`
may also be used to set this value.
* `gc`: (`boolean`) When true, the `Monitor` 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 the `NOTARE_GC` environment variable to `1`
may also be used to set this value.The `Monitor` object extends from Node.js [`stream.Readable`][].
## Configuration via Environment Variables
* `NOTARE_HZ=n` where `n` is the number of samples per second (default `2`)
* `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)[`stream.Readable`]: https://nodejs.org/dist/latest-v14.x/docs/api/stream.html#stream_readable_streams