fix(mcp): replace orphaned spans with proper transactions #3
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.
Problem
MCP tool calls were creating orphaned spans without parent transactions, causing Sentry to display
<unlabeled transaction>instead of meaningful transaction names. This made it impossible to properly track and analyze MCP tool usage.Root Cause
The implementation used
sentry.StartSpan()which creates spans without transactions. When spans don't have a parent transaction, Sentry automatically wraps them in unlabeled transactions.Solution
Updated the tracing implementation to create proper transactions following OpenTelemetry MCP Semantic Conventions:
tools/call {tool_name}(e.g.,tools/call get_action_parameters)mcp.serverChanges
sentry.StartSpan()tosentry.StartTransaction()SourceCustomImpact
Before (Broken)
❌
<unlabeled transaction>in Sentry❌ No visibility into which tool was called
❌ Difficult to filter or analyze
After (Fixed)
✅ Transaction Name:
tools/call get_action_parameters✅ Operation:
mcp.server✅ All MCP metadata properly attached
✅ Easy to filter and analyze by tool name
Testing
Compliance
Fully compliant with OpenTelemetry MCP Semantic Conventions:
mcp.method.name,mcp.tool.name,mcp.transport,network.transportmcp.request.argument.*,mcp.tool.result.*