@chainsafe/prometheus-gc-stats
v1.0.2
Published
Report Nodejs Garbage Collection stats using Prometheus
Downloads
1,205
Readme
@chainsafe/prometheus-gc-stats
Report Nodejs Garbage Collection stats using Prometheus
Usage
This module has a peer dependency on prom-client
. Currently, 10 is supported.
Collection of GC stats is automatically started when calling gcStats
and is stopped when calling the returned function.
Example:
import prometheus from 'prom-client';
import { gcStats } from '@chainsafe/prometheus-gc-stats';
prometheus.collectDefaultMetrics();
const stopGcStats = gcStats(prometheus.register);
// eventually
stopGcStats()
node:v8
The module doing the GC stats collecting is node:v8
. This module uses features that require Nodejs v18+.
Metrics exposed
This module exposes 3 metrics:
nodejs_gc_runs_total
: Counts the number of time GC is invokednodejs_gc_pause_seconds_total
: Time spent in GC in secondsnodejs_gc_reclaimed_bytes_total
: The number of bytes GC has freed
You can add a prefix to metric names using options:
const stopGcStats = gcStats(prometheus.register, {
prefix: 'my_application_',
});
Credits
Thanks to @tcolgate and @SimenB for the original implementation.