feat: add OpenTelemetry support for telemetry metrics and tracing#542
Open
vasantteja wants to merge 2 commits intoanthropics:mainfrom
Open
feat: add OpenTelemetry support for telemetry metrics and tracing#542vasantteja wants to merge 2 commits intoanthropics:mainfrom
vasantteja wants to merge 2 commits intoanthropics:mainfrom
Conversation
- Introduced optional telemetry configuration in `pyproject.toml` for OpenTelemetry dependencies. - Added `TelemetryOptions` class to manage telemetry settings. - Integrated telemetry into the `ClaudeSDKClient`, `Query`, and `SubprocessCLITransport` classes for tracing and metrics. - Updated README with instructions for enabling telemetry and examples of span names and metrics emitted. - Added tests for telemetry utilities to ensure proper functionality. This enhancement allows users to monitor and trace SDK operations, improving observability and debugging capabilities.
- Updated Dockerfile and GitHub Actions workflow to install SDK with telemetry dependencies. - Modified README to clarify installation instructions and added details about telemetry tests. - Introduced new end-to-end tests for telemetry integration, verifying metrics and tracing functionality. - Adjusted `conftest.py` to improve test marker documentation. These changes improve the observability of SDK operations and ensure proper testing of telemetry features.
Author
|
@ashwin-ant @dicksontsai Can you please take a look at this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
claude_agent_sdk.<layer>.<operation>), plus new top‑level lifecycle spans forClaudeSDKClientand one‑shotquery()usage.Spans Added/Updated
claude_agent_sdk.client.connect,claude_agent_sdk.client.query,claude_agent_sdk.client.disconnectclaude_agent_sdk.query.lifecycle,claude_agent_sdk.query.initialize,claude_agent_sdk.query.read_messages,claude_agent_sdk.query.stream_input,claude_agent_sdk.query.closeclaude_agent_sdk.transport.connect,claude_agent_sdk.transport.read_messages,claude_agent_sdk.transport.write,claude_agent_sdk.transport.closeclaude_agent_sdk.permission.can_use_tool,claude_agent_sdk.hooks.callbackclaude_agent_sdk.mcp.request,claude_agent_sdk.mcp.tool_callclaude_agent_sdk.cli.tool_callMetrics Added
messages,results,errors,invocationstokens.prompt,tokens.completion,tokens.totalmodel.latency_ms,model.errorsresult.duration_ms,result.cost_usd,cost.total_usdresponse.size_bytes,throttledsession.idfor grouping.