Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenTelemetry OpenAI Agents Instrumentation

pypi

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

Metadata

Release files for opentelemetry-instrumentation-genai-openai-agents 1.3b0

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

Source distribution (sdist)

Source distribution for opentelemetry-instrumentation-genai-openai-agents 1.3b0
File Size Uploaded Provenance Actions
opentelemetry_instrumentation_genai_openai_agents-1.3b0.tar.gz 10.4 kB With provenance Details for opentelemetry_instrumentation_genai_openai_agents-1.3b0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-genai-openai-agents 1.3b0
File Interpreter ABI Platform Actions
opentelemetry_instrumentation_genai_openai_agents-1.3b0-py3-none-any.whl Python 3 none any Details for opentelemetry_instrumentation_genai_openai_agents-1.3b0-py3-none-any.whl

Total release size: 23.2 kB

Release files / opentelemetry_instrumentation_genai_openai_agents-1.3b0.tar.gz

Download URL opentelemetry_instrumentation_genai_openai_agents-1.3b0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f431d874ad449fe34fdc8f81343680ab1de72da9044363d27e222388a6511d3f
BLAKE2b-256 checksum
How to use checksums
08fd67b593d31060017089fae067444b73526f35704548eebb64ee35cb97482f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

Release files / opentelemetry_instrumentation_genai_openai_agents-1.3b0-py3-none-any.whl

Download URL opentelemetry_instrumentation_genai_openai_agents-1.3b0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
816ab383c3ae74c9258e1635ce15cd7f0af4d4c039f5a41263b630da9afba1f4
BLAKE2b-256 checksum
How to use checksums
b4bd4e1cef1ba08af556ad1a97ba9e3d58a5b2e1cf8bece416e2d3ca91b97312
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 23, 2026.

Transparency log

Security for opentelemetry-instrumentation-genai-openai-agents 1.3b0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opentelemetry_instrumentation_genai_openai_agents-1.3b0.tar.gz

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 Oct 23, 2026.

Transparency log

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