-
Notifications
You must be signed in to change notification settings - Fork 847
Open
Labels
Description
What problem do you want to solve?
Add OpenTelemetry instrumentation for the Anthropic Claude Agent SDK (claude-agent-sdk package) to support tracing of agent operations, tool executions, and MCP server interactions, following the GenAI Agent Semantic Conventions.
Describe the solution you'd like
Create a new instrumentation package opentelemetry-instrumentation-anthrophic-agents (or similar naming) that:
Core Instrumentation
- Instruments agent query operations (
query()andClaudeSDKClient.query()) - Creates
invoke_agentspans for agent invocations following GenAI agent span conventions. - Creates
execute_toolspans for each tool execution (Read, Write, Bash, Edit, etc.) - Instruments custom MCP server tool calls created via
@tooldecorator andcreate_sdk_mcp_server() - Captures hook executions (
PreToolUse,PostToolUse, etc.) as span events or child spans.
Edit 1: I am working with agent-sdk maintainers to see if they can support trace and span creation. I will update the plan accordingly once I hear back from them.
Describe alternatives you've considered
No response
Additional Context
- Follow the structure of
opentelemetry-instrumentation-openai-v2 - Use
gen_ai.provider.name="anthropic"(already in OTel well-known values) - Map
ClaudeAgentOptionsfields to appropriategen_ai.*attributes - Handle
AssistantMessage,UserMessage,ResultMessage,SystemMessagetypes - Extract
ToolUseBlockandToolResultBlockfor tool span creation
Would you like to implement a fix?
Yes
References
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
dkmiller