Skip to content
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

Make SpanProcessor::on_start take a mutable span #601

Merged
merged 2 commits into from
Jul 23, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion opentelemetry/src/sdk/trace/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mod tests {
}

impl SpanProcessor for TestSpanProcessor {
fn on_start(&self, _span: &Span, _cx: &Context) {
fn on_start(&self, _span: &mut Span, _cx: &Context) {
unimplemented!()
}

Expand Down
6 changes: 3 additions & 3 deletions opentelemetry/src/sdk/trace/span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
/// `on_start` is called when a `Span` is started. This method is called
/// synchronously on the thread that started the span, therefore it should
/// not block or throw exceptions.
fn on_start(&self, span: &Span, cx: &Context);
fn on_start(&self, span: &mut Span, cx: &Context);
/// `on_end` is called after a `Span` is ended (i.e., the end timestamp is
/// already set). This method is called synchronously within the `Span::end`
/// API, therefore it should not block or throw an exception.
Expand Down Expand Up @@ -139,7 +139,7 @@ impl SimpleSpanProcessor {
}

impl SpanProcessor for SimpleSpanProcessor {
fn on_start(&self, _span: &Span, _cx: &Context) {
fn on_start(&self, _span: &mut Span, _cx: &Context) {
// Ignored
}

Expand Down Expand Up @@ -239,7 +239,7 @@ impl<R: TraceRuntime> fmt::Debug for BatchSpanProcessor<R> {
}

impl<R: TraceRuntime> SpanProcessor for BatchSpanProcessor<R> {
fn on_start(&self, _span: &Span, _cx: &Context) {
fn on_start(&self, _span: &mut Span, _cx: &Context) {
// Ignored
}

Expand Down
4 changes: 2 additions & 2 deletions opentelemetry/src/sdk/trace/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ impl crate::trace::Tracer for Tracer {
});

let span_context = SpanContext::new(trace_id, span_id, flags, false, span_trace_state);
let span = Span::new(span_context, inner, self.clone(), span_limits);
let mut span = Span::new(span_context, inner, self.clone(), span_limits);

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

span
Expand Down