Skip to content

feat(app-server): propagate app-server trace context into core#13368

Merged
owenlin0 merged 3 commits intomainfrom
owen/app_server_tracing_pt2
Mar 4, 2026
Merged

feat(app-server): propagate app-server trace context into core#13368
owenlin0 merged 3 commits intomainfrom
owen/app_server_tracing_pt2

Conversation

@owenlin0
Copy link
Collaborator

@owenlin0 owenlin0 commented Mar 3, 2026

Summary

Propagate trace context originating at app-server RPC method handlers -> codex core submission loop (so this includes spans such as run_turn!). This implements PR 2 of the app-server tracing rollout.

This also removes the old lower-level env-based reparenting in core so explicit request/submission ancestry wins instead of being overridden by ambient TRACEPARENT state.

What changed

  • Added trace: Option<W3cTraceContext> to codex_protocol::Submission
  • Taught Codex::submit() / submit_with_id() to automatically capture the current span context when constructing or forwarding a submission
  • Wrapped the core submission loop in a submission_dispatch span parented from Submission.trace
  • Warn on invalid submission trace carriers and ignore them cleanly
  • Removed the old env-based downstream reparenting path in core task execution
  • Stopped OTEL provider init from implicitly attaching env trace context process-wide
  • Updated mcp-server Submission call sites for the new field

Added focused unit tests for:

  • capturing trace context into Submission
  • preferring Submission.trace when building the core dispatch span

Why

PR 1 gave us consistent inbound request spans in app-server, but that only covered the transport boundary. For long-running work like turns and reviews, the important missing piece was preserving ancestry after the request handler returns and core continues work on a different async path.

This change makes that handoff explicit and keeps the parentage rules simple:

  • app-server request span sets the current context
  • Submission.trace snapshots that context
  • core restores it once, at the submission boundary
  • deeper core spans inherit naturally

That also lets us stop relying on env-based reparenting for this path, which was too ambient and could override explicit ancestry.

@owenlin0 owenlin0 marked this pull request as ready for review March 3, 2026 21:32
@owenlin0 owenlin0 force-pushed the owen/app_server_tracing_pt2 branch from deed122 to de30828 Compare March 3, 2026 21:35
@owenlin0 owenlin0 force-pushed the owen/app_server_tracing_pt2 branch from de30828 to 90585ec Compare March 3, 2026 21:47
@owenlin0
Copy link
Collaborator Author

owenlin0 commented Mar 3, 2026

@codex review

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 90585ec15e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@owenlin0
Copy link
Collaborator Author

owenlin0 commented Mar 3, 2026

@codex review

@chatgpt-codex-connector
Copy link
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@owenlin0 owenlin0 force-pushed the owen/app_server_tracing_pt2 branch from a349cc9 to 9fa6c16 Compare March 4, 2026 00:26
@owenlin0 owenlin0 enabled auto-merge (squash) March 4, 2026 00:40
@owenlin0 owenlin0 merged commit 52521a5 into main Mar 4, 2026
54 of 57 checks passed
@owenlin0 owenlin0 deleted the owen/app_server_tracing_pt2 branch March 4, 2026 01:03
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants