@chainsafe/prometheus-gc-stats
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@chainsafe/prometheus-gc-stats

Report Nodejs Garbage Collection stats using Prometheus

NPM Version

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:

  1. nodejs_gc_runs_total: Counts the number of time GC is invoked
  2. nodejs_gc_pause_seconds_total: Time spent in GC in seconds
  3. nodejs_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.

Package Sidebar

Install

npm i @chainsafe/prometheus-gc-stats

Weekly Downloads

599

Version

1.0.2

License

MIT

Unpacked Size

33.6 kB

Total Files

13

Last publish

Collaborators

  • wemeetagain
  • mpetrunic