Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

pypi

This library allows tracing agent runs and tool executions made through the Qwen-Agent framework.

It produces spans following the GenAI semantic conventions:

  • invoke_agent for Agent.run()

  • execute_tool for Agent._call_tool()

LLM call (chat) spans are intentionally not emitted by this instrumentation: the model client libraries qwen-agent calls into have their own instrumentations, and emitting them here as well would duplicate the LLM spans. Enable the instrumentation of the underlying model client library (e.g. opentelemetry-instrumentation-genai-openai for OpenAI-compatible backends) alongside this package to capture LLM calls.

Installation

pip install opentelemetry-instrumentation-genai-qwen-agent

Usage

from opentelemetry.instrumentation.genai.qwen_agent import (
    QwenAgentInstrumentor,
)
from qwen_agent.agents import Assistant

QwenAgentInstrumentor().instrument()

bot = Assistant(
    llm={"model": "qwen-max", "model_type": "qwen_dashscope"},
    name="my-assistant",
)
for responses in bot.run([{"role": "user", "content": "Hello!"}]):
    pass

Message content capture is disabled by default. Set OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT to one of NO_CONTENT, SPAN_ONLY, EVENT_ONLY, or SPAN_AND_EVENT to record prompts, completions, and tool arguments/results.

Uploading prompts and completions

Instead of recording message content inline, prompts and completions can be uploaded to external storage via a completion hook. To enable the built-in upload hook, set:

  • OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK=upload

  • OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH to an fsspec-compatible URI/path (e.g. /path/to/prompts or gs://my_bucket), and install the upload extra (pip install opentelemetry-util-genai[upload]).

A custom CompletionHook can also be passed programmatically, taking precedence over the environment variable:

QwenAgentInstrumentor().instrument(completion_hook=my_hook)

References

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz
Algorithm Hash digest
SHA256 6cbc5b6a5c68c4d2f1153c80b54652c6dea4a016dd703dcda875805717b81d3b
MD5 7108a7f6fe260a0c4cb6e58ed5f1511b
BLAKE2b-256 e9cf97a9c7f13f969b1c5112aae3e481999893ae4dbfa33d3d63790cd73c2561

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz:

Publisher: release-all.yml on open-telemetry/opentelemetry-python-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c9f380c0c83a1b752d8f863b9db9519b20e2983fa7ef2e7f2f8c0ca01e5c414
MD5 5f5428bd4d19cb26995d2ae1253f2e81
BLAKE2b-256 ee18370661be4d4fee6d2535bfc755e5071494161e71d2d18f70c2d26266a3b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl:

Publisher: release-all.yml on open-telemetry/opentelemetry-python-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page