Skip to content

fix: widen v8js.gc.duration histogram buckets#1119

Merged
fenos merged 2 commits into
supabase:masterfrom
mcollina:feat/gc-duration-buckets
May 21, 2026
Merged

fix: widen v8js.gc.duration histogram buckets#1119
fenos merged 2 commits into
supabase:masterfrom
mcollina:feat/gc-duration-buckets

Conversation

@mcollina
Copy link
Copy Markdown
Contributor

Summary

The v8js.gc.duration histogram emitted by @opentelemetry/instrumentation-runtime-node uses 4 hardcoded bucket boundaries: [10ms, 100ms, 1s, 10s]. This is one bucket per decade, which:

  • collapses every incremental and minor GC pause (typically sub-millisecond to a few ms) into the first bucket, making them indistinguishable, and
  • provides no resolution above 1s, so a 1.2s major-GC pause and a 9s one land in the same bucket.

This PR adds a View on the runtime-node meter that overrides the buckets for v8js.gc.duration only, with boundaries (in seconds):

100µs, 250µs, 500µs, 1ms, 2.5ms, 5ms, 10ms, 25ms, 50ms,
100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s, 30s

Sub-ms boundaries surface incremental/minor pauses; the 2.5s/5s/10s/30s tail keeps long major collections visible before the overflow bucket.

No other metric is affected — the override is scoped to meterName: '@opentelemetry/instrumentation-runtime-node', instrumentName: 'v8js.gc.duration'.

Test plan

  • npx tsc -noEmit
  • npm run lint
  • npx vitest run --config vitest.unit.config.ts src/internal/monitoring (69 tests pass)
  • After deploy, verify v8js_gc_duration_bucket series in Prometheus/OTLP backend exposes the new le values and that incremental-kind samples populate buckets below 10ms.

The @opentelemetry/instrumentation-runtime-node default buckets for
v8js.gc.duration are [10ms, 100ms, 1s, 10s], which lumps every
incremental and minor GC pause into the first bucket and provides no
resolution above 1s for long major collections.

Add a View on this meter to use sub-millisecond boundaries from 100µs up
through 30s, so incremental/minor pauses are distinguishable and major
pauses above 1s land in their own buckets.
@mcollina mcollina requested a review from a team as a code owner May 21, 2026 08:28
Copilot AI review requested due to automatic review settings May 21, 2026 08:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines OpenTelemetry metric aggregation for Node.js runtime GC pause durations by adding a scoped View override for the v8js.gc.duration histogram, improving resolution for sub-millisecond pauses and long major-GC events without affecting other metrics.

Changes:

  • Adds a dedicated explicit-bucket boundary set for v8js.gc.duration.
  • Registers a View scoped to meterName: '@opentelemetry/instrumentation-runtime-node' and instrumentName: 'v8js.gc.duration' to apply the new buckets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/internal/monitoring/otel-metrics.ts Outdated
Comment thread src/internal/monitoring/otel-metrics.ts
@coveralls
Copy link
Copy Markdown

coveralls commented May 21, 2026

Coverage Report for CI Build 26215109574

Coverage decreased (-0.003%) to 74.989%

Details

  • Coverage decreased (-0.003%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 10373
Covered Lines: 8193
Line Coverage: 78.98%
Relevant Branches: 6004
Covered Branches: 4088
Branch Coverage: 68.09%
Branches in Coverage %: Yes
Coverage Strength: 411.24 hits per line

💛 - Coveralls

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@fenos fenos enabled auto-merge (squash) May 21, 2026 08:40
@fenos fenos merged commit 3f44f1a into supabase:master May 21, 2026
18 checks passed
Sign up for free to 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.

5 participants