[Workers] Document startActiveSpan and span.end() tracing APIs#31853
[Workers] Document startActiveSpan and span.end() tracing APIs#31853nevikashah wants to merge 1 commit into
Conversation
|
This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:
|
There was a problem hiding this comment.
Review Summary
This PR adds clear, well-structured documentation for the new startActiveSpan and span.end() tracing APIs. The stream instrumentation example effectively demonstrates the primary use case, and the comparison table between enterSpan and startActiveSpan is a helpful addition.
What changed
- Added
tracing.startActiveSpan(name, callback, ...args)API reference with parameters, behavior, and examples - Added
span.end()method documentation on theSpanobject - Added a stream instrumentation example using
TransformStream - Added a comparison table for choosing between
enterSpanandstartActiveSpan - Updated TypeScript type declarations to include
startActiveSpanandend() - Removed the "No manual span lifetime management" limitation (now supported)
Issues flagged
-
Beta config note removal — The
<Render file="tracing-beta-config-note" product="workers" />partial was removed. That partial contains important forward-looking context aboutobservability.enabledbehavior and futurecompatibility_daterequirements. Please confirm this removal is intentional. If tracing is still in beta (thesidebar.badge.text: Betaremains), this note may still be valuable. -
Code block indentation — The TypeScript code examples throughout the file were changed from 2-space indentation to tabs. This affects every existing code block in the file, not just the new content. Please confirm this is intentional or revert to 2-space indentation to match the original file style.
-
Minor suggestion — In the bare
tssnippets forcapturedSpanandmySpan, consider adding type annotations (let capturedSpan: Span;,let mySpan: Span;) for clarity.
Overall a solid addition to the tracing docs. Once the two questions above are addressed, this should be good to merge.
Suggested code changes (inline references)Line 37 ( Lines 50–63 (first Line 180 ( Line 239 ( See the main review comment above for full context. |
|
I have completed the review of PR #31853 in What was done
PR Summary
Issues Flagged
No frontmatter errors, broken internal links, or MDX syntax issues were found. The new content is well-structured and the caution admonition correctly calls out the async-context limitation of |
|
Preview URL: https://067a3e04.preview.developers.cloudflare.com Files with changes (up to 15) |
|
Thanks for the review! Addressing each point:
|
irvinebroque
left a comment
There was a problem hiding this comment.
Does this mean we can make a little shim that bridges between this and opentelemetry-js?
Summary
Documents the new
tracing.startActiveSpan()andspan.end()APIs added in workerd MR !263. These APIs allow manual span lifetime management for instrumenting operations that outlive a single callback, such as stream pipelines.Key additions to the custom spans page:
tracing.startActiveSpan(name, callback, ...args)API reference with parameters, behavior, and examplesspan.end()method documentation on theSpanobjectenterSpanandstartActiveSpanThe docs call out an important caveat:
startActiveSpanprovides manual lifetime management but only in an "active during callback" shape — the span is the active context parent only during the callback, not for the full span lifetime. This is explained via a caution admonition and the comparison table.Documentation checklist