Skip to content

[TT-17356] Add W3C trace context extract/inject helpers for body-carried propagation#70

Merged
lghiur merged 2 commits into
mainfrom
TT-17356-mcp-trace-context
Jun 8, 2026
Merged

[TT-17356] Add W3C trace context extract/inject helpers for body-carried propagation#70
lghiur merged 2 commits into
mainfrom
TT-17356-mcp-trace-context

Conversation

@lghiur

@lghiur lghiur commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Adds two helpers to the trace package for cases where the W3C trace context travels in a request body (e.g. MCP/JSON-RPC params._meta) rather than the HTTP traceparent header:

  • ExtractW3CTraceContext(ctx, traceParent, traceState) — installs a W3C traceparent/tracestate as the active remote span context so later spans join that trace. Always W3C, regardless of the configured propagator.
  • CurrentW3CTraceContext(ctx) — serialises the active span context back to W3C traceparent/tracestate (empty when no span is active). Inverse of the above.

Description

Related Issue

Motivation and Context

Test Coverage For This Change

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring or add test (improvements in base code or adds test coverage to functionality)
  • Documentation updates or improvements.

Checklist

  • I have reviewed the guidelines for contributing to this repository.
  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). If PRing from your fork, don't come from your master!
  • Make sure you are making a pull request against our master branch (left side). Also, it would be best if you started your change off our latest master.
  • My change requires a change to the documentation.
    • I have manually updated the README(s)/documentation accordingly.
    • If you've changed APIs, describe what needs to be updated in the documentation.
  • I have updated the documentation accordingly.
  • Modules and vendor dependencies have been updated; run go mod tidy && go mod vendor
  • When updating library version must provide reason/explanation for this update.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • Check your code additions will not fail linting checks:
    • gofmt -s -w .
    • go vet ./...

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@lghiur

lghiur commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@lghiur
lghiur merged commit bc5cc13 into main Jun 8, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants