feat: support multiple benchmark framework! (#200)
Co-authored-by: musi admin@arms-test-agent033059173062.os30 Co-authored-by: root root@arms-test-agent033059173062.os30 Co-authored-by: Claude Opus 4.7 noreply@anthropic.com Co-authored-by: 流屿 caishipeng.csp@alibaba-inc.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802047560号
loongsuite-python-agent
English | 简体中文
Introduction
Loongsuite Python Agent is a key component of LoongSuite, Alibaba’s unified observability data collection suite, providing instrumentation for Python applications.
LoongSuite includes the following key components:
Loongsuite Python Agent is also a customized distribution of upstream OTel Python Agent, with enhanced support for popular AI agent framework. The implementation follows the latest GenAI semantic conventions.
Supported frameworks and components
LoongSuite instrumentation
Source tree:
instrumentation-loongsuite/.Distro and helpers:
loongsuite-instrument,loongsuite-bootstrap)OpenTelemetry instrumentation — generative workloads
Source tree:
instrumentation-genai/. These distributions follow OpenTelemetry generative semantic conventions (opentelemetry-instrumentation-*on PyPI).OpenTelemetry instrumentation
Source tree:
instrumentation/. General application and library instrumentations; PyPI project is alwayshttps://pypi.org/project/opentelemetry-instrumentation-<name>/. Each line below links to that URL and the package README in this repo.All
instrumentation/packages (click to expand)Quick start
This walkthrough uses AgentScope. The same exporter and
loongsuite-instrumentpatterns apply to other stacks once their instrumentations are installed.Prepare a demo (AgentScope ReAct example)
Use the upstream ReAct agent example as reference: you can clone AgentScope or align with that folder’s
main.py.Step 1 — Install AgentScope
Step 2 - Configure DashScope
Replace
{your_api_key}with a valid key from the DashScope console.To connect to a different model API instead of DashScope, see the AgentScope documentation: Model tutorial.
Step 3 - Create ReAct Agent
Install and run loongsuite
Recommended integration approach: automatic instrumentation with
loongsuite-instrumentafter installingloongsuite-distroand your instrumentations (vialoongsuite-bootstrapor manualpip).Step 1 — Install the distro
Optional:
pip install loongsuite-distro[otlp]for OTLP extras (loongsuite-distro README).Step 2 — Install instrumentations
Use
loongsuite-bootstrap(shipped withloongsuite-distro) to install LoongSuite wheels from a GitHub Release tarball and compatibleopentelemetry-instrumentation-*versions from PyPI. Bootstrap performs a two-phase install: LoongSuite artifacts from the release, then pinned OpenTelemetry instrumentation packages (see docs/loongsuite-release.md).Pick one of the following:
Option A — Install everything from a release:
Option B — Auto-detect (lean environments): install only instrumentations for libraries already present:
Option C — Manual
pip: install packages yourself from PyPI using the names in Supported frameworks and components.Step 3 — Run under
loongsuite-instrumentConfigure where telemetry is exported (see Configure telemetry export below) using environment variables and/or
loongsuite-instrumentflags, then start your app:For programmatic instrumentation, install from source, or site-bootstrap (
loongsuite-site-bootstrap), see Alternative installation methods.Configure telemetry export
Local debugging — console
Use the SDK’s console exporters so traces/metrics/logs print to the terminal, for example via
loongsuite-instrument:Under the hood this aligns with
ConsoleSpanExporter,ConsoleMetricExporter, andConsoleLogRecordExporter.Remote / production — OTLP
Before starting your application, install
opentelemetry-exporter-otlp:Point OpenTelemetry at a backend that accepts OTLP (gRPC or HTTP/protobuf), using
OtlpSpanExporter,OtlpMetricExporter,OtlpLogExporter(or the equivalent env vars /loongsuite-instrumentflags), for example:See also OpenTelemetry environment variables for
OTEL_EXPORTER_OTLP_*.Alternative installation methods
If you are not using the recommended
loongsuite-instrumentintegration approach, use one of the options below.Programmatic instrumentation
For applications where you can edit code and want explicit control over OpenTelemetry initialization.
Step 1 — Install instrumentations yourself from PyPI using the names in Supported frameworks and components.
Step 2 — Initialize the OpenTelemetry SDK before anything emits telemetry. You are wiring the same exporters as in Configure telemetry export.
Step 3 — Call the framework instrumentor, then start your app without
loongsuite-instrument.Install from source (for development)
Step 1 — Clone this repository and checkout your branch.
Step 2 — Install upstream OpenTelemetry Python core and local LoongSuite components from a Git checkout of opentelemetry-python:
Step 3 — Install the instrumentations you need, for example:
Step 4 — Run under
loongsuite-instrumentConfigure where telemetry is exported (see Configure telemetry export below) using environment variables and/or
loongsuite-instrumentflags, then start your app:Site-bootstrap (Beta)
Run without changing codes or bootstrap commands: a
.pthhook loads LoongSuite’s distro early (see loongsuite-site-bootstrap/README.md).Step 1 - Install LoongSuite Site Bootstrap
Step 2 — Install instrumentations
If you want a different installation approach, see Step 2 — Install instrumentations in Install and run loongsuite.
Step 3 — Enable the hook:
Step 4 — Create
~/.loongsuite/bootstrap-config.jsonwith the OpenTelemetry environments keys you need.Then run
python demo.py. For console exporters, other backends, usingloongsuite-instrumentinstead of plainpython, or full precedence / edge cases, see loongsuite-site-bootstrap/README.md.Optional: OTLP examples
AgentScope Studio
AgentScope Studio provides a web UI for traces and metrics.
Use the OTLP endpoint Studio prints (often
http://127.0.0.1:31415), for example:Or set
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT/OTEL_EXPORTER_OTLP_METRICS_ENDPOINTaccordingly. Details: AgentScope Studio.Forward OTLP to Jaeger via LoongCollector
Launch Jaeger
Launch LoongCollector
conf/continuous_pipeline_config/local/oltp.yaml:Run the demo against LoongCollector → Jaeger
Open the Jaeger UI and confirm traces arrive.
Community
We are looking forward to your feedback and suggestions. You can join our DingTalk group or scan the QR code below to engage with us.
Resources