Uh oh!
There was an error while loading. Please reload this page.
feat(bun): Add bunRuntimeMetricsIntegration - #19979
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Deps
Other
Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧Core
Deps
Deps Dev
Other
🤖 This preview updates automatically when you update the PR. |
size-limit report 📦
|
…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>
…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>
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>
…meMetricsIntegration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…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>
Mirrors nodeRuntimeMetricsIntegration but adapted for Bun: - Same CPU, memory, ELU, and uptime metrics - No event loop delay percentiles (monitorEventLoopDelay not available in Bun) - ELU wrapped in try/catch for forward compatibility with older Bun versions - Metrics use bun.runtime.* prefix and auto.bun.runtime_metrics origin - BunRuntimeMetricsOptions reuses NodeRuntimeMetricsOptions collect shape (minus the unsupported eventLoopDelay* flags) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds node-integration-tests scenarios that exercise the bun integration using @sentry/node for init (bunRuntimeMetricsIntegration is Node-compatible since it only uses perf_hooks and process.*). Four test scenarios: - default metrics shape (6 metrics with correct attributes/units) - opt-in metrics not emitted by default - all metrics when cpuTime + memExternal opted in - opt-out leaves only memory metrics Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
bc1c167 to
33f816bCompare| ### Important Changes | ||
| - **feat(node, bun): Add runtime metrics integrations for Node.js and Bun ([#19923](https://github.com/getsentry/sentry-javascript/pull/19923), [#19979](https://github.com/getsentry/sentry-javascript/pull/19979))** | ||
| New `nodeRuntimeMetricsIntegration` and `bunRuntimeMetricsIntegration` automatically collect runtime health metrics and send them to Sentry on a configurable interval (default: 30s). Collected metrics include memory (RSS, heap used/total), CPU utilization, event loop utilization, and process uptime. Node additionally collects event loop delay percentiles (p50, p99). Extra metrics like CPU time and external memory are available as opt-in. | ||
| ```ts | ||
| // Node.js | ||
| import * as Sentry from '@sentry/node'; | ||
| Sentry.init({ | ||
| dsn: '...', | ||
| integrations: [Sentry.nodeRuntimeMetricsIntegration()], | ||
| }); |
There was a problem hiding this comment.
I added the note for node again bc this was somehow lost in the gitflow merge (?)
Document the new bunRuntimeMetricsIntegration for collecting Bun runtime health metrics (memory, CPU, event loop, uptime). Ref: getsentry/sentry-javascript#19979 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
Explicitly pick the metrics available in Bun rather than omitting Node-only fields, so new Node metrics don't silently leak into Bun. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
|
Uh oh!
There was an error while loading. Please reload this page.
## DESCRIBE YOUR PR Document the new `bunRuntimeMetricsIntegration` added in getsentry/sentry-javascript#19979. Documents getsentry/sentry-javascript#19979 - Add integration documentation page with default/opt-in metrics table and configuration options - Add integration to the Bun platform integration table --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds a new
bunRuntimeMetricsIntegrationthat collects runtime metrics on a configurable interval usingprocess.memoryUsage(),process.cpuUsage(),performance.eventLoopUtilization(), andprocess.uptime().Default metrics (
bun.runtime.*prefix):mem.rss,mem.heap_used,mem.heap_totalcpu.utilizationevent_loop.utilizationprocess.uptimeOpt-in:
cpuTime(cpu.user,cpu.system),memExternal(mem.external,mem.array_buffers)vs.
nodeRuntimeMetricsIntegration: No event loop delay histogram metrics (monitorEventLoopDelayisunavailable in Bun). ELU is guarded with try/catch for older Bun versions. Uses
bun.runtime.*prefix andauto.bun.runtime_metricsorigin.Includes unit tests (
bun:test) and integration tests.closes https://linear.app/getsentry/issue/JS-1956/runtime-metrics-bun-support