Skip to content

Conversation

@sipercai
Copy link
Collaborator

@sipercai sipercai commented Dec 8, 2025

Description

This PR refactors the AgentScope instrumentation to use ExtendedTelemetryHandler from opentelemetry-util-genai instead of the previous custom implementation. This change provides better consistency with other GenAI instrumentations, improved span lifecycle management.

opentelemetry-util-genai: support for metrics

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Tests:

    • test_instrumentor.py: Tests for covering instrumentor initialization, instrumentation, and uninstrumentation
    • test_model.py: Tests for chat model and embedding model instrumentation
    • test_agent.py: Tests for agent instrumentation with tools
    • test_span_content.py: Tests for span content capture
  • Integration Tests: Verified with real AgentScope examples:

    • structured_output/main.py: Tests structured output with tool calls
    • stream_printing_messages/multi_agent.py: Tests multi-agent conversations
    • rag/agent_usage.py: Tests RAG functionality with embeddings

Test Configuration

# Install the updated package
pip install -e loongsuite-python-agent/instrumentation-loongsuite/loongsuite-instrumentation-agentscope

# Run unit tests
pytest tests/ -v

# Run integration test
opentelemetry-instrument --traces_exporter console --metrics_exporter console \
  python agentscope/examples/functionality/structured_output/main.py

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

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]>
Change-Id: Ib647add02a3828287eba027514ffc3961f672446
Co-developed-by: Cursor <[email protected]>
Change-Id: I5f7cf397133843f23cbf98e1af4eed24dc616dab
Co-developed-by: Cursor <[email protected]>
Change-Id: I82757e8cf43cc9210d9050be5925370593daf97a
Co-developed-by: Cursor <[email protected]>
Change-Id: I41b0f92aad53265e1fa1f65e0da55d8269a6ce9e
Co-developed-by: Cursor <[email protected]>
Change-Id: Idb02a70c0aa35eddf323518392544af46c23a1d2
Co-developed-by: Cursor <[email protected]>
Change-Id: I5fe34b20168badff7efccb0a6345c566c35f4f34
Co-developed-by: Cursor <[email protected]>
Change-Id: I811f5942da5b4c74b7c963a854d187351eb547e4
Co-developed-by: Cursor <[email protected]>
Change-Id: Id689c30a61620e97ec29ce9a6d4ae0ca75eb3a2a
Co-developed-by: Cursor <[email protected]>
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.

4 participants