Commit e3df1e1
fix(metrics): remove gen_ai.agent.id from all GenAI metric dimensions (#323)
gen_ai.agent.id was set to the span ID (unique per invocation), causing
unbounded metric cardinality across all metric types. This attribute is
useful for trace lookup on spans but has no meaningful role in metric
aggregation where per-run IDs create metric series explosion.
Changes:
- Remove gen_ai.agent.id from MetricsEmitter for LLMInvocation,
EmbeddingInvocation, ToolCall, MCPToolCall, RetrievalInvocation,
and AgentInvocation (where it was hardcoded to span_id)
- gen_ai.agent.id remains on all span attributes (no span emitter change)
- gen_ai.agent.name is unaffected (bounded cardinality, kept on metrics)
- Update test assertions to verify gen_ai.agent.id is absent from
metric data points
- Document span-only constraint in semconv-reference.md
Verified: 213 unit tests pass; end-to-end SRE Copilot run confirmed
telemetry forwarded to local OTel collector with no regressions.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 9268959 commit e3df1e1
4 files changed
Lines changed: 19 additions & 41 deletions
File tree
- docs
- util/opentelemetry-util-genai
- src/opentelemetry/util/genai/emitters
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
| 285 | + | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
Lines changed: 0 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | | - | |
110 | 108 | | |
111 | 109 | | |
112 | 110 | | |
| |||
170 | 168 | | |
171 | 169 | | |
172 | 170 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
| |||
224 | 218 | | |
225 | 219 | | |
226 | 220 | | |
227 | | - | |
228 | | - | |
229 | 221 | | |
230 | 222 | | |
231 | 223 | | |
| |||
252 | 244 | | |
253 | 245 | | |
254 | 246 | | |
255 | | - | |
256 | | - | |
257 | 247 | | |
258 | 248 | | |
259 | 249 | | |
| |||
289 | 279 | | |
290 | 280 | | |
291 | 281 | | |
292 | | - | |
293 | | - | |
294 | 282 | | |
295 | 283 | | |
296 | 284 | | |
| |||
319 | 307 | | |
320 | 308 | | |
321 | 309 | | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | 310 | | |
327 | 311 | | |
328 | 312 | | |
| |||
395 | 379 | | |
396 | 380 | | |
397 | 381 | | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | 382 | | |
404 | 383 | | |
405 | 384 | | |
| |||
437 | 416 | | |
438 | 417 | | |
439 | 418 | | |
440 | | - | |
441 | | - | |
442 | 419 | | |
443 | 420 | | |
444 | 421 | | |
| |||
467 | 444 | | |
468 | 445 | | |
469 | 446 | | |
470 | | - | |
471 | | - | |
472 | 447 | | |
473 | 448 | | |
474 | 449 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
264 | | - | |
| 263 | + | |
265 | 264 | | |
266 | 265 | | |
267 | 266 | | |
| |||
270 | 269 | | |
271 | 270 | | |
272 | 271 | | |
273 | | - | |
274 | 272 | | |
275 | 273 | | |
276 | 274 | | |
277 | 275 | | |
278 | 276 | | |
279 | 277 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
398 | 400 | | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
402 | | - | |
| 404 | + | |
403 | 405 | | |
404 | 406 | | |
405 | 407 | | |
| |||
0 commit comments