fix(semconv): attach spec-mandated explicit bucket boundaries to GenAI histogram helpers#5084
fix(semconv): attach spec-mandated explicit bucket boundaries to GenAI histogram helpers#5084alliasgher wants to merge 3 commits into
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>
The link pointed to opentelemetry-python-contrib/pull/5076 (404) but should reference opentelemetry-python/pull/5076, matching the main branch. Signed-off-by: Ali <alliasgher123@gmail.com>
|
Fixed the two CI failures: check-links: The CHANGELOG had a stale link pointing to pypy-3.10 Windows: The failing test |
tammy-baylis-swi
left a comment
There was a problem hiding this comment.
Overall lgtm, and this dir isn't generally tested.
It would be good if @open-telemetry/python-approvers who make regular GenAI instrumentation changes could also look at this please.
MikeGoldsmith
left a comment
There was a problem hiding this comment.
Looks good, thanks @alliasgher - I've left a suggestion to update the changelog to use the PR number instead of issue number.
| - `opentelemetry-semantic-conventions`: Attach spec-mandated explicit bucket boundaries to the GenAI histogram helpers (`gen_ai.client.operation.duration`, `gen_ai.server.request.duration`, `gen_ai.server.time_to_first_token`, `gen_ai.server.time_per_output_token`); without them the default SDK buckets produced unusable histograms for latency-per-token metrics | ||
| ([#4946](https://github.com/open-telemetry/opentelemetry-python/issues/4946)) |
There was a problem hiding this comment.
| - `opentelemetry-semantic-conventions`: Attach spec-mandated explicit bucket boundaries to the GenAI histogram helpers (`gen_ai.client.operation.duration`, `gen_ai.server.request.duration`, `gen_ai.server.time_to_first_token`, `gen_ai.server.time_per_output_token`); without them the default SDK buckets produced unusable histograms for latency-per-token metrics | |
| ([#4946](https://github.com/open-telemetry/opentelemetry-python/issues/4946)) | |
| - `opentelemetry-semantic-conventions`: Attach spec-mandated explicit bucket boundaries to the GenAI histogram helpers | |
| ([#5084](https://github.com/open-telemetry/opentelemetry-python/issues/5084)) |
lmolkova
left a comment
There was a problem hiding this comment.
I support the cause, but this code is auto-generated and changes will disappear with the next update. this is currently blocked on open-telemetry/semantic-conventions#1225.
Signed-off-by: Ali <alliasgher123@gmail.com>
|
This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment. |
|
This PR has been closed due to inactivity. Please reopen if you would like to continue working on it. |
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_histogram