Skip to content

feat(mcp): implement OpenTelemetry tracing instrumentation#3929

Merged
jknack merged 1 commit intomainfrom
3928
Apr 26, 2026
Merged

feat(mcp): implement OpenTelemetry tracing instrumentation#3929
jknack merged 1 commit intomainfrom
3928

Conversation

@jknack
Copy link
Copy Markdown
Member

@jknack jknack commented Apr 26, 2026

Introduced OtelMcpTracing to provide native, specification-compliant distributed tracing for Model Context Protocol servers.

  • Implements official OpenTelemetry Semantic Conventions for both base RPC (rpc.system=mcp) and GenAI/MCP domains (gen_ai.tool.name, mcp.resource.uri).
  • Resolves high-cardinality span naming by standardizing on JSON-RPC methods (e.g., tools/call) while preserving specific targets in attributes.
  • Leverages McpOperation and McpChain for seamless context injection and session tracking (mcp.session.id).
  • Accurately captures tool execution failures by inspecting CallToolResult.isError() without relying on thrown exceptions, ensuring complete trace fidelity.

Introduced `OtelMcpTracing` to provide native, specification-compliant distributed tracing for Model Context Protocol servers.

- Implements official OpenTelemetry Semantic Conventions for both base RPC (`rpc.system=mcp`) and GenAI/MCP domains (`gen_ai.tool.name`, `mcp.resource.uri`).
- Resolves high-cardinality span naming by standardizing on JSON-RPC methods (e.g., `tools/call`) while preserving specific targets in attributes.
- Leverages `McpOperation` and `McpChain` for seamless context injection and session tracking (`mcp.session.id`).
- Accurately captures tool execution failures by inspecting `CallToolResult.isError()` without relying on thrown exceptions, ensuring complete trace fidelity.
@jknack jknack added this to the 4.5.0 milestone Apr 26, 2026
@jknack jknack merged commit c6dd2dd into main Apr 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant