Repository navigation
Record OpenAI Agents SDK traces as the Airflow task's OpenTelemetry spans - #74769
Merged
Merged
Conversation
phanikumv
reviewed
Oct 15, 2026
phanikumv
reviewed
Oct 15, 2026
kaxil
force-pushed
the
openai-agents-tracing
branch
2 times, most recently
from
October 15, 2026 12:46
46945cb to
4812fdd
Compare
kaxil
requested review from
amoghrajesh,
bugraoz93,
choo121600,
ephraimbuddy,
jason810496,
jedcunningham,
jscheffl,
potiuk and
vatsrahul1001
as code owners
October 15, 2026 12:47
…pans The SDK traces runs with a system of its own rather than OpenTelemetry, so agent_framework_tracing() cannot reach it. AirflowTraceProcessor is an SDK trace processor that records each trace as spans under the current span, following the GenAI conventions for agents, model calls and tool calls, with content left out unless [common.ai] capture_content is on and masked when recorded. Registered with set_trace_processors it also stops the SDK's default export to OpenAI; add_trace_processor keeps both.
kaxil
force-pushed
the
openai-agents-tracing
branch
from
October 15, 2026 12:47
4812fdd to
f0b8e8a
Compare
pankajkoti
reviewed
Oct 15, 2026
pankajastro
reviewed
Oct 15, 2026
pankajastro
left a comment
Member
There was a problem hiding this comment.
A few questions inline.
Drafted-by: Claude Code (Sonnet 5.5); reviewed by @pankajastro before posting
…pans A span the SDK never finished now ends with its trace, and one whose attributes fail to build still ends. Model calls start as CLIENT spans with gen_ai.provider.name on the Responses path and server.address on the Chat Completions path. A result that is a bare number or string is masked as text, and the Responses output is serialized only when content is captured.
pankajastro
approved these changes
Oct 15, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OpenAI Agents SDK traces runs with a system of its own rather than OpenTelemetry, and by default sends every trace, prompts and model output included, to OpenAI's backend, whatever model the agent runs.
agent_framework_tracing()cannot reach it the way it reaches Strands and ADK. This addsAirflowTraceProcessor, an SDK trace processor that records each trace as OpenTelemetry spans under the task's span:Stacked on the CI PR.
Design rationale
The user registers the processor; the helper does not mute OpenAI's export. The SDK has public
add_trace_processorandset_trace_processors, but no public way to inspect or remove its default exporter. Muting it insideagent_framework_tracing()would mean reading the trace provider's private processor list. With an explicit processor the user picks, with the SDK's own calls, whether traces stay in Airflow or go to both.Its own processor rather than an existing instrumentation.
openinference-instrumentation-openai-agentsandopentelemetry-instrumentation-openai-agentsalso convert the SDK's traces, but they would be a new dependency for an experimental adapter, they have content switches of their own thatagent_framework_tracing()does not set, and they do not mask. This processor follows common.ai's content rule: prompts, completions, tool arguments and results, and the SDK's error messages (some of which are app-supplied text, such as an approval rejection reason) are recorded only when[common.ai] otel_export_enabledandcapture_contentare both on, and pass through the masker. JSON text is parsed before it is masked, so a secret holding a quote or backslash is not missed in its escaped form.Each SDK span is the current span while it runs. Spans other instrumentation starts inside a tool or model call, such as an HTTP request, nest under that call rather than beside the agent tree. The task's identity attributes are stamped by the processor itself, so they are on the spans whichever tracer provider records them.
Spans use the GenAI convention names:
invoke_agent,chatwith the model and token counts (both the Chat Completions and Responses paths), andexecute_tool. The SDK's owntaskandturnspans are namedopenai_agents.taskandopenai_agents.turn, so they are not confused with the Airflow task's span. The content rule now comes from one helper,_content_capture_enabled(), whichagent_framework_tracing()uses too.Gotchas
set_tracing_disabled,RunConfig(tracing_disabled=True)) stops the processor receiving anything too.RunConfig(trace_include_sensitive_data=False)the SDK withholds the whole response on the Responses path, so thosechatspans carry token counts but no model name.{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.