Skip to content

Add Responses spans and RMCP trace propagation#15792

Draft
nicholasclark-openai wants to merge 2 commits intomainfrom
nicholasclark/2026-03-25-responses-spans
Draft

Add Responses spans and RMCP trace propagation#15792
nicholasclark-openai wants to merge 2 commits intomainfrom
nicholasclark/2026-03-25-responses-spans

Conversation

@nicholasclark-openai
Copy link
Contributor

@nicholasclark-openai nicholasclark-openai commented Mar 25, 2026

Summary

  • add explicit responses_http.request spans for Responses HTTP requests under the existing turn trace
  • add lower-level http.client child spans so raw transport time is visible under the semantic Responses span
  • add RMCP transport work: mcp.client.operation child spans plus traceparent/tracestate propagation over streamable HTTP headers and stdio request _meta

Included Changes

  • codex-rs/core/src/network_trace.rs: shared Responses span builder and turn correlation fields
  • codex-rs/core/src/client.rs: wrap Responses HTTP requests in responses_http.request
  • codex-rs/codex-client/src/default_client.rs: add http.client child spans and inject W3C trace headers from the explicit HTTP span
  • codex-rs/core/src/tasks/mod.rs: keep the task-owned turn span as the explicit parent for nested request spans
  • codex-rs/core/tests/suite/otel.rs: assert Responses request spans are nested under the turn span
  • codex-rs/rmcp-client/src/rmcp_client.rs: add mcp.client.operation spans and propagate traceparent / tracestate over streamable HTTP headers and stdio metadata
  • codex-rs/rmcp-client/src/bin/test_stdio_server.rs: expose propagated stdio trace metadata in the test server response
  • codex-rs/rmcp-client/src/bin/test_streamable_http_server.rs: require traceparent on session POSTs in the streamable HTTP test mode
  • codex-rs/rmcp-client/tests/resources.rs: add direct RMCP stdio propagation coverage
  • codex-rs/core/tests/suite/rmcp_client.rs: cover streamable HTTP propagation and keep the end-to-end MCP round-trip coverage

Testing

  • cargo test -p codex-client
  • cargo test -p codex-rmcp-client
  • just fix -p codex-client
  • just fix -p codex-rmcp-client
  • just fmt

Notes

  • websocket-specific spans and websocket transport propagation remain out of scope
  • MCP metrics moved to sibling PR Add MCP connector metrics #15805
  • full workspace cargo test was not run

@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from 905cab6 to a417486 Compare March 25, 2026 19:37
@nicholasclark-openai nicholasclark-openai changed the title Add Responses and HTTP child spans Add Responses spans and RMCP trace propagation Mar 25, 2026
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch 2 times, most recently from d04171e to 2e88da9 Compare March 25, 2026 20:56
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-23-server-spans branch from 4fe235f to 6f5cefc Compare March 25, 2026 21:21
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from 2e88da9 to e738606 Compare March 25, 2026 21:21
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-23-server-spans branch from 6f5cefc to 16d57b4 Compare March 25, 2026 21:28
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from e738606 to caf275b Compare March 25, 2026 21:29
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-23-server-spans branch from 16d57b4 to 89161d4 Compare March 25, 2026 21:40
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from caf275b to 875f48c Compare March 25, 2026 21:48
@nicholasclark-openai nicholasclark-openai changed the title Add Responses spans and RMCP trace propagation Add Responses spans, RMCP trace propagation, and MCP metrics Mar 25, 2026
@nicholasclark-openai nicholasclark-openai changed the title Add Responses spans, RMCP trace propagation, and MCP metrics Add Responses spans and RMCP trace propagation Mar 25, 2026
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from 875f48c to 5173865 Compare March 25, 2026 22:10
Base automatically changed from nicholasclark/2026-03-23-server-spans to main March 25, 2026 22:13
nicholasclark-openai added a commit that referenced this pull request Mar 25, 2026
## Summary
- add an explicit `mcp.tools.call` span around MCP tool execution in
core
- keep MCP span validation local to `mcp_tool_call_tests` instead of
broadening the integration test suite
- inline the turn/session correlation fields directly in the span
initializer

## Included Changes
- `codex-rs/core/src/mcp_tool_call.rs`: wrap the existing MCP tool call
in `mcp.tools.call` and inline `conversation.id`, `session.id`, and
`turn.id` in the span initializer
- `codex-rs/core/src/mcp_tool_call_tests.rs`: assert the MCP span
records the expected correlation and server fields

## Testing
- `cargo test -p codex-core`
- `just fmt`

## Notes
- `cargo test -p codex-core` still hits existing unrelated failures in
guardian-config tests and the sandboxed JS REPL `mktemp` test
- metric work moved to stacked PR #15792
- transport-level RMCP spans and trace propagation remain in stacked PR
#15792
- full workspace `cargo test` was not run

---------

Co-authored-by: Codex <noreply@openai.com>
nicholasclark-openai and others added 2 commits March 25, 2026 15:19
Layer the Responses-specific request spans and HTTP transport child spans on top of the MCP tracing branch, and add focused tracing assertions for the Responses path.

Co-authored-by: Codex <noreply@openai.com>
Add traceparent/tracestate propagation for RMCP streamable HTTP and stdio calls, and cover it with transport-level tests.

Co-authored-by: Codex <noreply@openai.com>
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-responses-spans branch from 5173865 to e9e5bea Compare March 25, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant