Skip to content

Commit 8737f91

Browse files
feat: Refactor agentscope instrument using genai util to replace (#82)
* Squashed commit of the following: commit 6b8e48ebd909636ce4c2d8631b2b382fb5bb8e32 Author: 流屿 <[email protected]> Date: Thu Dec 4 20:44:50 2025 +0800 fix: span exporter error Change-Id: I0e7a55eece19a166236d931bf69e590ea3a76ed1 Co-developed-by: Cursor <[email protected]> commit c1f6e3cc23b1dab15d5e6582211ac679588ef871 Author: 流屿 <[email protected]> Date: Thu Dec 4 15:51:27 2025 +0800 chore: use new genai util Change-Id: I681e478ffc86cd774aac5476fddf6ec4f22c68b6 Co-developed-by: Cursor <[email protected]> commit cd2448c018efe4a2f5823e20d57862503b448692 Author: 流屿 <[email protected]> Date: Thu Dec 4 15:40:38 2025 +0800 refactor: update genai util Change-Id: I338a57c2a2311551bf293132b6dc54224823c3a1 Co-developed-by: Cursor <[email protected]> commit 3141f49745ab756a2bbc89781cb75dd223186ce5 Author: 流屿 <[email protected]> Date: Tue Dec 2 23:21:14 2025 +0800 refactor: agentscope use util genai Change-Id: Ia6dd446c2ff04a9bc62f705b8001d2a978ae983d Co-developed-by: Cursor <[email protected]> commit c6217390ff5a5f704a2ab87c660c9159de41638e Author: 流屿 <[email protected]> Date: Mon Nov 24 14:11:14 2025 +0800 Refactor agentscope instrumentation to standard structure and drop v0 support Change-Id: Ie267bd9304e8291895d2b4b80914698173598437 Co-developed-by: Cursor <[email protected]> Change-Id: I16dfafe9ae766d2a36bbee1b773598e143a2af21 Co-developed-by: Cursor <[email protected]> * fix(agentscope): add missing trace span attributes Change-Id: Ib647add02a3828287eba027514ffc3961f672446 Co-developed-by: Cursor <[email protected]> * chore: add __future__.annotations for forward type hints Change-Id: I5f7cf397133843f23cbf98e1af4eed24dc616dab Co-developed-by: Cursor <[email protected]> * fix: tool context error Change-Id: I82757e8cf43cc9210d9050be5925370593daf97a Co-developed-by: Cursor <[email protected]> * feat: add extended metrics Change-Id: I41b0f92aad53265e1fa1f65e0da55d8269a6ce9e Co-developed-by: Cursor <[email protected]> * feat: add extended metrics Change-Id: Idb02a70c0aa35eddf323518392544af46c23a1d2 Co-developed-by: Cursor <[email protected]> * fix: test error fix Change-Id: I5fe34b20168badff7efccb0a6345c566c35f4f34 Co-developed-by: Cursor <[email protected]> * fix: fix test failed Change-Id: I811f5942da5b4c74b7c963a854d187351eb547e4 Co-developed-by: Cursor <[email protected]> * refactor: simplify structure and remove unused code Change-Id: Id689c30a61620e97ec29ce9a6d4ae0ca75eb3a2a Co-developed-by: Cursor <[email protected]> * feat: add spankind Change-Id: Ia9d28b59748a3f367c35529c5d9ac311eec32954 Co-developed-by: Cursor <[email protected]> * using handler Change-Id: I3a46ccb35472c2212f475b2ccefc0df51fa51c2a Co-developed-by: Cursor <[email protected]> * fix(agentscope): tool using handler function Change-Id: Ie4f1c804a22639e6621fc2229d6813bd1d5f8026 Co-developed-by: Cursor <[email protected]> * remove pytest.ini add metrics test Change-Id: I760e6ba769fe398121bc45bbebdd128fec149f48 Co-developed-by: Cursor <[email protected]> * Fix agentscope unit tests Change-Id: Id9394f34545f935b053f3aee0348dfe5b82427cd Co-developed-by: Cursor <[email protected]> * Fix lint error Change-Id: I49d21f443393e464b76067847b661a12bdf10f6b Co-developed-by: Cursor <[email protected]> * Fix tests Change-Id: I0b50eab9480ee7576112fafe7b24c35a17caf871 Co-developed-by: Cursor <[email protected]> * Add TODO comments Change-Id: I50444daa100eef7b42749f72ef692066ad5f926b Co-developed-by: Cursor <[email protected]> --------- Co-authored-by: cirilla-zmh <[email protected]>
1 parent ab1d7de commit 8737f91

File tree

81 files changed

+8988
-3422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8988
-3422
lines changed

.github/workflows/loongsuite_lint_0.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,25 @@ env:
3232

3333
jobs:
3434

35+
lint-loongsuite-instrumentation-agentscope:
36+
name: LoongSuite loongsuite-instrumentation-agentscope
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 30
39+
steps:
40+
- name: Checkout repo @ SHA - ${{ github.sha }}
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Python 3.13
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.13"
47+
48+
- name: Install tox
49+
run: pip install tox-uv
50+
51+
- name: Run tests
52+
run: tox -c tox-loongsuite.ini -e lint-loongsuite-instrumentation-agentscope
53+
3554
lint-loongsuite-instrumentation-dashscope:
3655
name: LoongSuite loongsuite-instrumentation-dashscope
3756
runs-on: ubuntu-latest

.github/workflows/loongsuite_test_0.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,158 @@ env:
3232

3333
jobs:
3434

35+
py310-test-loongsuite-instrumentation-agentscope-oldest_ubuntu-latest:
36+
name: LoongSuite loongsuite-instrumentation-agentscope-oldest 3.10 Ubuntu
37+
runs-on: ubuntu-latest
38+
timeout-minutes: 30
39+
steps:
40+
- name: Checkout repo @ SHA - ${{ github.sha }}
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Python 3.10
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: "3.10"
47+
48+
- name: Install tox
49+
run: pip install tox-uv
50+
51+
- name: Run tests
52+
run: tox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agentscope-oldest -- -ra
53+
54+
py310-test-loongsuite-instrumentation-agentscope-latest_ubuntu-latest:
55+
name: LoongSuite loongsuite-instrumentation-agentscope-latest 3.10 Ubuntu
56+
runs-on: ubuntu-latest
57+
timeout-minutes: 30
58+
steps:
59+
- name: Checkout repo @ SHA - ${{ github.sha }}
60+
uses: actions/checkout@v4
61+
62+
- name: Set up Python 3.10
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: "3.10"
66+
67+
- name: Install tox
68+
run: pip install tox-uv
69+
70+
- name: Run tests
71+
run: tox -c tox-loongsuite.ini -e py310-test-loongsuite-instrumentation-agentscope-latest -- -ra
72+
73+
py311-test-loongsuite-instrumentation-agentscope-oldest_ubuntu-latest:
74+
name: LoongSuite loongsuite-instrumentation-agentscope-oldest 3.11 Ubuntu
75+
runs-on: ubuntu-latest
76+
timeout-minutes: 30
77+
steps:
78+
- name: Checkout repo @ SHA - ${{ github.sha }}
79+
uses: actions/checkout@v4
80+
81+
- name: Set up Python 3.11
82+
uses: actions/setup-python@v5
83+
with:
84+
python-version: "3.11"
85+
86+
- name: Install tox
87+
run: pip install tox-uv
88+
89+
- name: Run tests
90+
run: tox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-agentscope-oldest -- -ra
91+
92+
py311-test-loongsuite-instrumentation-agentscope-latest_ubuntu-latest:
93+
name: LoongSuite loongsuite-instrumentation-agentscope-latest 3.11 Ubuntu
94+
runs-on: ubuntu-latest
95+
timeout-minutes: 30
96+
steps:
97+
- name: Checkout repo @ SHA - ${{ github.sha }}
98+
uses: actions/checkout@v4
99+
100+
- name: Set up Python 3.11
101+
uses: actions/setup-python@v5
102+
with:
103+
python-version: "3.11"
104+
105+
- name: Install tox
106+
run: pip install tox-uv
107+
108+
- name: Run tests
109+
run: tox -c tox-loongsuite.ini -e py311-test-loongsuite-instrumentation-agentscope-latest -- -ra
110+
111+
py312-test-loongsuite-instrumentation-agentscope-oldest_ubuntu-latest:
112+
name: LoongSuite loongsuite-instrumentation-agentscope-oldest 3.12 Ubuntu
113+
runs-on: ubuntu-latest
114+
timeout-minutes: 30
115+
steps:
116+
- name: Checkout repo @ SHA - ${{ github.sha }}
117+
uses: actions/checkout@v4
118+
119+
- name: Set up Python 3.12
120+
uses: actions/setup-python@v5
121+
with:
122+
python-version: "3.12"
123+
124+
- name: Install tox
125+
run: pip install tox-uv
126+
127+
- name: Run tests
128+
run: tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-agentscope-oldest -- -ra
129+
130+
py312-test-loongsuite-instrumentation-agentscope-latest_ubuntu-latest:
131+
name: LoongSuite loongsuite-instrumentation-agentscope-latest 3.12 Ubuntu
132+
runs-on: ubuntu-latest
133+
timeout-minutes: 30
134+
steps:
135+
- name: Checkout repo @ SHA - ${{ github.sha }}
136+
uses: actions/checkout@v4
137+
138+
- name: Set up Python 3.12
139+
uses: actions/setup-python@v5
140+
with:
141+
python-version: "3.12"
142+
143+
- name: Install tox
144+
run: pip install tox-uv
145+
146+
- name: Run tests
147+
run: tox -c tox-loongsuite.ini -e py312-test-loongsuite-instrumentation-agentscope-latest -- -ra
148+
149+
py313-test-loongsuite-instrumentation-agentscope-oldest_ubuntu-latest:
150+
name: LoongSuite loongsuite-instrumentation-agentscope-oldest 3.13 Ubuntu
151+
runs-on: ubuntu-latest
152+
timeout-minutes: 30
153+
steps:
154+
- name: Checkout repo @ SHA - ${{ github.sha }}
155+
uses: actions/checkout@v4
156+
157+
- name: Set up Python 3.13
158+
uses: actions/setup-python@v5
159+
with:
160+
python-version: "3.13"
161+
162+
- name: Install tox
163+
run: pip install tox-uv
164+
165+
- name: Run tests
166+
run: tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-agentscope-oldest -- -ra
167+
168+
py313-test-loongsuite-instrumentation-agentscope-latest_ubuntu-latest:
169+
name: LoongSuite loongsuite-instrumentation-agentscope-latest 3.13 Ubuntu
170+
runs-on: ubuntu-latest
171+
timeout-minutes: 30
172+
steps:
173+
- name: Checkout repo @ SHA - ${{ github.sha }}
174+
uses: actions/checkout@v4
175+
176+
- name: Set up Python 3.13
177+
uses: actions/setup-python@v5
178+
with:
179+
python-version: "3.13"
180+
181+
- name: Install tox
182+
run: pip install tox-uv
183+
184+
- name: Run tests
185+
run: tox -c tox-loongsuite.ini -e py313-test-loongsuite-instrumentation-agentscope-latest -- -ra
186+
35187
py39-test-loongsuite-instrumentation-dashscope-oldest_ubuntu-latest:
36188
name: LoongSuite loongsuite-instrumentation-dashscope-oldest 3.9 Ubuntu
37189
runs-on: ubuntu-latest
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased
9+
10+
### Breaking Changes
11+
- **Minimum AgentScope version requirement**: Only supports AgentScope 1.0.0 and above. Previous 0.x versions are not supported.
12+
13+
### Changed
14+
- **Refactored to use opentelemetry-util-genai**: Migrated to `ExtendedTelemetryHandler` and `ExtendedInvocationMetricsRecorder` from `opentelemetry-util-genai` for unified metrics and tracing management
15+
- **Architecture Simplification**: Removed redundant code and consolidated instrumentation logic
16+
- **Tool Tracing Enhancement**: Rewritten tool execution tracing to use `ExtendedTelemetryHandler` for full feature support (see HANDLER_INTEGRATION.md)
17+
- Now properly leverages `_apply_execute_tool_finish_attributes` for standardized attribute handling
18+
- Automatic metrics recording for tool executions
19+
- Content capturing mode support (respects experimental mode and content capturing settings)
20+
- Unified error handling with proper error attributes
21+
- Removed "V1" prefix from class names (AgentScopeV1ChatModelWrapper → AgentScopeChatModelWrapper, etc.)
22+
- Updated to use Apache License 2.0 headers across all source files
23+
24+
### Added
25+
- **Metrics Support**: Comprehensive metrics following OpenTelemetry GenAI Semantic Conventions via `ExtendedInvocationMetricsRecorder`
26+
- `gen_ai.client.operation.duration`: Counter for operation duration
27+
- `gen_ai.client.token.usage`: Counter for token usage
28+
- Metrics include attributes: operation_name, provider_name, request_model, response_model, token_type, error_type
29+
- RPC attribute support for spans (function name as RPC identifier)
30+
- **Handler Integration for Async Generators**: New pattern for using handler capabilities with async generators
31+
- Enables handler feature reuse in async generator scenarios (tool execution)
32+
33+
## Version 1.0.0 (2025-11-24)
34+
35+
### Added
36+
- Initial release supporting AgentScope 1.0.0+
37+
- Comprehensive tracing for agents, models, tools, and formatters
38+
- Support for chat models and embedding models
39+
- Tool execution tracing
40+
- Message formatting tracing
41+
42+
### Note
43+
- Only supports AgentScope 1.0.0 and above
44+
- Previous 0.x versions are not supported
45+

0 commit comments

Comments
 (0)