Add W3C Trace Context propagation via MCP _meta#3682
Conversation
Add MetaCarrier (TextMapCarrier for MCP _meta fields) and InjectMetaTraceContext for injecting traceparent/tracestate into outgoing MCP requests, per the MCP OTEL specification. This enables distributed tracing across vMCP → backend boundaries using the standard W3C Trace Context format propagated through MCP params._meta. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3682 +/- ##
=======================================
Coverage 66.31% 66.32%
=======================================
Files 426 427 +1
Lines 41742 41765 +23
=======================================
+ Hits 27682 27700 +18
- Misses 11948 11955 +7
+ Partials 2112 2110 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jhrozek
left a comment
There was a problem hiding this comment.
Review conducted with 4 specialized agents (MCP Protocol Expert, Go Expert Developer, Security Reviewer, Code Reviewer). 2 inline comments below, no blocking issues found.
Overall: Clean, correct, well-tested implementation. MCP spec-compliant use of _meta for W3C Trace Context. No security concerns.
|
@claude could you rebase the commit atop origin/main and see if you can address my review comments in a separate commit (they are squashed anyway and a separate commit will be easier to back away from) |
|
Claude finished @jhrozek's task in 2m 24s —— View job Review comments addressed ✓
Changes MadeI've successfully addressed both review comments in a separate commit (125f2d1):
All tests pass successfully. The linter check will run in CI since it requires tool approval. |
- Add compile-time assertion that MetaCarrier implements propagation.TextMapCarrier - Refactor TestMetaCarrier_GetSetKeys to use table-driven test pattern for Get operations Co-authored-by: Jakub Hrozek <jhrozek@users.noreply.github.com>
|
welp, I don't know if the table-driven test is an improvement |
|
@claude Address the lint errors that occur in the pipeline please |
|
Claude finished @ChrisJBurns's task in 1m 13s —— View job Lint errors fixed ✓
What was fixed:
Changes committed:
|
- Added t.Parallel() call in subtests to satisfy paralleltest/tparallel linters - Maintains test isolation while allowing parallel execution Co-authored-by: Chris Burns <ChrisJBurns@users.noreply.github.com>
Summary
MetaCarrierimplementingpropagation.TextMapCarrierfor MCP_metafieldsInjectMetaTraceContextfor injectingtraceparent/tracestateinto outgoing MCP requestsThis is the foundation layer for the MCP OTEL semantic conventions alignment (#3399). The propagation carrier and injection function are used by subsequent PRs to inject trace context into outgoing MCP calls.
PR Stack (1/3): This PR → #3683 (metrics/attributes) → #3 (client spans)
Test plan
MetaCarrier(Get/Set/Keys/Meta)InjectMetaTraceContext(with real tracer, nil meta)//nolintdirective)go build ./...passesgo test ./pkg/telemetry/...passestask lint-fixpasses with 0 issues🤖 Generated with Claude Code