Skip to main content
Pre-release

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

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

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

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file opentelemetry_instrumentation_genai_openai_agents-1.1b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_openai_agents-1.1b0.tar.gz
Algorithm Hash digest
SHA256 8664eea769b16a219068d6b7a1a1863db425d45660d97cb1c440d67670e6b749
MD5 9e73847b183a35ebfb82521d79da04e7
BLAKE2b-256 2cf2b7986d9b4c6b5feecda3f8fbba1becb44e2996e9155f406ec84885636f5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_instrumentation_genai_openai_agents-1.1b0.tar.gz:

Publisher: release-all.yml on open-telemetry/opentelemetry-python-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opentelemetry_instrumentation_genai_openai_agents-1.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_genai_openai_agents-1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 48f8d5533dcb1e72f2a8e656b2591a85c26411a82eec23b75701cee26000f860
MD5 4227cdb8ca3fb12d0cf154010c8ecada
BLAKE2b-256 68d6bcb6babd852029ec15cb1e7052ab8421ebe860f5cfaaa7357bd1cfb4382e

See more details on using hashes here.

Provenance

The following attestation bundles were made for opentelemetry_instrumentation_genai_openai_agents-1.1b0-py3-none-any.whl:

Publisher: release-all.yml on open-telemetry/opentelemetry-python-genai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.1b0 This release

2 files

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