NodeRuntimeMetrics

Collect Node.js runtime health metrics such as memory usage, CPU utilization, and event loop delay.

Import name: Sentry.nodeRuntimeMetricsIntegration

The nodeRuntimeMetricsIntegration periodically collects Node.js runtime health metrics and sends them to Sentry. Metrics include memory usage, CPU utilization, event loop delay, and process uptime.

Copied
import * as Sentry from "@sentry/node";

Sentry.init({
  dsn: "___PUBLIC_DSN___",
  integrations: [Sentry.nodeRuntimeMetricsIntegration()],
});

The following metrics are emitted every 30 seconds by default:

MetricTypeUnitDescription
node.runtime.mem.rssgaugebyteResident Set Size — actual process memory footprint
node.runtime.mem.heap_usedgaugebyteV8 heap currently in use
node.runtime.mem.heap_totalgaugebyteTotal V8 heap allocated
node.runtime.cpu.utilizationgaugeratioCPU time / wall-clock time ratio
node.runtime.event_loop.delay.p50gaugesecondMedian event loop delay
node.runtime.event_loop.delay.p99gaugesecond99th percentile event loop delay
node.runtime.event_loop.utilizationgaugeratioFraction of time the event loop was active
node.runtime.process.uptimecountersecondCumulative process uptime

Type: object

Configure which metrics to collect. You can enable opt-in metrics or disable default ones.

Opt-in metrics (off by default):

Copied
Sentry.nodeRuntimeMetricsIntegration({
  collect: {
    cpuTime: true, // node.runtime.cpu.user + node.runtime.cpu.system
    memExternal: true, // node.runtime.mem.external + node.runtime.mem.array_buffers
    eventLoopDelayMin: true,
    eventLoopDelayMax: true,
    eventLoopDelayMean: true,
    eventLoopDelayP90: true,
  },
});

Disabling default metrics:

Copied
Sentry.nodeRuntimeMetricsIntegration({
  collect: {
    uptime: false,
    eventLoopDelayP50: false,
  },
});

Type: number

The interval in milliseconds between metric collections. Defaults to 30000 (30 seconds).

Copied
Sentry.nodeRuntimeMetricsIntegration({
  collectionIntervalMs: 60_000,
});
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").