Commit Detail
Commit 924971e
Replace startSpan with auto-ending enterSpan in user tracing Replaces `tracing.startSpan(name) -> JsSpan` with `tracing.enterSpan(name, callback, ...args)`, which pushes the new span onto the AsyncContextFrame for the callback's duration and auto-ends it on return, throw, or promise settlement. This makes nested spans and runtime-generated spans (e.g. `fetch`) correctly parent on the surrounding user span. Child spans are wrapped in a fresh UserTraceSpanHolder before being pushed onto the AsyncContextFrame; the holder is cleared by SpanImpl::end() so actor IoContexts don't leak tracer refs across requests. `Span` and `SpanImpl` live in a new `workerd::api::user_tracing` sub-namespace to avoid collision with `workerd::Span`. The JS class name is still `Span` via `JSG_NESTED_TYPE_NAMED`. `withSpan` in tracing-helpers.ts becomes a one-line passthrough over `enterSpan`, so downstream callers (d1, images, etc.) need no changes. Adds tracing-hierarchy-test which verifies parent/child relationships in the streaming-tail event stream for nested enterSpan (sync and async), fetch-inside-enterSpan, fetch-inside-nested-enterSpan, and sibling enterSpan calls.
Files changed
12 files changed+4 added~8 modified