NodeRuntimeMetrics for Cloud Functions for Firebase
Collect Node.js runtime health metrics such as memory usage, CPU utilization, and event loop delay.
This integration only works in the Node.js runtime.
Available since: v10.46.0
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()],
});
import * as Sentry from "@sentry/node";
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [Sentry.nodeRuntimeMetricsIntegration()],
});
The following metrics are emitted every 30 seconds by default:
| Metric | Type | Unit | Description |
|---|---|---|---|
node.runtime.mem.rss | gauge | byte | Resident Set Size — actual process memory footprint |
node.runtime.mem.heap_used | gauge | byte | V8 heap currently in use |
node.runtime.mem.heap_total | gauge | byte | Total V8 heap allocated |
node.runtime.cpu.utilization | gauge | ratio | CPU time / wall-clock time ratio |
node.runtime.event_loop.delay.p50 | gauge | second | Median event loop delay |
node.runtime.event_loop.delay.p99 | gauge | second | 99th percentile event loop delay |
node.runtime.event_loop.utilization | gauge | ratio | Fraction of time the event loop was active |
node.runtime.process.uptime | counter | second | Cumulative 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,
},
});
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,
},
});
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,
});
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").
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").