Trace Every Agent Step with OpenTelemetry in Python
Which step of my agent failed, and which was slow? One trace showed both, with the time each step took.
Video #35 ยท AI agents and MCP
Steps in the video
Files
- agent.py (39 lines)
- report.py (16 lines)
- tracing.py (10 lines)
Tested with
Python 3.12.15 | opentelemetry-sdk==1.45.1
What this does not show
The slow step and the failure are staged with a sleep and a raised error. No model call, no collector, no sampling and no network. One trace in one process, timed on Windows, where very short spans are only roughly timed.
Sources
Learning IT by Example.