Commit 56f3b08
Add support for OTel GenAI Semantic Convention patterns in LLO handler (#460)
*Description of changes:*
Handle specific span events by recognizing them via event.name. Move
their associated attributes into Log events (as content) and remove them
from the original Span Event.
* gen_ai.assistant.message (output)
* gen_ai.tool.message (input)
* gen_ai.user.message (input)
* gen_ai.system.message (input)
* gen_ai.choice (output)
### Test
```
{
"resource": {
"attributes": {
"aws.local.service": "langgraph-min",
"aws.service.type": "gen_ai_agent",
"telemetry.sdk.language": "python",
"service.name": "langgraph-min",
"cloud.resource_id": "fastapi-app",
"aws.log.group.names": "test_trace-min-4",
"telemetry.sdk.version": "1.33.1",
"telemetry.auto.version": "0.11.0.dev0-aws",
"telemetry.sdk.name": "opentelemetry"
}
},
"scope": {
"name": "strands.telemetry.tracer"
},
"timeUnixNano": 1756004845660372000,
"observedTimeUnixNano": 1756004845662834000,
"severityNumber": 9,
"severityText": "",
"body": {
"output": {
"messages": [
{
"content": {
"message": "# Weather Forecast for New York City 🌤️\n\nHere's the current weather forecast for New York City (Manhattan area):\n\n## **Current Conditions (Tonight - Saturday Night, Aug 23)**\n🌙 **Tonight**: Partly Cloudy \n- **Temperature**: Low around 70°F \n- **Wind**: South 7-13 mph \n- **Precipitation**: 0% chance \n\n## **This Weekend**\n\n### **Sunday (Aug 24)**\n🌤️ **Partly Sunny** \n- **High**: 77°F \n- **Wind**: South 7-16 mph \n- **Precipitation**: 10% chance \n\n### **Sunday Night** \n🌧️ **Chance Rain Showers** (after 8pm) \n- **Low**: 72°F \n- **Wind**: South 6-15 mph \n- **Precipitation**: 40% chance \n\n### **Monday (Aug 25)** \n🌦️ **Chance Rain Showers** \n- **High**: 80°F \n- **Wind**: Southwest 6-10 mph \n- **Precipitation**: 40% chance \n\n## **Looking Ahead (Tuesday - Saturday)**\n\n**Tuesday**: ☀️ Sunny, High 76°F - Beautiful day! \n**Wednesday**: 🌤️ Mostly Sunny, High 73°F \n**Thursday**: 🌤️ Mostly Sunny, High 76°F \n**Friday**: 🌤️ Mostly Sunny, High 76°F \n**Saturday**: 🌤️ Mostly Sunny, High 75°F \n\n## **Key Highlights**\n- **Pleasant temperatures** in the mid-70s to near 80°F\n- **Possible rain** Sunday night through Monday morning\n- **Great weather** returning Tuesday with sunny skies\n- **Comfortable humidity** levels expected\n- **Light to moderate winds** throughout the period\n\nThis forecast shows typical late August weather for NYC with comfortable temperatures and mostly pleasant conditions, with just a brief chance of showers early in the week before clearing up nicely!\n",
"finish_reason": "end_turn"
},
"role": "assistant"
}
]
},
"input": {
"messages": [
{
"content": "You are a weather assistant with HTTP capabilities. You can:\n\n1. Make HTTP requests to the National Weather Service API\n2. Process and display weather forecast data\n3. Provide weather information for locations in the United States\n\nWhen retrieving weather information:\n1. First get the coordinates or grid information using https://api.weather.gov/points/{latitude},{longitude} or https://api.weather.gov/points/{zipcode}\n2. Then use the returned forecast URL to get the actual forecast\n\nWhen displaying responses:\n- Format weather data in a human-readable way\n- Highlight important information like temperature, precipitation, and alerts\n- Handle errors appropriately\n- Convert technical terms to user-friendly language\n\nAlways explain the weather conditions clearly and provide context for the forecast.\n",
"role": "system"
},
{
"content": {
"content": "[{\"text\": \"What is the weather in New York?\"}]"
},
"role": "user"
}
]
}
},
"attributes": {
"event.name": "strands.telemetry.tracer"
},
"flags": 1,
"traceId": "68aa81cd356fb8ea277cca6fbd34640d",
"spanId": "5a3802fa510a2725"
}
```
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
Co-authored-by: Michael He <53622546+yiyuan-he@users.noreply.github.com>1 parent 9e094eb commit 56f3b08
File tree
3 files changed
+391
-3
lines changed- aws-opentelemetry-distro
- src/amazon/opentelemetry/distro
- tests/amazon/opentelemetry/distro/llo_handler
3 files changed
+391
-3
lines changedLines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
140 | 170 | | |
141 | 171 | | |
142 | 172 | | |
| |||
214 | 244 | | |
215 | 245 | | |
216 | 246 | | |
| 247 | + | |
217 | 248 | | |
218 | 249 | | |
219 | 250 | | |
| |||
279 | 310 | | |
280 | 311 | | |
281 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
282 | 319 | | |
283 | 320 | | |
284 | 321 | | |
| |||
372 | 409 | | |
373 | 410 | | |
374 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
375 | 416 | | |
376 | 417 | | |
377 | 418 | | |
| |||
417 | 458 | | |
418 | 459 | | |
419 | 460 | | |
420 | | - | |
| 461 | + | |
421 | 462 | | |
422 | 463 | | |
423 | 464 | | |
| |||
0 commit comments