fix(semconv): attach spec-mandated explicit bucket boundaries to GenAI histogram helpers#5084
Open
alliasgher wants to merge 1 commit intoopen-telemetry:mainfrom
Open
fix(semconv): attach spec-mandated explicit bucket boundaries to GenAI histogram helpers#5084alliasgher wants to merge 1 commit intoopen-telemetry:mainfrom
alliasgher wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
…I histogram helpers The four GenAI histogram helpers in opentelemetry-semantic-conventions called meter.create_histogram without passing explicit_bucket_boundaries_advisory. The SDK therefore fell back to _DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES, which is tuned for request-duration metrics in the seconds range and produces unusable histograms for latency-per-token and TTFT metrics — the exact problem flagged in the semconv spec which says these metrics SHOULD be specified with ExplicitBucketBoundaries. Pass the semconv-prescribed boundaries for all four helpers: * gen_ai.client.operation.duration / gen_ai.server.request.duration / gen_ai.server.time_to_first_token share the latency boundary set [0.01 .. 81.92] seconds. * gen_ai.server.time_per_output_token uses the per-token boundary set [0.01 .. 2.5] seconds. Add tests asserting each factory passes the correct explicit_bucket_boundaries_advisory to Meter.create_histogram. Fixes open-telemetry#4946 Signed-off-by: Ali <alliasgher123@gmail.com>
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.
Description
The four GenAI histogram helpers in
opentelemetry-semantic-conventionscalledmeter.create_histogramwithout passingexplicit_bucket_boundaries_advisory. The SDK therefore fell back to_DEFAULT_EXPLICIT_BUCKET_HISTOGRAM_AGGREGATION_BOUNDARIES, which is tuned for request-duration metrics in the seconds range and produces unusable histograms for latency-per-token and TTFT metrics — the exact problem flagged in the semconv spec, which says these metrics SHOULD be specified withExplicitBucketBoundaries.Pass the semconv-prescribed boundaries for all four helpers:
gen_ai.client.operation.duration,gen_ai.server.request.duration,gen_ai.server.time_to_first_tokenshare the latency boundary set[0.01 … 81.92]seconds.gen_ai.server.time_per_output_tokenuses the per-token boundary set[0.01 … 2.5]seconds.Fixes #4946
Checklist
pytest opentelemetry-semantic-conventions/tests/test_gen_ai_metrics.pyexplicit_bucket_boundaries_advisorytoMeter.create_histogramSigned-off-by: Ali alliasgher123@gmail.com