-
Notifications
You must be signed in to change notification settings - Fork 22
feat: Add instrumentation for claude agent sdk #103 #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Initial implementation of Claude Agent SDK instrumentation - Support for agent query sessions via Hooks mechanism - Support for tool execution tracing (PreToolUse/PostToolUse hooks) - Integration with opentelemetry-util-genai ExtendedTelemetryHandler - Span attributes following OpenTelemetry GenAI Semantic Conventions - Support for Alibaba Cloud DashScope Anthropic-compatible API Change-Id: aebd1fd0-3afc-4a37-af74-3800c117aaf0 Change-Id: I187974bfe8b44b9f592ffcb368e11d98c41f1a30 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ie6eab7ffae40e000b3b2c55a0abe50848490c1e7 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I2656979e57ed2e9b3110867f9e5f6321d45cb3e2 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ibf6f934583ed0e76a4f79016cbfbade94a05acec Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I1420318408a53e563499c43a3cc2ae86ed0aa929 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Iab09e483df20ef8ad44545e36d0d83f5ae0cae1d Co-developed-by: Cursor <noreply@cursor.com>
c3e3afb to
462b1a0
Compare
Change-Id: I55134f7e3ef30b7192deab801b12b132b250a31c Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I44bf3572fa7d8bf7d47b665d3463433a93076f9c Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I4308f8d8ecc7048c1bc9d1d9ec824addad1c5912 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ice677164663bc066e830b3cd24c09697d2dd0fb1 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ieadc2e7ea2193e301c171c62eee9da3179c95199 Co-developed-by: Cursor <noreply@cursor.com>
a3b3f65 to
c38bdcd
Compare
Change-Id: I4464ce9be8aab760c5b6a497e6b5bfd865d927ed Co-developed-by: Cursor <noreply@cursor.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds OpenTelemetry instrumentation for the Claude Agent SDK, enabling automatic tracing and metrics collection for Claude agent conversations, LLM calls, and tool executions. The implementation introduces a new instrumentation package that follows OpenTelemetry GenAI semantic conventions.
Changes:
- Adds comprehensive instrumentation for Claude Agent SDK including agent sessions, tool executions, and token tracking
- Implements test suites covering unit tests, integration tests, edge cases, and attribute validation
- Configures CI/CD workflows for automated testing and linting across multiple Python versions
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tox-loongsuite.ini | Adds tox environment configuration for claude-agent-sdk instrumentation testing |
| .github/workflows/loongsuite_test_0.yml | Adds CI test jobs for Python 3.10-3.13 across oldest/latest dependency versions |
| .github/workflows/loongsuite_lint_0.yml | Adds linting job for claude-agent-sdk instrumentation |
| util/opentelemetry-util-genai/.../pre_uploader.py | Adds pyright ignore comment for numpy import |
| instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk/* | New instrumentation package with source code, tests, and documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...instrumentation-claude-agent-sdk/src/opentelemetry/instrumentation/claude_agent_sdk/patch.py
Outdated
Show resolved
Hide resolved
...instrumentation-claude-agent-sdk/src/opentelemetry/instrumentation/claude_agent_sdk/hooks.py
Outdated
Show resolved
Hide resolved
...instrumentation-claude-agent-sdk/src/opentelemetry/instrumentation/claude_agent_sdk/hooks.py
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk/tests/test_edge_cases.py
Show resolved
Hide resolved
Change-Id: I39681d6a7c105b1653d75c7f8397a30bc94b785a Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I9694ccab2f5bf9eb8d24deb644b78f60555a5bdf Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I50bda0c04949a1e536106e9221d2755b23aba8ae Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I960449e43e8a3522bdafd9c0dbd6fcb7dff15345 Co-developed-by: Cursor <noreply@cursor.com>
| @@ -0,0 +1,17 @@ | |||
| # Changelog | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need changelog here. Changes should be added to CHANGLOG-loongsuite.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other packages have their own CHANGELOG.md file. Perhaps we update the root CHANGELOG-loongsuite.md during releases?
| @@ -0,0 +1,201 @@ | |||
| Apache License | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other packages in instrumentation-genai/ and instrumentation-loongsuite/ include LICENSE files. This might be because these packages may be used standalone.
instrumentation-loongsuite/loongsuite-instrumentation-claude-agent-sdk/pyproject.toml
Outdated
Show resolved
Hide resolved
Change-Id: I4bab45d35f385a2fe25af0d8e2456db187ec46d6 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ic5c347a1241bda769fe8af50dc50397fd5b4e869 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ieb6c0fa2f44b1b517b2998da0b58afffd4598d15 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: Ib3954bfc8863415404e7b2a12a9b3ee147754ff6 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: If7c6314141852aa249d73bf22316aa1aab486b21 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I5d569a4ef592ad2802984e43dbd74a27e8b309a5 Co-developed-by: Cursor <noreply@cursor.com>
Description
This PR adds OpenTelemetry instrumentation support for Claude Agent SDK, enabling automatic tracing and metrics collection for Claude agent conversations, LLM calls, and tool executions.
Fixes #103
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Lint check
tox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-claude-agent-sdk
Unit tests (Python 3.12 + latest)
tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-claude-agent-sdk-latest
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.