Skip to content

[WO-1570] Report spans outside the invocation's trace in their own trace - #8561

Draft
jmorrell-cloudflare wants to merge 1 commit into
mainfrom
jmorrell/span-trace-context
Draft

jmorrell-cloudflare wants to merge 1 commit into
mainfrom
jmorrell/span-trace-context

Conversation

@jmorrell-cloudflare

@jmorrell-cloudflare jmorrell-cloudflare commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Streaming tail events now report each span in the trace it belongs to. Until now every event carried the invocation's trace ID, which is wrong for a span whose parent was created somewhere else, such as in another Worker, or for a span that starts a new trace.

A child of a span from elsewhere is reported in that span's trace. A span that starts a new trace gets a new trace ID, has no parent span ID in its spanOpen, and is marked sampled, as OpenTelemetry's default sampler does for a root span. Logs and other events inside these spans carry the span's trace ID too. The tail event format doesn't change.

Nothing creates these spans yet; tracing.withActiveSpanContext() in the next PR will. Embedders now have to implement SpanSubmitter::submitSpanTrace() and makeRootTraceId(), and BaseTracer::setSpanTrace(), so each span's trace reaches the tail stream.

Heads up: once something creates these spans, tail workers will see spanOpen events with no parent and events in traces other than the invocation's. The internal build needs the matching jmorrell/span-trace-context edgeworker branch.

Every tail event carries a trace ID, but the runtime always filled it with the
invocation's. Spans can now belong to another trace: children of a span created
elsewhere, such as in another Worker, and spans that start a new trace. Their
events, and logs written inside them, carry the span's own trace ID. A span that
starts a trace has no parent span ID in its spanOpen event, and is marked
sampled, as OpenTelemetry's default sampler does for a root span. No new tail
event fields are added.

Nothing creates these spans yet; tracing.withActiveSpanContext() will.
Embedders must now implement SpanSubmitter::submitSpanTrace() and
makeRootTraceId(), and BaseTracer::setSpanTrace(), to carry each span's trace.
@jmorrell-cloudflare
jmorrell-cloudflare force-pushed the jmorrell/span-trace-context branch from aebe418 to eb4a1ef Compare November 18, 2026 01:17
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.

1 participant