feat(bun): Add bunRuntimeMetricsIntegration#19979
Draft
Conversation
…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>
Contributor
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 🐛Cloudflare
Core
Deps
Other
Internal Changes 🔧Deps Dev
Nuxt
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
size-limit report 📦
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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