Conversation
With use_otel_instrumentation=True the receiving side recreated the caller's Agents SDK trace and span and started them, so OpenInference registered never-finished copies under the caller's IDs. In a shared process these displaced the caller's own spans, leaving temporal:startWorkflow and temporal:startActivity spans with a parent that was never exported and dropping the client's root span. Restore the trace and span without starting them and attach the propagated OTel span context as current so receiving-side spans parent to the caller's span. Remove the now unused id seeding and start_traces flag. Fixes #1852
DABH
force-pushed
the
otel-bridge-no-replica-registration
branch
from
September 14, 2026 17:36
a53ec68 to
d25b184
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The reconstructed parent always forces sampling instead of preserving the caller’s sampling decision.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates OpenAI Agents OTel propagation to avoid worker-side replica spans and detached trace trees.
Changes:
- Restores propagated spans without starting copies.
- Parents worker spans using propagated OTel context.
- Adds single-process regression coverage and changelog notes.
File summaries
| File | Description |
|---|---|
CHANGELOG.md |
Documents corrected span parenting. |
temporalio/contrib/openai_agents/_trace_interceptor.py |
Removes replica-starting behavior. |
temporalio/contrib/openai_agents/_otel_trace_interceptor.py |
Restores remote OTel parent context. |
temporalio/contrib/openai_agents/_temporal_openai_agents.py |
Removes obsolete ID generator wiring. |
tests/contrib/openai_agents/test_openai_tracing.py |
Updates setup and adds regression coverage. |
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| trace_id=otel_trace_id, | ||
| span_id=otel_span_id, | ||
| is_remote=True, | ||
| trace_flags=TraceFlags(TraceFlags.SAMPLED), |
Contributor
Author
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.
OpenAIAgentsPlugin(use_otel_instrumentation=True)exportedtemporal:startWorkflowandtemporal:startActivityspans whose parent was never exported, so model and tool subtrees rendered detached in Phoenix, and a client running in the worker process lost its root span. The interceptor recreated and started the caller's Agents SDK trace and span on the worker; OpenInference registered these never-finished copies under the caller's IDs, displacing the caller's entries and leaking one per task.The receiving side now restores them without starting them and attaches the propagated OTel span context as current, so spans created there parent to the caller's span. The
start_tracesflag only served the copies and is removed; the seeding methods onTemporalIdGeneratorare now unused but left in place to keep this change small. A caller without an OTel span no longer gets a synthesized root on the worker.A new single-process regression test with an activity tool fails on main. Two existing tests started the client trace before the worker had installed instrumentation and only passed because the copy stood in for the root; they now use
tracing_context().Fixes #1852