Improve OTel GenAI span semantics and DIFC/rate-limit milestone visibility#7989
Merged
Conversation
Copilot
AI
changed the title
[WIP] Review OpenTelemetry Go module usage
Improve OTel GenAI span semantics and DIFC/rate-limit milestone visibility
Jun 23, 2026
Collaborator
|
@copilot resolve the merge conflicts in this pull request |
…-review # Conflicts: # internal/tracing/span_helpers.go # internal/tracing/span_helpers_test.go
Contributor
Author
Resolved in |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances OpenTelemetry trace semantics for MCP tool calls and the proxy DIFC pipeline by adding milestone span events for DIFC phases/denials and rate-limit detection, improving trace timelines and Sentry visibility.
Changes:
- Emit DIFC milestone span events in both unified tool-call flow and proxy DIFC pipeline (
difc.pre_phases_complete,difc.access_deniedwithreason). - Emit
rate_limit.detectedspan events with optionalreset_at, and setrate_limit.hit=trueon relevant spans when rate limiting is detected. - Consolidate proxy rate-limit signal detection into a shared helper and add focused unit test coverage for the helper.
Show a summary per file
| File | Description |
|---|---|
| internal/server/unified.go | Adds DIFC and rate-limit milestone events to mcp.tool_call spans (and propagates rate_limit.hit). |
| internal/proxy/handler.go | Adds DIFC milestone events, rate-limit event/attribute emission, and introduces shared rateLimitSignal helper. |
| internal/proxy/rate_limit_test.go | Adds unit tests covering the new rateLimitSignal helper behavior. |
| docs/otel-sentry.md | Documents new gen_ai.* attributes on mcp.tool_call and the new milestone span events / expanded rate_limit.hit coverage. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 0
This was referenced Jun 24, 2026
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.
This addresses gaps from the OTel module review:
mcp.tool_callspans were missing key GenAI semconv attributes, and DIFC/rate-limit milestones were not represented as span events. The PR adds those missing semantics and timeline markers in unified and proxy paths.GenAI semconv completion (
mcp.tool_call)gen_ai.operation.name="execute_tool"to tool-call spans.gen_ai.agent.name="mcp-gateway"to tool-call spans.gen_ai.system,gen_ai.agent.id,gen_ai.tool.name,mcp.method) intact.DIFC milestone span events
difc.pre_phases_completeafter successful pre-phases.difc.access_deniedwith structuredreasonon policy denials.Rate-limit observability events
rate_limit.detectedevent when rate-limit signals are detected.reset_atevent attribute when available.rate_limit.hit=trueattribute on proxy forward span when signaled.Proxy rate-limit signal consolidation
Tracing docs and focused test updates