You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(sdk): change SpanProcessor::on_end to take &mut FinishedSpan
Refactors the SpanProcessor API to avoid unnecessary cloning of span data:
1. Introduces `ReadableSpan` trait with getters for span fields, allowing
processors to inspect spans without cloning.
2. Introduces `FinishedSpan` wrapper passed to `on_end`. Processors that
only read span data pay zero cost. Processors that need ownership call
`consume()` — the last processor gets the data via move (zero-copy),
earlier processors get a clone.
3. Changes `on_end(&self, span: SpanData)` to
`on_end(&self, span: &mut FinishedSpan)`.
This is a breaking change to the SpanProcessor trait.
4. Implements `ReadableSpan` for both `Span` (live spans) and
`FinishedSpan`.
Benchmarks show span lifecycle cost becomes constant regardless of
processor count (previously scaled linearly due to cloning).
Original work by paullegranddc in PR #2962.
Supersedes #2962.
Relates to #2940, #2726, #2939.
0 commit comments