OpenTelemetry Official OpenAI Agents instrumentation
Project description
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.
References
Project details
Release history Release notifications | RSS feed
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_openai_agents-1.0b0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_genai_openai_agents-1.0b0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f8da01fa992b61a35a63cda72bb9bfba05cbeacf97438415543bf42630e10f0
|
|
| MD5 |
687b8b79aa3a0877c5e2833c63f1ff0b
|
|
| BLAKE2b-256 |
274190257e4f085cd15b8d75ebe0272716e1e35d9358e09316de99185b109169
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_genai_openai_agents-1.0b0.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_openai_agents-1.0b0.tar.gz -
Subject digest:
7f8da01fa992b61a35a63cda72bb9bfba05cbeacf97438415543bf42630e10f0 - Sigstore transparency entry: 2132314411
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-all.yml@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file opentelemetry_instrumentation_genai_openai_agents-1.0b0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_genai_openai_agents-1.0b0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3848374be8f6050f9d698218f12bdd31acac15070a8cde2fd63ac537ceb21e59
|
|
| MD5 |
1f07fda6f1d8a3d7625930726ab3b2ec
|
|
| BLAKE2b-256 |
4e55959947674959d789b92c4625acc1db1802f201e193cf5f296ec48d45b7fa
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_genai_openai_agents-1.0b0-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_openai_agents-1.0b0-py3-none-any.whl -
Subject digest:
3848374be8f6050f9d698218f12bdd31acac15070a8cde2fd63ac537ceb21e59 - Sigstore transparency entry: 2132314549
- Sigstore integration time:
-
Permalink:
open-telemetry/opentelemetry-python-genai@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/open-telemetry
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-all.yml@1e4aca50a0c5b5fcf8b3e2a7a81eec6ac12a1669 -
Trigger Event:
workflow_dispatch
-
Statement type: