Uh oh!
There was an error while loading. Please reload this page.
Add GenAI semconv attributes to native OTel spans - #2854
Closed
etserend wants to merge 4 commits into
Closed
Conversation
etserend
commented
Jun 12, 2026
Author
Here is example output |
etserendforce-pushed
the
enrich-otel-spans-genai-semconv
branch
from
June 12, 2026 20:59
aa95d2b to
6930f92CompareUh oh!
There was an error while loading. Please reload this page.
…, add gen_ai.prompt.name for prompts/get
etserendforce-pushed
the
enrich-otel-spans-genai-semconv
branch
from
June 15, 2026 14:21
e038fe2 to
5744777Compareetserend
marked this pull request as ready for review
June 15, 2026 15:52
2 tasks
maxisbey
commented
Jul 29, 2026
Contributor
Thanks for the PR. This has since landed via #2970. I'm closing this out as part of a backlog cleanup now that v2 is out. Feel free to reopen if this is still relevant. |
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 freeto 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.
The existing otel_middleware and client-side spans only emitted mcp.method.name and jsonrpc.request.id. This enriches them with attributes defined in the OTel GenAI MCP semantic conventions:
gen_ai.operation.name— operation type derived from the method (execute_toolfor tools/call,list_toolsfor tools/list,read_resourcefor resources/read,get_promptfor prompts/get, etc.)gen_ai.tool.name— tool or prompt name from params.name when presentmcp.resource.uri— resource URI from params.uri or params.ref.urirpc.system = "mcp"— standard RPC system attributeMotivation and Context
The SDK already ships otel_middleware in
src/mcp/server/runner.pyproducing SpanKind.SERVER spans with W3C trace context propagation. Aligning the native span attributes with the GenAI semconv spec means every MCP-based framework and every distribution gets conformant telemetry without independently re-implementing span plumbing.How Has This Been Tested?
Adds three tests to tests/shared/test_otel.py:
Types of changes
Checklist
Additional context