Skip to content

feat(node): Add nodeRuntimeMetricsIntegration #19967

Description

@github-actions

Note

The pull request "feat(node): Add nodeRuntimeMetricsIntegration" was created by @chargome but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

Adds nodeRuntimeMetricsIntegration to @sentry/node and @sentry/node-core. When enabled, the integration periodically collects Node.js runtime health metrics and emits them to Sentry via the metrics pipeline.

Usage

import*asSentryfrom'@sentry/node';Sentry.init({dsn: '...',integrations: [Sentry.nodeRuntimeMetricsIntegration(),],});

Default metrics (8)

Emitted every 30 seconds out of the box:

MetricTypeUnitDescription
node.runtime.mem.rssgaugebyteResident Set Size — actual process memory footprint
node.runtime.mem.heap_usedgaugebyteV8 heap currently in use — tracks GC pressure and leaks
node.runtime.mem.heap_totalgaugebyteTotal V8 heap allocated — paired with heap_used to see headroom
node.runtime.cpu.utilizationgaugeCPU time / wall-clock time ratio (can exceed 1.0 on multi-core)
node.runtime.event_loop.delay.p50gaugesecondMedian event loop delay — baseline latency
node.runtime.event_loop.delay.p99gaugesecond99th percentile event loop delay — tail latency / spikes
node.runtime.event_loop.utilizationgaugeFraction of time the event loop was active
node.runtime.process.uptimecountersecondCumulative uptime — useful for detecting restarts / crashes

Opt-in metrics (off by default)

Sentry.nodeRuntimeMetricsIntegration({collect: {cpuTime: true,// node.runtime.cpu.user + node.runtime.cpu.system (raw seconds)memExternal: true,// node.runtime.mem.external + node.runtime.mem.array_bufferseventLoopDelayMin: true,eventLoopDelayMax: true,eventLoopDelayMean: true,eventLoopDelayP90: true,},})

Any default metric can also be turned off:

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

Collection interval

Sentry.nodeRuntimeMetricsIntegration({collectionIntervalMs: 60_000,// default: 30_000})

Serverless (Next.js on Vercel, AWS Lambda, etc.)

Works out of the box — no special configuration needed. Metrics are sent by the periodic collection interval and flushed by the existing SDK flush infrastructure (framework wrappers like SvelteKit, TanStack Start, and @sentry/aws-serverless already call flushIfServerless after each request handler). The interval is unref()-ed so it never prevents the process from exiting.

Runtime compatibility

This integration is Node.js only. Bun and Deno will be addressed in separate integrations that use their respective native APIs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions