Commit 70f9c1b
committed
fix(semconv): attach spec-mandated explicit bucket boundaries to GenAI 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 #4946
Signed-off-by: Ali <alliasgher123@gmail.com>1 parent 7477b10 commit 70f9c1b
2 files changed
Lines changed: 55 additions & 0 deletions
File tree
- opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
opentelemetry-semantic-conventions/src/opentelemetry/semconv/_incubating/metrics/gen_ai_metrics.py
Lines changed: 53 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
28 | 47 | | |
29 | 48 | | |
30 | 49 | | |
31 | 50 | | |
32 | 51 | | |
33 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
34 | 56 | | |
35 | 57 | | |
36 | 58 | | |
| |||
61 | 83 | | |
62 | 84 | | |
63 | 85 | | |
| 86 | + | |
| 87 | + | |
64 | 88 | | |
65 | 89 | | |
66 | 90 | | |
67 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
68 | 95 | | |
69 | 96 | | |
70 | 97 | | |
| |||
78 | 105 | | |
79 | 106 | | |
80 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
81 | 126 | | |
82 | 127 | | |
83 | 128 | | |
84 | 129 | | |
85 | 130 | | |
86 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
87 | 135 | | |
88 | 136 | | |
89 | 137 | | |
| |||
97 | 145 | | |
98 | 146 | | |
99 | 147 | | |
| 148 | + | |
| 149 | + | |
100 | 150 | | |
101 | 151 | | |
102 | 152 | | |
103 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
104 | 157 | | |
0 commit comments