docs(trace): clarify that startActiveSpan requires manual span.end()#6633
Merged
david-luna merged 1 commit intoMay 19, 2026
Merged
Conversation
|
|
Add explicit documentation noting that the callback function is responsible for calling span.end() to finish the span. Unlike some other OpenTelemetry implementations, the span is NOT automatically ended when the callback returns. If span.end() is not called, the span will never be exported and will be silently lost. Fixes open-telemetry#5905
cb33c1a to
f73f7b0
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6633 +/- ##
=======================================
Coverage 95.70% 95.70%
=======================================
Files 375 375
Lines 12921 12921
Branches 3090 3090
=======================================
Hits 12366 12366
Misses 555 555
🚀 New features to boost your workflow:
|
david-luna
approved these changes
May 19, 2026
Contributor
|
Thank you for your contribution @raphaeltorquat0! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. |
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.
Which problem is this PR solving?
The JSDoc for
startActiveSpandoes not make it clear that the callback function is responsible for callingspan.end(). Users coming from other OpenTelemetry implementations (like Go) where spans are automatically ended may silently lose spans when using the JavaScript SDK.This PR adds explicit documentation warning that:
span.end()span.end()is not called, the span will never be exportedFixes #5905
Short description of the changes
Added an "Important" note to the JSDoc for
startActiveSpanin both:api/src/trace/tracer.ts(the interface)packages/opentelemetry-sdk-trace-base/src/Tracer.ts(the implementation)The note explicitly states that
span.end()must be called by the callback function, otherwise the span is silently lost.Type of change
Note: parts of this implementation were developed with AI assistance.
CLA Status: I have signed the Contributor License Agreement for this project.