fix: use GenAI semconv explicit bucket boundaries for OTEL histograms#312244
Merged
fix: use GenAI semconv explicit bucket boundaries for OTEL histograms#312244
Conversation
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
Contributor
There was a problem hiding this comment.
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
MetricOptionsmapping withadvice.explicitBucketBoundariesfor 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
roblourens
approved these changes
Apr 23, 2026
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.
Summary
Set
ExplicitBucketBoundariesadvisory parameters ongen_ai.client.operation.durationandgen_ai.client.token.usagehistogram instruments per the OpenTelemetry GenAI semantic conventions, instead of relying on SDK default buckets (0–10,000).Boundaries applied
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
MetricOptionswithadvice.explicitBucketBoundariesinNodeOTelService. WhencreateHistogram()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