Skip to content

Add MCP connector metrics#15805

Open
nicholasclark-openai wants to merge 6 commits intomainfrom
nicholasclark/2026-03-25-mcp-metrics
Open

Add MCP connector metrics#15805
nicholasclark-openai wants to merge 6 commits intomainfrom
nicholasclark/2026-03-25-mcp-metrics

Conversation

@nicholasclark-openai
Copy link
Contributor

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

Summary

  • enrich codex.mcp.call with tool, connector_id, and sanitized connector_name for actual MCP executions
  • record codex.mcp.call.duration_ms for actual MCP executions so connector-level latency is visible in metrics
  • keep skipped, blocked, declined, and cancelled paths on the plain status-only codex.mcp.call counter

Included Changes

  • codex-rs/core/src/mcp_tool_call.rs: add connector-sliced MCP count and duration metrics only for executed tool calls, while leaving non-executed outcomes as status-only counts
  • codex-rs/core/src/mcp_tool_call_tests.rs: cover metric tag shaping, connector-name sanitization, and the new duration metric tags

Testing

  • cargo test -p codex-core
  • just fix -p codex-core
  • just fmt

Notes

  • cargo test -p codex-core still hits existing unrelated failures in approvals-reviewer config tests and the sandboxed JS REPL mktemp test
  • full workspace cargo test was not run

@nicholasclark-openai nicholasclark-openai changed the base branch from nicholasclark/2026-03-23-server-spans to main March 25, 2026 22:35
@nicholasclark-openai nicholasclark-openai changed the base branch from main to nicholasclark/2026-03-23-server-spans March 25, 2026 23:13
@nicholasclark-openai nicholasclark-openai changed the base branch from nicholasclark/2026-03-23-server-spans to main March 25, 2026 23:31
@nicholasclark-openai nicholasclark-openai force-pushed the nicholasclark/2026-03-25-mcp-metrics branch from c6b4fbf to a445016 Compare March 25, 2026 23:43
@nicholasclark-openai nicholasclark-openai marked this pull request as ready for review March 26, 2026 00:13
tag_refs.as_slice()
} else {
status_only_tags.as_slice()
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is pretty messy. looks like this complexity is due to conditionally applying tags. for codex.mcp.call, can we always tag it with status, tool, connector_id, connector_name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

and reuse the same tags for both metrics?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was done to not pollute metrics for tool calls that didn't execute declines/safety/other, but agree it just makes things messy. I'll just skip the duration metric if we didn't execute and keep the tags the same (with status) otherwise

nicholasclark-openai and others added 4 commits March 25, 2026 17:58
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
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.

2 participants