Skip to content

Add QwenPaw instrumentation - #311

Open
123liuziming wants to merge 7 commits into
open-telemetry:mainfrom
123liuziming:add-qwenpaw-instrumentation
Open

Add QwenPaw instrumentation#311
123liuziming wants to merge 7 commits into
open-telemetry:mainfrom
123liuziming:add-qwenpaw-instrumentation

Conversation

@123liuziming

Copy link
Copy Markdown
Contributor

Description

Adds opentelemetry-instrumentation-genai-qwenpaw, instrumentation for QwenPaw, a personal assistant application built on AgentScope. Each user turn handled by AgentRunner.query_handler is traced as one invoke_agent span (gen_ai.agent.id, gen_ai.agent.name, gen_ai.conversation.id, and opt-in input/output message content), plus the gen_ai.client.operation.duration metric, all through opentelemetry-util-genai.

QwenPaw delegates model (LLM) and tool execution to AgentScope, so this package intentionally emits no chat or execute_tool spans and the conformance suite covers none — those operations belong to the AgentScope instrumentation.

Supported range is qwenpaw >= 1.1.0, < 2.0.0 (2.0 removed AgentRunner.query_handler).

Type of change

  • New feature (non-breaking change which adds functionality)

How has this been tested?

  • tox -e py310-test-instrumentation-genai-qwenpaw-oldest (qwenpaw 1.1.0 via lowest-direct)
  • tox -e py312-test-instrumentation-genai-qwenpaw-latest (qwenpaw 1.1.12.post3)
  • tox -e py313-test-instrumentation-genai-qwenpaw-conformance (weaver live-check, 0 violations)
  • tox -e lint-instrumentation-genai-qwenpaw, precommit, typecheck, readme

Checklist

See CONTRIBUTING.md
for the style guide, changelog guidance, and more.

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

Made with Cursor

Traces each AgentRunner.query_handler turn as an invoke_agent span per the
GenAI semantic conventions, with unit and Weaver conformance tests. Model
and tool execution are delegated to AgentScope, so this package emits no
chat or execute_tool spans.

Change-Id: I11606f53aab9d7f90acd8c712a17337bbf3b67a4
Co-developed-by: Cursor <noreply@cursor.com>
Assisted-by: Claude Fable 5
@123liuziming
123liuziming requested a review from a team as a code owner July 26, 2026 14:23
Copilot AI review requested due to automatic review settings July 26, 2026 14:23
Change-Id: I387b13c54797040a9b37fdf4af1f39b5dd4a5391
Co-developed-by: Cursor <noreply@cursor.com>
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 26, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-08-06 01:35 UTC

Respond to 3 review items (e.g. link a commit, explain why not, ask a follow-up):

  • Inline threads: 1, 2
  • Top-level threads: 3
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new GenAI instrumentation package, opentelemetry-instrumentation-genai-qwenpaw, to trace QwenPaw AgentRunner.query_handler turns as invoke_agent operations using opentelemetry-util-genai, and wires the package into the monorepo’s test/release automation.

Changes:

  • Introduces the new QwenPaw instrumentor implementation (async-generator wrapping + message mapping helpers).
  • Adds unit tests and a conformance scenario for the single emitted semconv operation (invoke_agent), plus tox env wiring.
  • Registers the new package in workspace deps, release workflows, and per-package tooling configs.

Reviewed changes

Copilot reviewed 29 out of 32 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tox.ini Adds tox envs/deps/commands for qwenpaw oldest/latest/conformance + lint; adjusts typecheck install.
pyproject.toml Adds qwenpaw workspace dependency and pyright include/exclude entries.
instrumentation/README.md Lists the new qwenpaw instrumentation in the workspace table.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/test_query_handler.py End-to-end async tests for query_handler span/metric behavior and error cases.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/test_message_mapping.py Unit tests for call parsing + message mapping utilities.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/test_instrumentor.py Tests instrumentation dependency metadata and uninstrument behavior.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/test_conformance.py Runs the per-scenario conformance runner for qwenpaw.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/requirements.oldest.txt Defines oldest-factor test-only dependency pins (currently none).
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/requirements.latest.txt Pins latest qwenpaw and installs editable util/instrumentation for tests.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/harness.py Test harness to drive query_handler without real model/tool execution.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/conftest.py Registers shared fixtures and defines package-local test fixtures.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/conformance/invoke_agent.py Conformance scenario for one invoke_agent turn.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/conformance/init.py Marks conformance package.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/tests/init.py Marks tests package.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/src/opentelemetry/instrumentation/genai/qwenpaw/version.py Adds package version module.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/src/opentelemetry/instrumentation/genai/qwenpaw/utils.py Adds helpers for parsing/mapping input/output messages.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/src/opentelemetry/instrumentation/genai/qwenpaw/patch.py Implements async stream wrapper + wrapt wrapper for query_handler.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/src/opentelemetry/instrumentation/genai/qwenpaw/package.py Declares instruments metadata for the instrumentor.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/src/opentelemetry/instrumentation/genai/qwenpaw/init.py Adds QwenPawInstrumentor implementation + package docstring.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/README.rst Adds package README for PyPI long description.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/pyproject.toml Adds package build metadata, deps, and instrumentor entry point.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/LICENSE Adds Apache 2.0 license file for the new package.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/.changelog/311.added Adds towncrier fragment for the new instrumentation.
instrumentation/opentelemetry-instrumentation-genai-qwenpaw/.changelog/.gitignore Ensures the changelog directory is retained in git.
eachdist.ini Adds qwenpaw to per-dist tooling configuration.
dev-requirements-conformance.txt Adds OTLP meta/proto-http pins needed by some conformance dependencies.
.github/workflows/release-package.yml Adds qwenpaw to the release workflow package choice list.
.github/workflows/prepare-release.yml Adds qwenpaw to the prepare-release workflow package choice list.
.github/workflows/prepare-backport-patch.yml Adds qwenpaw to the backport patch workflow package choice list.
.github/workflows/bump-package-minor.yml Adds qwenpaw to the bump-minor workflow package choice list.
.github/workflows/bump-package-major.yml Adds qwenpaw to the bump-major workflow package choice list.

Comment thread instrumentation/opentelemetry-instrumentation-genai-qwenpaw/pyproject.toml Outdated
Change-Id: I46107eb41fbacc8c5d6e846e8a9f6cd96dbb8cd9
Co-developed-by: Cursor <noreply@cursor.com>
@123liuziming 123liuziming changed the title Add QwenPaw instrumentation 【WIP】Add QwenPaw instrumentation Jul 26, 2026
- Wire the GenAI completion hook through instrument(), matching the other
  instrumentations, and document it.
- Fix the documented content-capture values: the util expects a
  ContentCapturingMode name, not "true".
- Close the wrapped async generator when the caller raises inside
  "async with", which previously leaked a suspended generator.
- Mark the instruments extra with the Python range qwenpaw supports so it
  stays installable on 3.14 tooling interpreters.
- Ignore "astroid" in codespell; it is a locked transitive dependency name.

Change-Id: I06dc0f24f110bf8a28a9a7693cfd8efc39a0888d
Co-developed-by: Cursor <noreply@cursor.com>
Assisted-by: Claude Opus 4.6
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @123liuziming — just a friendly reminder that this pull request is waiting on you.

There are still items that need your attention. See the dashboard status comment for the full list. You don't need to push a code change to hand it back — replying to move each discussion forward is enough, whether that's answering a question, explaining why no change is needed, or asking a follow-up. The dashboard then automatically routes it back to reviewers.

If you believe this pull request is incorrectly routed as waiting on the author, comment /dashboard route:reviewers to route it from waiting on the author to waiting on reviewers.

- Ship the standard examples/manual (with custom_hook.py) and
  examples/zero-code layouts and link them from the README.
- Drop the feature-specific validate() override from the conformance
  scenario; conformance validates the telemetry shape and the specific
  attribute values are already covered by unit tests.
- Start the new package at 1.0b0.dev like the other unreleased packages.

Change-Id: Ifc74679047aec04f06fe3dad8be85bece499c5cf
Co-developed-by: Qoder <noreply@qoder.com>
Assisted-by: Claude Opus 4.6
…tation

Change-Id: I867f7aa66287d1ebd69211f64309e68e5fb8c3b3
Co-developed-by: Qoder <noreply@qoder.com>
After merging main, util-genai records time_to_first_chunk for streamed
invocations; declare it in the scenario along with the known
gen_ai.provider.name gap (QwenPaw delegates model calls to AgentScope,
so no provider applies to invoke_agent).

Change-Id: I9a74da28a3cef297c62efec511515a00c6e4f3bc
Co-developed-by: Qoder <noreply@qoder.com>
Assisted-by: Claude Opus 4.6
@123liuziming 123liuziming changed the title 【WIP】Add QwenPaw instrumentation Add QwenPaw instrumentation Aug 4, 2026

@eternalcuriouslearner eternalcuriouslearner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! Minor nit and can you please resolve the merge conflicts?

class QwenPawInstrumentor(BaseInstrumentor):
"""An instrumentor for the QwenPaw application runner.

Traces ``AgentRunner.query_handler`` as an ``invoke_agent`` span and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: appreciate the doc comments. They’re really helpful in understanding context.


def query_handler_wrapper(
wrapped: Callable[..., AsyncGenerator[Any, None]],
instance: Any,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question(non-blocking): can we avoid Any here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants