feat(tracing): allow span processor to keep span reference#3350
feat(tracing): allow span processor to keep span reference#3350samugi wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
Adds a get_handle method to `Span` that allows obtaining an instance of `SpanHandle`: a structure that shares the same fields as the span, where the SpanData is protected by a Mutex. This allows holding a reference to a span, which enables use cases such as span processors keeping track of active spans, as mentioned in [the spec](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/sdk.md#onstart). fixes: 602
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3350 +/- ##
=======================================
+ Coverage 82.2% 82.4% +0.2%
=======================================
Files 128 128
Lines 24510 24875 +365
=======================================
+ Hits 20154 20511 +357
- Misses 4356 4364 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hey @samugi thanks for contributing! This is a pretty chunky change, and I note a SHOULD in the spec; out of curiosity, is there an external driver you'd like to share - e.g. something downstream that needs this to be implemented? I haven't looked at it in detail yet, but I'd suggest we likely want a reasonably detailed design discussion here. Paging @cijothomas and @bantonsson who almost certainly have useful input :) |
|
hey @scottgerring , thanks for the feedback!
Not really, I picked the issue from the Tracing SDK Stable milestone. Is the milestone up to date and a good source of contributions or would you recommend focusing elsewhere? Thank you! |
Fixes #602
Changes
Adds a
get_handlemethod toSpanthat allows obtaining an instance ofSpanHandle: a structure that shares the same fields as the span, where the SpanData is protected by a Mutex.This allows holding a reference to a Span, which enables use cases such as span processors keeping track of active spans, as mentioned in the spec.
Example:
Notes
First contribution here. The change ended up being a bit more invasive than I would've hoped, if there's a cleaner or more idiomatic way to achieve the goal, I'm very happy to adjust the approach and keep iterating on it. Thanks!
Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial, user-facing changes