Observe 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 observe-instrumentation-genai-openai when it is installed and instrumented alongside this package.
This package is Observe’s replacement for upstream’s opentelemetry-instrumentation-genai-openai-agents, not an addition to it. The two distributions install to the same paths, so an environment holding both gets a per-file mix of them and uninstalling either one breaks the other. This package depends on observe-util-genai, which replaces upstream’s opentelemetry-util-genai in the same way. Uninstall both upstream packages first; an upstream instrumentation that still needs opentelemetry-util-genai cannot share an environment with this one.
Installation
pip uninstall opentelemetry-instrumentation-genai-openai-agents opentelemetry-util-genai pip install observe-instrumentation-genai-openai-agents
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 observeinc.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 by changing observe-util-genai to observe-util-genai[upload] in the install command above), or pass a custom CompletionHook programmatically, which takes precedence over the environment variable:
OpenAIAgentsInstrumentor().instrument(completion_hook=my_hook)
References
Metadata
Release files for observe-instrumentation-genai-openai-agents 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| observe_instrumentation_genai_openai_agents-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for observe_instrumentation_genai_openai_agents-0.1.0-py3-none-any.whl |
Release files / observe_instrumentation_genai_openai_agents-0.1.0-py3-none-any.whl
| Download URL | observe_instrumentation_genai_openai_agents-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79eacd7ed447845c1af47751def97bc494b7e60fb337f779f1db34981533f24b
|
|
BLAKE2b-256 checksum How to use checksums |
463714ca54949ef6d6e54d86c289f2ab70b9dbecdde3ffd6a100cf6cfd23abbd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Security for observe-instrumentation-genai-openai-agents 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.