Skip to main content

OpenTelemetry Qwen-Agent Instrumentation

OpenTelemetry instrumentation for the Qwen-Agent framework.

Installation

pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install

pip install "qwen-agent >= 0.0.20"

pip install ./util/opentelemetry-util-genai

# Install this instrumentation (from the LoongSuite repo)
pip install ./instrumentation-loongsuite/loongsuite-instrumentation-qwen-agent

Published package name:

pip install loongsuite-instrumentation-qwen-agent

Usage

Auto-instrumentation

With loongsuite-instrumentation-qwen-agent installed, the opentelemetry_instrumentor entry point qwen_agent is registered for use with the OpenTelemetry distro.

opentelemetry-instrument \
    --traces_exporter console \
    python your_qwen_agent_app.py

Manual instrumentation

from opentelemetry.instrumentation.qwen_agent import QwenAgentInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor
from qwen_agent.agents import Assistant

provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))

QwenAgentInstrumentor().instrument(tracer_provider=provider)

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

QwenAgentInstrumentor().uninstrument()

Configuration

Export to an OTLP backend

export OTEL_SERVICE_NAME=my-qwen-agent-app
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=<trace_endpoint>
# Optional: metrics / logs if you configure exporters globally
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=<metrics_endpoint>

opentelemetry-instrument python your_app.py

GenAI semantic conventions and content capture

# Enable experimental GenAI semantic conventions (recommended for this instrumentation)
export OTEL_SEMCONV_STABILITY_OPT_IN=gen_ai_latest_experimental

# Message content capture (same env vars as other GenAI instrumentations in this repo)
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY
# EVENT_ONLY | SPAN_AND_EVENT | NO_CONTENT

Supported components

Area Instrumented API Span / operation
Agent Agent.run invoke_agent
LLM BaseChatModel.chat chat
ReAct Agent._call_llm react step (agents with tools)
Tools Agent._call_tool execute_tool

Agent.run_nonstream() is not wrapped separately; it calls run() internally, so you still get a single invoke_agent span per run.

Model backends (inferred from model_type / class name): DashScope, OpenAI-compatible APIs, Azure OpenAI, and other Qwen-Agent–supported backends.

Visualization

Export telemetry to:

License

Apache License 2.0

Metadata

Release files for loongsuite-instrumentation-qwen-agent 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for loongsuite-instrumentation-qwen-agent 0.9.0
File Interpreter ABI Platform Actions
loongsuite_instrumentation_qwen_agent-0.9.0-py3-none-any.whl Python 3 none any Details for loongsuite_instrumentation_qwen_agent-0.9.0-py3-none-any.whl

Release files / loongsuite_instrumentation_qwen_agent-0.9.0-py3-none-any.whl

Download URL loongsuite_instrumentation_qwen_agent-0.9.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46554a23125df7fb6e2d0953cc4573c326a3ce3fe32c87cc2c87aca49a84eafc
BLAKE2b-256 checksum
How to use checksums
1a6f5b3a29149f8c4c9891bfc204c236b1585fdff36f1f2f33622400f7df73dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for loongsuite-instrumentation-qwen-agent 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page