feat(qwen-agent): add instrumentation for Qwen-Agent#154
Open
sipercai wants to merge 3 commits intoalibaba:mainfrom
Open
feat(qwen-agent): add instrumentation for Qwen-Agent#154sipercai wants to merge 3 commits intoalibaba:mainfrom
sipercai wants to merge 3 commits intoalibaba:mainfrom
Conversation
Change-Id: I5ab30c79fea5e6f2070ef182da505084092632b2 Co-developed-by: Cursor <noreply@cursor.com>
Change-Id: I6e70c5771f05d4915546bf6c2d4b96dc50582ce7 Co-developed-by: Cursor <noreply@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new LoongSuite OpenTelemetry instrumentation package for the Qwen-Agent framework, integrating ExtendedTelemetryHandler to emit GenAI semantic-convention spans for agent runs, LLM chat calls, ReAct steps, and tool execution, along with CI/tox wiring and test coverage (unit + VCR-based integration).
Changes:
- Introduces
loongsuite-instrumentation-qwen-agentwith wrappers aroundAgent.run,BaseChatModel.chat,Agent._call_llm, andAgent._call_tool. - Adds unit tests validating span creation/hierarchy and VCR-backed integration tests with recorded HTTP cassettes.
- Wires the new package into
tox-loongsuite.iniand GitHub Actions test/lint workflows.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tox-loongsuite.ini | Adds tox envs/deps/commands for qwen-agent tests + lint. |
| .github/workflows/loongsuite_test_0.yml | Adds CI test jobs for qwen-agent across py39–py313 (oldest/latest). |
| .github/workflows/loongsuite_lint_0.yml | Adds CI lint job for qwen-agent package. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/pyproject.toml | New package metadata, deps, and opentelemetry_instrumentor entry point. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/init.py | Instrumentor implementation wiring wrapt wrappers + uninstrumentation. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/patch.py | Core wrappers emitting spans for agent/LLM/tools/ReAct. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/utils.py | Message/tool/provider conversion helpers for GenAI types. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/tests/* | Unit tests, VCR integration tests, conftest, and VCR cassettes. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/README.md | Usage/config docs for the new instrumentation. |
| instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/CHANGELOG.md | Changelog entry for initial release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/patch.py
Show resolved
Hide resolved
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/patch.py
Show resolved
Hide resolved
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/utils.py
Outdated
Show resolved
Hide resolved
...te/loongsuite-instrumentation-qwen-agent/tests/cassettes/test_qwen_agent_with_tool_call.yaml
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/tests/test_real_api.py
Show resolved
Hide resolved
Cirilla-zmh
requested changes
Apr 1, 2026
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/README.md
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/pyproject.toml
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/pyproject.toml
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/pyproject.toml
Outdated
Show resolved
Hide resolved
instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent/CHANGELOG.md
Outdated
Show resolved
Hide resolved
...oongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/version.py
Outdated
Show resolved
Hide resolved
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/utils.py
Outdated
Show resolved
Hide resolved
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/utils.py
Show resolved
Hide resolved
.../loongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/utils.py
Show resolved
Hide resolved
...ongsuite-instrumentation-qwen-agent/src/opentelemetry/instrumentation/qwen_agent/__init__.py
Show resolved
Hide resolved
…or utility functions Change-Id: Ie0b1fc3e63c84fa082ca600d44451f308a679de5
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.
Description
This PR adds loongsuite-instrumentation-qwen-agent: OpenTelemetry instrumentation for Qwen-Agent using ExtendedTelemetryHandler from opentelemetry-util-genai. It emits GenAI semantic-convention traces for agent runs, LLM calls, ReAct steps, and tool execution (invoke_agent, chat, react step, execute_tool), registers an opentelemetry_instrumentor entry point, and includes unit tests plus VCR-based integration tests.
Fixes #11
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
pip install -e ".[test]" under instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent, then pytest on that package’s tests/
From repo root: tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-qwen-agent-oldest, py312-test-loongsuite-instrumentation-qwen-agent-latest, lint-loongsuite-instrumentation-qwen-agent
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.