-
Notifications
You must be signed in to change notification settings - Fork 821
Open
Labels
Description
What problem do you want to solve?
Add OpenTelemetry instrumentation for the Anthropic Claude Python SDK (anthropic package) to support tracing of Messages API calls, following the same pattern as the existing OpenAI instrumentation.
Describe the solution you'd like
Create a new instrumentation package opentelemetry-instrumentation-anthropic (or similar naming) that:
- Instruments the Anthropic Messages API (anthropic.messages.create())
- Captures request/response attributes following GenAI semantic conventions
- Emits log events for messages (with opt-in content capture)
- Records metrics for operation duration and token usage
- Supports both sync and async operations
- Handles streaming responses
Describe alternatives you've considered
No response
Additional Context
- Follow the same structure as opentelemetry-instrumentation-openai-v2
- Use gen_ai.system = "anthropic"
- Map Anthropic's stop_reason (single value) to gen_ai.response.finish_reasons (array format)
- Handle Anthropic's content block structure (array of content blocks vs OpenAI's string/array)
- Support opt-in content capture via OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT
Would you like to implement a fix?
Yes
Tip
References
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.