Skip to content

Commit

Permalink
Make SpanProcessor::on_start take a mutable span (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramosbugs committed Jul 23, 2021
1 parent 197c388 commit 7037f71
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
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

0 comments on commit 7037f71

Please sign in to comment.