fix(cloud): propagate OTEL trace context across worker→DO boundary#320
Merged
RhysSullivan merged 1 commit intomainfrom Apr 18, 2026
Merged
fix(cloud): propagate OTEL trace context across worker→DO boundary#320RhysSullivan merged 1 commit intomainfrom
RhysSullivan merged 1 commit intomainfrom
Conversation
Worker and McpSessionDO run in separate isolates with independent WebSdk tracer providers, so nothing carried trace context across stub.init() / stub.handleRequest() — the DO emitted a brand-new root trace per request and mcp.request + McpSessionDO.* never stitched in Axiom. Ferry the worker-side span's SpanContext across as a W3C traceparent: - mcp.ts builds it from Effect.currentSpan and either injects a traceparent header on the forwarded Request (handleRequest) or passes it as a new second arg to stub.init(token, traceparent). - mcp-session.ts parses it and uses OtelTracer.withSpanContext so the DO's root Effect span lands under the worker span. Regression guard added to the miniflare e2e suite (extended CapturedSpan to track traceId/spanId/parentSpanId) — asserts McpSessionDO.init shares trace_id with mcp.request and has its spanId as parent_span_id, plus the same for a follow-up tools/list → McpSessionDO.handleRequest.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
executor-marketing | 867ad76 | Commit Preview URL Branch Preview URL |
Apr 18 2026, 08:52 PM |
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.
Summary
mcp.request(worker) andMcpSessionDO.*(DO) in separate traces — the worker's WebSdk and the DO's WebSdk live in different isolates and nothing carried OTEL context across thestub.init()/stub.handleRequest()RPC, so the DO emitted a brand-new root trace per call.traceparentfromEffect.currentSpanand ferries it to the DO (header onhandleRequest, second arg oninit). DO parses it and anchors its root span viaOtelTracer.withSpanContext.McpSessionDO.init/handleRequestmust sharetrace_idwith the correspondingmcp.requestand point to it viaparent_span_id.Test plan
bun run vitest run --config vitest.node.config.ts(cloud): 29/29 pass, including the new propagation assertion.mcp.request+McpSessionDO.*into a single trace.