This release is a pre-release and may not be stable for production use.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cbc5b6a5c68c4d2f1153c80b54652c6dea4a016dd703dcda875805717b81d3b
|
|
| MD5 |
7108a7f6fe260a0c4cb6e58ed5f1511b
|
|
| BLAKE2b-256 |
e9cf97a9c7f13f969b1c5112aae3e481999893ae4dbfa33d3d63790cd73c2561
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_genai_qwen_agent-1.1b0.tar.gz -
Subject digest:
6cbc5b6a5c68c4d2f1153c80b54652c6dea4a016dd703dcda875805717b81d3b - Sigstore transparency entry: 2535566218
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@8476682703b0b72f107bc3b58998a77dacc0d1d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-all.yml@8476682703b0b72f107bc3b58998a77dacc0d1d3 -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c9f380c0c83a1b752d8f863b9db9519b20e2983fa7ef2e7f2f8c0ca01e5c414
|
|
| MD5 |
5f5428bd4d19cb26995d2ae1253f2e81
|
|
| BLAKE2b-256 |
ee18370661be4d4fee6d2535bfc755e5071494161e71d2d18f70c2d26266a3b0
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_genai_qwen_agent-1.1b0-py3-none-any.whl -
Subject digest:
2c9f380c0c83a1b752d8f863b9db9519b20e2983fa7ef2e7f2f8c0ca01e5c414 - Sigstore transparency entry: 2535566660
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@8476682703b0b72f107bc3b58998a77dacc0d1d3 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-all.yml@8476682703b0b72f107bc3b58998a77dacc0d1d3 -
Trigger Event:
pull_request
-
Statement type: