Rename span attributes to MCP OTEL semantic conventions - #3748
Merged
Merged
Conversation
ChrisJBurns
requested review from
JAORMX,
jerm-dro and
yrobla
as code owners
February 10, 2026 15:21
7 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3748 +/- ##
==========================================
- Coverage 66.35% 66.33% -0.03%
==========================================
Files 427 427
Lines 41807 41864 +57
==========================================
+ Hits 27741 27770 +29
- Misses 11953 11982 +29
+ Partials 2113 2112 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add new standard OTEL semantic convention attribute names alongside
the existing legacy names. New attributes (http.request.method,
mcp.method.name, gen_ai.tool.name, etc.) are always emitted, while
legacy names are conditionally emitted behind UseLegacyAttributes.
Also updates createSpanName to use "{method} {resourceID}" format
and adds mapTransport helper for network.transport mapping.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ChrisJBurns
force-pushed
the
otel/pr2a-attribute-rename-v2
branch
from
February 10, 2026 15:54
e0d5fd6 to
aed1ec5
Compare
- Remove duplicate mcp.resource.uri emission for resources/read - Rename rpc.system to rpc.system.name, move rpc.system to legacy block - Capture network.protocol.name and network.protocol.version in SSE path - Simplify span names to just MCP method (avoid cardinality risk) - Add network.protocol.version to mapTransport (SSE=1.1, streamable-http=2) - Fix mockSpan.SetStatus to capture status for test verification - Delete dead TestHTTPMiddleware_FinalizeSpan_Logic test - Add tests for mcp.resource.uri conditional logic and protocol version Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Defer mcp.protocol.version to a follow-up once we determine the correct source (header vs constant vs SDK). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
JAORMX
approved these changes
Feb 10, 2026
8 tasks
jhrozek
reviewed
Feb 10, 2026
|
|
||
| // New OTEL MCP semantic convention attributes (always emitted) | ||
| span.SetAttributes( | ||
| attribute.String("mcp.method.name", parsedMCP.Method), |
Contributor
There was a problem hiding this comment.
If someone like me has no idea where these come from: https://opentelemetry.io/docs/specs/semconv/gen-ai/mcp/
jhrozek
reviewed
Feb 10, 2026
| case "sse": | ||
| return networkTransportTCP, networkProtocolHTTP, "1.1" | ||
| case "streamable-http": | ||
| return networkTransportTCP, networkProtocolHTTP, "2" |
Contributor
There was a problem hiding this comment.
is it always http/2 for streamable http or "usually" ?
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UseLegacyAttributes(from Gate legacy span attributes behind UseLegacyAttributes flag #3747)mapTransporthelper to convert MCP transport types to OTELnetwork.transportvaluesmcp.tools/call→tools/call(method only, no resource target to avoid cardinality issues)rpc.systemtorpc.system.name(per OTEL deprecation), movesrpc.systemto legacy blocknetwork.protocol.nameandnetwork.protocol.versionin SSE connection spansKey attribute renames (new names always emitted, old names gated):
http.methodhttp.request.methodhttp.urlurl.fullhttp.status_codehttp.response.status_codemcp.methodmcp.method.namemcp.request.idjsonrpc.request.idmcp.tool.namegen_ai.tool.namemcp.tool.argumentsgen_ai.tool.call.argumentsmcp.transportnetwork.transportmcp.resource.idmcp.resource.urirpc.systemrpc.system.nameNew attributes with no legacy equivalent:
jsonrpc.protocol.versiongen_ai.operation.name,gen_ai.prompt.namenetwork.protocol.name,url.scheme,url.path,url.queryserver.address,user_agent.originalhttp.request.body.size,http.response.body.sizeTransport mapping:
network.transportstdiopipessetcpstreamable-httptcpStacked on #3747 (gates legacy attributes behind the flag).
Test plan
mapTransporthelpercreateSpanNameformat (method only, no resource ID)mcp.resource.uriconditional logic (present forresources/read, absent fortools/call)codes.Okfor 2xx,codes.Errorfor 5xx)task lintpassestask testpasses🤖 Generated with Claude Code