Skip to content

[codex] trace MCP startup latency - #28630

Merged
rphilizaire-openai merged 1 commit into
mainfrom
dev/rphilizaire/mcp-startup-tracing
Jun 24, 2026
Merged

[codex] trace MCP startup latency#28630
rphilizaire-openai merged 1 commit into
mainfrom
dev/rphilizaire/mcp-startup-tracing

Conversation

@rphilizaire-openai

Copy link
Copy Markdown
Contributor

Summary

  • add trace-level instrumentation around per-server MCP setup, client construction, initialization, and initial tool listing
  • trace Codex Apps tool and server-info cache loads
  • attach server_name to server-scoped spans so slow startup work can be attributed to a specific MCP server

Why

session_init.mcp_manager_init can occasionally be slow, but its existing coarse span does not identify whether time is spent loading the Codex Apps cache, constructing a client, initializing a transport, or listing tools. These definition-level spans provide that breakdown without changing startup behavior.

Validation

  • just test -p codex-mcp (87 passed)
  • just test -p codex-rmcp-client (86 passed, 2 skipped)

@rphilizaire-openai
rphilizaire-openai marked this pull request as ready for review June 17, 2026 00:45

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

Copy link
Copy Markdown
Contributor

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: f01296ebe1

ℹ️ 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".

impl AsyncManagedClient {
// Keep this constructor flat so the startup inputs remain readable at the
// single call site instead of introducing a one-off params wrapper.
#[instrument(level = "trace", skip_all, fields(server_name = %server_name))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve the session parent for startup spans

Because new is synchronous, this span ends after constructing the shared startup future below; the actual client construction/initialize/tool-list work is later polled from McpConnectionManager::new's background JoinSet task. For non-required MCP servers, or whenever that background task polls the shared future first, the new startup spans are detached from the session_init trace, so they still cannot explain which server made startup slow. Capture and instrument the startup future or spawned task with the current span so these definition-level spans remain under the session init trace.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rphilizaire-openai this one's worth a look

@rphilizaire-openai
rphilizaire-openai force-pushed the dev/rphilizaire/mcp-startup-tracing branch from f01296e to 6bf6afe Compare June 23, 2026 22:56
@rphilizaire-openai
rphilizaire-openai force-pushed the dev/rphilizaire/mcp-startup-tracing branch from 6bf6afe to 5dde64d Compare June 23, 2026 23:50
@rphilizaire-openai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 5dde64dacd

ℹ️ 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".

@rphilizaire-openai
rphilizaire-openai merged commit 322e335 into main Jun 24, 2026
46 of 47 checks passed
@rphilizaire-openai
rphilizaire-openai deleted the dev/rphilizaire/mcp-startup-tracing branch June 24, 2026 00:46
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 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