Skip to content

fix: use GenAI semconv explicit bucket boundaries for OTEL histograms#312244

Merged
zhichli merged 1 commit intomainfrom
zhichli/otelfix1
Apr 23, 2026
Merged

fix: use GenAI semconv explicit bucket boundaries for OTEL histograms#312244
zhichli merged 1 commit intomainfrom
zhichli/otelfix1

Conversation

@zhichli
Copy link
Copy Markdown
Member

@zhichli zhichli commented Apr 23, 2026

Summary

Set ExplicitBucketBoundaries advisory parameters on gen_ai.client.operation.duration and gen_ai.client.token.usage histogram instruments per the OpenTelemetry GenAI semantic conventions, instead of relying on SDK default buckets (0–10,000).

Boundaries applied

Metric Boundaries
gen_ai.client.operation.duration [0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, 20.48, 40.96, 81.92]
gen_ai.client.token.usage [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864]

Approach

Added a static map of per-metric MetricOptions with advice.explicitBucketBoundaries in NodeOTelService. When createHistogram() is called, the advisory options are passed if a mapping exists; otherwise the SDK default applies (no behavior change for non-GenAI histograms).

Fixes #311905

Set ExplicitBucketBoundaries advisory parameters on gen_ai.client.operation.duration
and gen_ai.client.token.usage histograms per the OpenTelemetry GenAI semantic
conventions, instead of relying on SDK default buckets.

Fixes #311905
Copilot AI review requested due to automatic review settings April 23, 2026 22:22
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

Updates the Copilot extension’s Node OpenTelemetry metrics setup to follow the GenAI semantic conventions by applying explicit bucket boundaries for the GenAI histogram instruments, rather than relying on SDK defaults.

Changes:

  • Add a static per-metric MetricOptions mapping with advice.explicitBucketBoundaries for GenAI histograms.
  • Pass the mapped options into Meter.createHistogram() when creating histograms.
Show a summary per file
File Description
extensions/copilot/src/platform/otel/node/otelServiceImpl.ts Adds GenAI histogram bucket boundary advice and applies it when creating histogram instruments.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread extensions/copilot/src/platform/otel/node/otelServiceImpl.ts
@zhichli zhichli enabled auto-merge April 23, 2026 22:28
@zhichli zhichli merged commit 03beef5 into main Apr 23, 2026
44 of 45 checks passed
@zhichli zhichli deleted the zhichli/otelfix1 branch April 23, 2026 23:26
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 23, 2026
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.

VS Code copilot OTEL bounds incorrect

3 participants