Skip to content

fix(span_processor): only call on_start with recording spans #3011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## vNext

- TODO: Placeholder for Span processor related things
- *Fix* SpanProcessor::on_start is no longer called on non recording spans

## 0.30.0

Released 2025-May-23
Expand Down
13 changes: 9 additions & 4 deletions opentelemetry-sdk/src/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use crate::trace::{
IdGenerator, ShouldSample, SpanEvents, SpanLimits, SpanLinks,
};
use opentelemetry::{
trace::{SamplingDecision, SpanBuilder, SpanContext, SpanKind, TraceContextExt, TraceFlags},
trace::{
SamplingDecision, Span as _, SpanBuilder, SpanContext, SpanKind, TraceContextExt,
TraceFlags,
},
Context, InstrumentationScope, KeyValue,
};
use std::fmt;
Expand Down Expand Up @@ -281,9 +284,11 @@ impl opentelemetry::trace::Tracer for SdkTracer {
}
};

// Call `on_start` for all processors
for processor in provider.span_processors() {
processor.on_start(&mut span, parent_cx)
if span.is_recording() {
// Call `on_start` for all processors
for processor in provider.span_processors() {
processor.on_start(&mut span, parent_cx)
}
}

span
Expand Down