This release is a pre-release and may not be stable for production use.
OpenTelemetry OpenAI Agents Instrumentation
This library traces applications built with the OpenAI Agents SDK. It registers a tracing processor with the Agents runtime and turns its trace/span callbacks into spans that mirror the structure of your agent run:
Workflow spans for an agent run — one per Runner.run / run_sync invocation, named after the run’s RunConfig.workflow_name.
Agent spans for each agent invoked within the workflow, including the agent name.
Tool spans for function tool calls, capturing the tool arguments and result.
The spans nest to reflect the run, so a single Runner.run produces a workflow span with the agent and tool calls it triggered as children.
LLM-level spans (chat / embeddings) are not emitted by this package. They are produced by opentelemetry-instrumentation-genai-openai when it is installed and instrumented alongside this package.
Installation
pip install opentelemetry-instrumentation-genai-openai-agents
Install opentelemetry-instrumentation-genai-openai as well to also capture the underlying LLM calls.
See the examples directory for runnable manual and zero-code scenarios.
Usage
Call OpenAIAgentsInstrumentor().instrument() once during startup, then run your agent as usual. The Runner.run_sync(...) call below is recorded as a workflow span with the agent and tool spans nested underneath.
from agents import Agent, Runner, function_tool
from opentelemetry.instrumentation.genai.openai_agents import (
OpenAIAgentsInstrumentor,
)
OpenAIAgentsInstrumentor().instrument()
@function_tool
def get_weather(city: str) -> str:
return f"The forecast for {city} is sunny with pleasant temperatures."
assistant = Agent(
name="Travel Concierge",
instructions="You are a concise travel concierge.",
model="<your-model>",
tools=[get_weather],
)
result = Runner.run_sync(
assistant, "I'm visiting Barcelona this weekend. How should I pack?"
)
print(result.final_output)
Configuration
By default the instrumentor keeps the Agents SDK’s built-in trace exporter (which uploads traces to OpenAI’s hosted tracing backend when OPENAI_API_KEY is set) active alongside OpenTelemetry emission. Pass disable_openai_trace_export=True to route traces only through OpenTelemetry:
OpenAIAgentsInstrumentor().instrument(disable_openai_trace_export=True)
The workflow span name comes from the Agents SDK’s own Runner.run(..., run_config=RunConfig(workflow_name=...)) knob. Content capture is controlled through OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable.
Prompts and completions can instead be uploaded to external storage via a completion hook: set OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK=upload with OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH (install the upload extra: pip install opentelemetry-util-genai[upload]), or pass a custom CompletionHook programmatically, which takes precedence over the environment variable:
OpenAIAgentsInstrumentor().instrument(completion_hook=my_hook)
References
Release files for opentelemetry-instrumentation-genai-openai-agents 1.2b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opentelemetry_instrumentation_genai_openai_agents-1.2b0.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opentelemetry_instrumentation_genai_openai_agents-1.2b0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / opentelemetry_instrumentation_genai_openai_agents-1.2b0.tar.gz
| Download URL | opentelemetry_instrumentation_genai_openai_agents-1.2b0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a66f016403ea7e02b78c2555c21e097d48d04b16935dca01cc86b15635762cc
|
|
BLAKE2b-256 checksum How to use checksums |
afdc4dbef83c5e361a187df0e9a36562b23d75b10d66c222c1ccd1ee92ba204c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / opentelemetry_instrumentation_genai_openai_agents-1.2b0-py3-none-any.whl
| Download URL | opentelemetry_instrumentation_genai_openai_agents-1.2b0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cf85d401c0bf1bbeb80a212394ea21d81fd6f7d79a0151489e04cf5ceebd6f8f
|
|
BLAKE2b-256 checksum How to use checksums |
02e97dcedbf04314b156759bcd56615f8421f17548b5459cc057777370663198
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log