Quick Start
Compatibility
What Gets Traced
The instrumentor automatically captures:- Agent runs - Every agent invocation with inputs and outputs
- Tool executions - Built-in tool calls (Bash, Read, Write, Glob) with arguments and results
- Multi-turn conversations - Session continuity across turns with
ClaudeSDKClient - Token usage and cost - Model token counts and cost per request
Example: Single Query with Tools
Thequery() function runs a one-off agent session. The agent can use built-in tools to complete tasks autonomously:
permission_mode="bypassPermissions" allows unrestricted tool use without interactive prompts. Use only in sandboxed or non-interactive environments.Example: Multi-Turn Conversation
ClaudeSDKClient maintains session continuity across multiple turns. The agent remembers context from previous interactions:
Troubleshooting
Traces not appearing
- Check environment variables - Ensure
HH_API_KEYis set - Pass the tracer provider - The instrumentor must receive
tracer_provider=tracer.provider:
- Import after instrumenting - Import
claude_agent_sdkafter callinginstrument(). The instrumentor patches module-level functions, so importing before patching captures the original unpatched references:
- Flush before exit - Call
tracer.force_flush()before your process exits. Without this, buffered spans may be silently dropped in short-lived scripts:
- Check Anthropic credentials - Ensure
ANTHROPIC_API_KEYis set
Related
Enrich Your Traces
Add user IDs and custom metadata to Claude Agent SDK traces
Custom Spans
Create spans for business logic around agent calls
Distributed Tracing
Trace agents across service boundaries

