Skip to content

Conversation

@sipercai
Copy link
Collaborator

@sipercai sipercai commented Jan 9, 2026

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

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

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

  • Test

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?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

- 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>
@sipercai sipercai force-pushed the liuyu/claude-clean branch from c3e3afb to 462b1a0 Compare January 9, 2026 03:39
sipercai and others added 6 commits January 9, 2026 14:06
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>
Change-Id: I4464ce9be8aab760c5b6a497e6b5bfd865d927ed
Co-developed-by: Cursor <noreply@cursor.com>
Copy link

Copilot AI left a 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.

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
Copy link
Collaborator

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

Copy link
Collaborator Author

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
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add instrumentation for claude agent sdk

4 participants