Component ยท Shared or other
libs/amp-instrumentation
What it is
amp-instrumentation is a pip package that adds OpenTelemetry tracing to a Python agent without changing its code. It is built on the Traceloop SDK and sends traces to Agent Manager. You start the agent through the amp-instrument command, or call init_otel() for a one-line exporter setup when you want to emit your own spans.
It is a dashcam you strap on from outside. The car (your agent) is not modified, but everything it does is recorded and sent to base.
Why it exists
To see what an agent did, the platform needs its traces. A package that wires up tracing from the outside means agent authors do not have to write instrumentation themselves.
How it works
- Register the agent in Agent Manager to get an API key, then set AMP_OTEL_ENDPOINT and AMP_AGENT_API_KEY.
- Run the agent as amp-instrument python my_script.py (or with uvicorn, poetry run, and so on). The wrapper starts the Traceloop SDK before your code.
- Traces are exported to AMP_OTEL_ENDPOINT with the key in the x-amp-api-key header.
- A span processor copies the conversation id onto each trace's root span as gen_ai.conversation.id, so traces can be filtered by conversation.
- Each release of the package pins one Traceloop SDK version. For agents deployed by the platform, the init container python-instrumentation-provider delivers a pinned Traceloop-based instrumentation set into the pod instead of the pip package.
Identity and access
The agent proves itself with its agent API key, sent in the x-amp-api-key header of every export.
Key facts
- Package
- amp-instrumentation (PyPI)
- Command
- amp-instrument <command>
- Required settings
- AMP_OTEL_ENDPOINT, AMP_AGENT_API_KEY
- Auth header
- x-amp-api-key
- Python
- 3.10 or newer
Talks to (1)
- depends on Agent workload (internal) Alternative instrumentationpip import