Commit 734eb1c
authored
fix(genai-instrumentors): cleanup code, align with OTel GenAI semconv, add missing attributes and fix deprecated usage (#706)
*Description of changes:*
Further aligns GenAI instrumentors with the OTel GenAI semantic
conventions spec.
- Use `SpanKind.CLIENT` for inference spans in LlamaIndex
instrumentation
- Fix `retrieval` operation span in LlamaIndex instrumentation
- Remove `gen_ai.system_instructions` from `invoke_agent` span
- Remove `on_agent_action`/`on_agent_finish` from LangChain as
on_chain_start will capture these spans
- add `gen_ai.response.finish_reasons` from model responses
- add LLM request params: `frequency_penalty`, `presence_penalty`,
`stop_sequences`, `top_p`, `top_k` across all instrumentors
- add `ToolCallRequestPart` and `ReasoningPart` in LlamaIndex output
messages
- fixed `error.message` to `error.type` in CrewAI per OTel spec
- changed `gen_ai.prompt` to `gen_ai.input.messages` in LangChain per
OTel spec
- changed `gen_ai.prompt` to `gen_ai.prompt.name` in MCP per OTel spec
- add `record_exception()` to LangChain error path
*Tests:*
- Contract tests: replace hardcoded strings with OTel semconv imports
- Contract tests: assert `gen_ai.system_instructions` on all chat spans
- add provider subtests for finish_reasons
- add OTel JSON schema validation for ToolCallRequestPart and
ReasoningPart
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.1 parent db1f721 commit 734eb1c
13 files changed
Lines changed: 481 additions & 213 deletions
File tree
- aws-opentelemetry-distro
- src/amazon/opentelemetry/distro/instrumentation
- crewai
- langchain
- llama_index
- mcp
- tests/amazon/opentelemetry/distro/instrumentation
- crewai
- langchain
- llama_index
- mcp
- contract-tests/tests/test/amazon/gen_ai
- crewai
- llamaindex
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
Lines changed: 29 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
| 31 | + | |
| 32 | + | |
29 | 33 | | |
30 | 34 | | |
31 | 35 | | |
| |||
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| |||
201 | 206 | | |
202 | 207 | | |
203 | 208 | | |
204 | | - | |
205 | | - | |
| 209 | + | |
| 210 | + | |
206 | 211 | | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
210 | | - | |
211 | | - | |
| 215 | + | |
| 216 | + | |
212 | 217 | | |
213 | 218 | | |
214 | 219 | | |
215 | | - | |
| 220 | + | |
216 | 221 | | |
217 | 222 | | |
218 | 223 | | |
| |||
233 | 238 | | |
234 | 239 | | |
235 | 240 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| |||
244 | 246 | | |
245 | 247 | | |
246 | 248 | | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
253 | 261 | | |
254 | 262 | | |
255 | 263 | | |
| |||
259 | 267 | | |
260 | 268 | | |
261 | 269 | | |
262 | | - | |
263 | | - | |
| 270 | + | |
| 271 | + | |
264 | 272 | | |
265 | 273 | | |
266 | 274 | | |
| |||
296 | 304 | | |
297 | 305 | | |
298 | 306 | | |
299 | | - | |
300 | | - | |
| 307 | + | |
| 308 | + | |
301 | 309 | | |
302 | 310 | | |
303 | 311 | | |
| |||
344 | 352 | | |
345 | 353 | | |
346 | 354 | | |
| 355 | + | |
347 | 356 | | |
348 | 357 | | |
349 | 358 | | |
| |||
412 | 421 | | |
413 | 422 | | |
414 | 423 | | |
415 | | - | |
| 424 | + | |
416 | 425 | | |
417 | 426 | | |
418 | 427 | | |
| |||
Lines changed: 40 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
| 33 | + | |
31 | 34 | | |
| 35 | + | |
32 | 36 | | |
33 | 37 | | |
34 | 38 | | |
| |||
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| |||
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
155 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| |||
174 | 181 | | |
175 | 182 | | |
176 | 183 | | |
177 | | - | |
178 | | - | |
179 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
180 | 189 | | |
181 | 190 | | |
182 | 191 | | |
| |||
283 | 292 | | |
284 | 293 | | |
285 | 294 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | 295 | | |
313 | 296 | | |
314 | 297 | | |
| |||
470 | 453 | | |
471 | 454 | | |
472 | 455 | | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
473 | 468 | | |
474 | 469 | | |
475 | 470 | | |
| |||
512 | 507 | | |
513 | 508 | | |
514 | 509 | | |
| 510 | + | |
515 | 511 | | |
516 | 512 | | |
517 | 513 | | |
| |||
553 | 549 | | |
554 | 550 | | |
555 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
556 | 564 | | |
557 | 565 | | |
558 | 566 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
| 153 | + | |
| 154 | + | |
153 | 155 | | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
157 | | - | |
| 159 | + | |
158 | 160 | | |
159 | 161 | | |
160 | 162 | | |
| |||
0 commit comments