Observability for the Claude Agent SDK: Tracing Tool Use and Extended Thinking with OpenTelemetry
Blog post from OpenObserve
Observability in the Claude Agent SDK primarily revolves around three OpenTelemetry signals: traces, metrics, and log events, each serving distinct purposes in monitoring and debugging agent applications. The SDK employs the Claude Code CLI as a child process, with built-in OpenTelemetry instrumentation that captures spans for each interaction, tool call, and request, while metrics track tokens and costs, and logs provide a detailed audit trail. By configuring environment variables, users can direct telemetry data to an OTLP endpoint like OpenObserve, enabling comprehensive tracing of the agent's operations, including modeling requests and interactions with external MCP servers. This setup differentiates from simple API call observations as it reveals the complex sequence of operations within an agent loop, highlighting bottlenecks and errors through distributed tracing. The SDK simplifies telemetry by automatically handling instrumentation and configuration, while allowing users to customize data collection and distribution according to their needs, ensuring sensitive data management and activity attribution. Through OpenTelemetry integration, users can correlate traces, metrics, and logs within a unified observability backend like OpenObserve, facilitating a seamless investigation workflow and enabling detailed analysis of agent performance and decision-making processes.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| MCP | 17 | 6,026 | 689 | 188 | -15% |
| Observability | 15 | 3,430 | 674 | 183 | +0% |
| OpenTelemetry | 15 | 701 | 153 | 53 | -26% |
| AI Coding Assistant | 5 | 1,586 | 431 | 148 | -12% |
| LLM | 3 | 5,172 | 1,006 | 220 | -43% |
| AI Agents | 2 | 4,874 | 1,103 | 240 | -1% |
| Data Pipeline | 1 | 441 | 203 | 86 | -29% |
| Secrets Management | 1 | 2,063 | 322 | 117 | -4% |