Skip to content

feat(node): Add nodeRuntimeMetricsIntegration - #19923

Merged
chargome merged 17 commits into
developfrom
feat/node-runtime-metrics
Mar 25, 2026
Merged

feat(node): Add nodeRuntimeMetricsIntegration#19923
chargome merged 17 commits into
developfrom
feat/node-runtime-metrics

Conversation

@chargome

@chargomechargome commented Mar 20, 2026

Copy link
Copy Markdown
Member

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.

Closes#19967 (added automatically)

@chargomechargome self-assigned this Mar 20, 2026
@github-actions

github-actionsBot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Deps

  • Bump mongodb-memory-server-global from 10.1.4 to 11.0.1 by dependabot in #19888
  • Bump stacktrace-parser from 0.1.10 to 0.1.11 by dependabot in #19887

Other

  • (elysia) Elysia SDK by logaretm in #19509
  • (node) Add nodeRuntimeMetricsIntegration by chargome in #19923
  • (nuxt) Conditionally use plugins based on Nitro version (v2/v3) by s1gr1d in #19955

Bug Fixes 🐛

Cloudflare

  • Send correct events in local development by JPeer264 in #19900
  • Forward ctx argument to Workflow.do user callback by Lms24 in #19891

Core

  • Preserve .withResponse() on Anthropic instrumentation by nicohrubec in #19935
  • Truncate content array format in Vercel by nicohrubec in #19911
  • Send internal_error as span status for Vercel error spans by nicohrubec in #19921
  • Do not overwrite user provided conversation id in Vercel by nicohrubec in #19903
  • Return same value from startSpan as callback returns by s1gr1d in #19300

Deps

  • Update lockfile to resolve h3@1.15.10 by chargome in #19933
  • Bump fast-xml-parser to 5.5.8 in @azure/core-xml chain by chargome in #19918
  • Bump next to 15.5.14 in nextjs-15 and nextjs-15-intl E2E test apps by chargome in #19917
  • Bump socket.io-parser to 4.2.6 to fix CVE-2026-33151 by chargome in #19880

Other

  • (craft) Add missing mainDocsUrl for @sentry/effect SDK by bc-sentry in #19860
  • (nestjs) Add node to nest metadata by chargome in #19875
  • (serverless) Add node to metadata by nicohrubec in #19878

Internal Changes 🔧

Deps Dev

  • Bump effect from 3.19.19 to 3.20.0 by dependabot in #19926
  • Bump qunit-dom from 3.2.1 to 3.5.0 by dependabot in #19546
  • Bump @react-router/node from 7.13.0 to 7.13.1 by dependabot in #19544

Nuxt

  • Extract core logic for storage/database to prepare for Nuxt v5 by s1gr1d in #19920
  • Extract handler patching to extra plugin for Nitro v2/v3 by s1gr1d in #19915

Other

  • (astro) Re-enable server island tracing e2e test in Astro 6 by Lms24 in #19872
  • (ci) Fix "Gatbsy" typo in issue package label workflow by chargome in #19905
  • (claude) Enable Claude Code Intelligence (LSP) by s1gr1d in #19930
  • (cloudflare) Enable multi-worker tests for CF integration tests by JPeer264 in #19938
  • (lint) Resolve oxlint warnings by isaacs in #19893
  • (node-integration-tests) Remove unnecessary file-type dependency by Lms24 in #19824
  • (remix) Replace glob with native recursive fs walk by roli-lpci in #19531
  • (sveltekit) Replace recast + @babel/parser with acorn by roli-lpci in #19533
  • Add external contributor to CHANGELOG.md by javascript-sdk-gitflow in #19925
  • Add external contributor to CHANGELOG.md by javascript-sdk-gitflow in #19909

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actionsBot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

⚠️Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

PathSize% ChangeChange
@sentry/browser25.69 kB+0.2%+49 B 🔺
@sentry/browser - with treeshaking flags24.17 kB+0.14%+33 B 🔺
@sentry/browser (incl. Tracing)42.67 kB+0.13%+54 B 🔺
@sentry/browser (incl. Tracing, Profiling)47.33 kB+0.12%+55 B 🔺
@sentry/browser (incl. Tracing, Replay)81.48 kB+0.08%+57 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags71.06 kB+0.1%+69 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas)86.17 kB+0.06%+50 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback)98.41 kB+0.04%+36 B 🔺
@sentry/browser (incl. Feedback)42.48 kB+0.08%+30 B 🔺
@sentry/browser (incl. sendFeedback)30.35 kB+0.15%+43 B 🔺
@sentry/browser (incl. FeedbackAsync)35.4 kB+0.12%+39 B 🔺
@sentry/browser (incl. Metrics)26.96 kB+0.15%+38 B 🔺
@sentry/browser (incl. Logs)27.1 kB+0.12%+32 B 🔺
@sentry/browser (incl. Metrics & Logs)27.78 kB+0.15%+39 B 🔺
@sentry/react27.45 kB+0.22%+58 B 🔺
@sentry/react (incl. Tracing)45.01 kB+0.14%+60 B 🔺
@sentry/vue30.13 kB+0.16%+46 B 🔺
@sentry/vue (incl. Tracing)44.52 kB+0.09%+39 B 🔺
@sentry/svelte25.7 kB+0.16%+40 B 🔺
CDN Bundle28.35 kB+0.27%+75 B 🔺
CDN Bundle (incl. Tracing)43.57 kB+0.15%+62 B 🔺
CDN Bundle (incl. Logs, Metrics)29.22 kB+0.27%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics)44.43 kB+0.17%+75 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics)68.29 kB+0.13%+85 B 🔺
CDN Bundle (incl. Tracing, Replay)80.41 kB+0.1%+73 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)81.31 kB+0.1%+76 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback)85.97 kB+0.12%+103 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)86.86 kB+0.1%+86 B 🔺
CDN Bundle - uncompressed82.7 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing) - uncompressed128.62 kB+0.05%+64 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed85.57 kB+0.1%+77 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed131.49 kB+0.05%+64 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed209.22 kB+0.05%+102 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed245.5 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed248.35 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed258.41 kB+0.04%+89 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed261.26 kB+0.04%+89 B 🔺
@sentry/nextjs (client)47.4 kB+0.08%+37 B 🔺
@sentry/sveltekit (client)43.12 kB+0.12%+51 B 🔺
@sentry/node-core56.42 kB+0.13%+73 B 🔺
@sentry/node170.71 kB-1.42%-2.44 kB 🔽
@sentry/node - without tracing96.45 kB+0.12%+107 B 🔺
@sentry/aws-serverless113.54 kB+0.18%+203 B 🔺

View base workflow run

@github-actions

github-actionsBot commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
⚠️Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

ScenarioRequests/s% of BaselinePrev. Requests/sChange %
GET Baseline8,946-8,799+2%
GET With Sentry1,65518%1,646+1%
GET With Sentry (error only)6,11068%5,983+2%
POST Baseline1,193-1,167+2%
POST With Sentry57548%580-1%
POST With Sentry (error only)1,02586%1,024+0%
MYSQL Baseline3,222-3,191+1%
MYSQL With Sentry46915%425+10%
MYSQL With Sentry (error only)2,59280%2,626-1%

View base workflow run

chargomeand others added 8 commits March 23, 2026 10:52
…google-cloud-serverless, skip for bun
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chargomechargome changed the title [WIP] feat(node): Add nodeRuntimeMetricsIntegrationfeat(node): Add nodeRuntimeMetricsIntegrationMar 24, 2026
@chargome
chargome marked this pull request as ready for review March 24, 2026 15:54
@chargome
chargome requested a review from Lms24March 24, 2026 15:54
@chargome
chargome requested a review from JPeer264March 24, 2026 15:54

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: process.once prevents serverless flush after first invocation
    • Changed process.once to process.on so the beforeExit listener fires on every serverless invocation, not just the first one.

Create PR

Or push these changes by commenting:

@cursor push 152bf6699a
Preview (152bf6699a)
diff --git a/packages/node-core/src/integrations/nodeRuntimeMetrics.ts b/packages/node-core/src/integrations/nodeRuntimeMetrics.ts--- a/packages/node-core/src/integrations/nodeRuntimeMetrics.ts+++ b/packages/node-core/src/integrations/nodeRuntimeMetrics.ts@@ -202,7 +202,7 @@
// Collect and flush at the end of every invocation. In non-serverless environments
// flushIfServerless is a no-op, so this is safe to call unconditionally.
- process.once('beforeExit', () => {+ process.on('beforeExit', () => {
collectMetrics();
void flushIfServerless();
});

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts Outdated
…ener
Fixes the beforeExit listener to fire on every invocation in serverless
warm starts (e.g. AWS Lambda). Also properly removes the old listener on
re-init to avoid accumulation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts Outdated

@Lms24Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Had some questions/minor suggestions but nice! TIL about the event loop metrics.

Comment threaddev-packages/node-integration-tests/suites/node-runtime-metrics/test.ts Outdated
Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts Outdated
Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts Outdated
Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts Outdated
Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts
Framework wrappers (SvelteKit, TanStack, etc.) already call flushIfServerless
after each request handler. The beforeExit flush was redundant and introduced
an infinite loop risk since Node.js re-emits beforeExit after async work
completes. Metrics are sent by the periodic interval or the existing SDK
flush infrastructure.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rtions in tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@cursorcursorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment threadpackages/node-core/src/integrations/nodeRuntimeMetrics.ts
chargomeand others added 3 commits March 25, 2026 11:13
…meMetricsIntegration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chargomeand others added 2 commits March 25, 2026 11:34
…s in integration tests
ArrayContaining items are matched with strict equals (subsetEquality is not
propagated), so extra attributes like sentry.timestamp.sequence and server.address
caused all arrayContaining matches to fail. Wrapping with expect.objectContaining
allows extra keys.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@chargome
chargome requested review from Lms24 and logaretmMarch 25, 2026 13:40

@Lms24Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding my suggestions!

@chargome
chargome merged commit 4ffea2d into developMar 25, 2026
239 of 240 checks passed
@chargome
chargome deleted the feat/node-runtime-metrics branch March 25, 2026 14:51
chargome added a commit that referenced this pull request Mar 27, 2026
Add E2E tests for `nodeRuntimeMetricsIntegration` (#19923) in two test
applications:
- **node-express-v5**: Enables the integration in the Express app's
Sentry init and adds 4 tests verifying all 8 default runtime metrics are
emitted with correct shape
- **nextjs-16**: Enables the integration in the server config and adds
the same 4 tests, verifying metrics flow through the Next.js server
runtime
Both test suites use `waitForMetric` from `@sentry-internal/test-utils`
and validate metric type, unit, value, and attributes (including
`sentry.origin: 'auto.node.runtime_metrics'`). The collection interval
is set to 1 second to keep tests fast.
Refs #19923
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chargome added a commit to getsentry/sentry-docs that referenced this pull request Mar 27, 2026
Document the new nodeRuntimeMetricsIntegration for collecting Node.js
runtime health metrics (memory, CPU, event loop, uptime).
Ref: getsentry/sentry-javascript#19923
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
github-actionsBot added a commit to getsentry/sentry-for-ai that referenced this pull request Mar 30, 2026
…eMetricsIntegration
Documents the new runtime metrics integrations introduced in sentry-javascript
(getsentry/sentry-javascript#19923, #19979) which were missing from the skill.
Co-Authored-By: claude-sonnet-4-6 <noreply@anthropic.com>
chargome added a commit to getsentry/sentry-docs that referenced this pull request Mar 31, 2026
## DESCRIBE YOUR PR
Document the new `nodeRuntimeMetricsIntegration` added in
getsentry/sentry-javascript#19923.
Documents getsentry/sentry-javascript#19923
- Add integration documentation page with default/opt-in metrics table
and configuration options
- Add integration to all Node.js-based platform integration tables
## IS YOUR CHANGE URGENT?
- [ ] Urgent deadline (GA date, etc.)
- [ ] Other deadline
- [x] None: Not urgent, can wait up to 1 week+
## SLA
- Teamwork makes the dream work, so please add a reviewer to your PRs.
- Please give the docs team up to 1 week to review your PR unless you've
added an urgent due date to it.
Thanks in advance for your help!
## PRE-MERGE CHECKLIST
- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HazAT pushed a commit to getsentry/sentry-for-ai that referenced this pull request Apr 8, 2026
…eMetricsIntegration (#84)
Documents the new runtime metrics integrations introduced in sentry-javascript
(getsentry/sentry-javascript#19923, #19979) which were missing from the skill.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: claude-sonnet-4-6 <noreply@anthropic.com>
chargome added a commit to getsentry/sentry that referenced this pull request May 5, 2026
…113517)
Add the Node.js Runtime Metrics prebuilt dashboard and its onboarding
panel. Seven widgets:
- Event Loop Utilization, CPU Utilization, Process Uptime (KPIs)
- Memory Usage (RSS / heap total / heap used — area chart)
- CPU Utilization Over Time (line)
- HTTP Request Duration (p50 / p95 — line, spans dataset)
Surfaces the `node.runtime.*` trace metrics emitted by
`nodeRuntimeMetricsIntegration` (getsentry/sentry-javascript#19923) so
users can monitor CPU, memory, and event loop health alongside request
latency.
Metric names, types, and aggregations are aligned with the SDK:
- `max()` on the pre-computed p50/p99 event loop delay percentiles
(averaging pre-computed percentiles is statistically incorrect).
- `sum()` on `process.uptime` — the SDK emits elapsed-since-last-tick
deltas as a counter, so summing across the window gives total
process-seconds.
Trade-off: users with transactions but no runtime metrics will see empty
widgets rather than the onboarding panel.
Onboarding:
<img width="1714" height="1200" alt="Screenshot 2026-04-20 at 15 39 56"
src="https://github.com/user-attachments/assets/2e539210-0207-4849-b0c7-afe5d945a6a1"
/>
Dashboard:
<img width="2404" height="980" alt="Screenshot 2026-04-21 at 10 38 08"
src="https://github.com/user-attachments/assets/46de8e4e-6f4f-4ad4-8069-63de9e5b5a98"
/>
depends on #113516
ref getsentry/sentry-javascript#19923
closes
https://linear.app/getsentry/issue/DAIN-1532/create-prebuilt-nodejs-health-dashboard
cleptric pushed a commit to getsentry/sentry that referenced this pull request May 5, 2026
…113517)
Add the Node.js Runtime Metrics prebuilt dashboard and its onboarding
panel. Seven widgets:
- Event Loop Utilization, CPU Utilization, Process Uptime (KPIs)
- Memory Usage (RSS / heap total / heap used — area chart)
- CPU Utilization Over Time (line)
- HTTP Request Duration (p50 / p95 — line, spans dataset)
Surfaces the `node.runtime.*` trace metrics emitted by
`nodeRuntimeMetricsIntegration` (getsentry/sentry-javascript#19923) so
users can monitor CPU, memory, and event loop health alongside request
latency.
Metric names, types, and aggregations are aligned with the SDK:
- `max()` on the pre-computed p50/p99 event loop delay percentiles
(averaging pre-computed percentiles is statistically incorrect).
- `sum()` on `process.uptime` — the SDK emits elapsed-since-last-tick
deltas as a counter, so summing across the window gives total
process-seconds.
Trade-off: users with transactions but no runtime metrics will see empty
widgets rather than the onboarding panel.
Onboarding:
<img width="1714" height="1200" alt="Screenshot 2026-04-20 at 15 39 56"
src="https://github.com/user-attachments/assets/2e539210-0207-4849-b0c7-afe5d945a6a1"
/>
Dashboard:
<img width="2404" height="980" alt="Screenshot 2026-04-21 at 10 38 08"
src="https://github.com/user-attachments/assets/46de8e4e-6f4f-4ad4-8069-63de9e5b5a98"
/>
depends on #113516
ref getsentry/sentry-javascript#19923
closes
https://linear.app/getsentry/issue/DAIN-1532/create-prebuilt-nodejs-health-dashboard
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(node): Add nodeRuntimeMetricsIntegration

2 participants

@chargome@Lms24