Skip to content

Commit 4f2b65a

Browse files
authored
Merge branch 'main' into http-json-example
2 parents 640b886 + 0ce6a6d commit 4f2b65a

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

opentelemetry-sdk/CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
asynchronously, it should clone the log data to ensure it can be safely processed without
2727
lifetime issues.
2828

29+
- **Breaking** [1836](https://github.com/open-telemetry/opentelemetry-rust/pull/1836) `SpanProcessor::shutdown` now takes an immutable reference to self. Any reference can call shutdown on the processor. After the first call to `shutdown` the processor will not process any new spans.
30+
2931
## v0.23.0
3032

3133
- Fix SimpleSpanProcessor to be consistent with log counterpart. Also removed

opentelemetry-sdk/src/trace/provider.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ mod tests {
264264
}
265265
}
266266

267-
fn shutdown(&mut self) -> TraceResult<()> {
267+
fn shutdown(&self) -> TraceResult<()> {
268268
self.force_flush()
269269
}
270270
}

opentelemetry-sdk/src/trace/span_processor.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
9191
fn force_flush(&self) -> TraceResult<()>;
9292
/// Shuts down the processor. Called when SDK is shut down. This is an
9393
/// opportunity for processors to do any cleanup required.
94-
fn shutdown(&mut self) -> TraceResult<()>;
94+
fn shutdown(&self) -> TraceResult<()>;
9595
}
9696

9797
/// A [SpanProcessor] that passes finished spans to the configured
@@ -137,7 +137,7 @@ impl SpanProcessor for SimpleSpanProcessor {
137137
Ok(())
138138
}
139139

140-
fn shutdown(&mut self) -> TraceResult<()> {
140+
fn shutdown(&self) -> TraceResult<()> {
141141
if let Ok(mut exporter) = self.exporter.lock() {
142142
exporter.shutdown();
143143
Ok(())
@@ -249,7 +249,7 @@ impl<R: RuntimeChannel> SpanProcessor for BatchSpanProcessor<R> {
249249
.and_then(|identity| identity)
250250
}
251251

252-
fn shutdown(&mut self) -> TraceResult<()> {
252+
fn shutdown(&self) -> TraceResult<()> {
253253
let (res_sender, res_receiver) = oneshot::channel();
254254
self.message_sender
255255
.try_send(BatchMessage::Shutdown(res_sender))
@@ -687,7 +687,7 @@ mod tests {
687687
#[test]
688688
fn simple_span_processor_on_end_calls_export() {
689689
let exporter = InMemorySpanExporterBuilder::new().build();
690-
let mut processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
690+
let processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
691691
let span_data = new_test_export_span_data();
692692
processor.on_end(span_data.clone());
693693
assert_eq!(exporter.get_finished_spans().unwrap()[0], span_data);
@@ -720,7 +720,7 @@ mod tests {
720720
#[test]
721721
fn simple_span_processor_shutdown_calls_shutdown() {
722722
let exporter = InMemorySpanExporterBuilder::new().build();
723-
let mut processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
723+
let processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
724724
let span_data = new_test_export_span_data();
725725
processor.on_end(span_data.clone());
726726
assert!(!exporter.get_finished_spans().unwrap().is_empty());
@@ -876,7 +876,7 @@ mod tests {
876876
scheduled_delay: Duration::from_secs(60 * 60 * 24), // set the tick to 24 hours so we know the span must be exported via force_flush
877877
..Default::default()
878878
};
879-
let mut processor =
879+
let processor =
880880
BatchSpanProcessor::new(Box::new(exporter), config, runtime::TokioCurrentThread);
881881
let handle = tokio::spawn(async move {
882882
loop {
@@ -976,7 +976,7 @@ mod tests {
976976
delay_for: Duration::from_millis(if !time_out { 5 } else { 60 }),
977977
delay_fn: async_std::task::sleep,
978978
};
979-
let mut processor = BatchSpanProcessor::new(Box::new(exporter), config, runtime::AsyncStd);
979+
let processor = BatchSpanProcessor::new(Box::new(exporter), config, runtime::AsyncStd);
980980
processor.on_end(new_test_export_span_data());
981981
let flush_res = processor.force_flush();
982982
if time_out {
@@ -1000,7 +1000,7 @@ mod tests {
10001000
delay_for: Duration::from_millis(if !time_out { 5 } else { 60 }),
10011001
delay_fn: tokio::time::sleep,
10021002
};
1003-
let mut processor =
1003+
let processor =
10041004
BatchSpanProcessor::new(Box::new(exporter), config, runtime::TokioCurrentThread);
10051005
tokio::time::sleep(Duration::from_secs(1)).await; // skip the first
10061006
processor.on_end(new_test_export_span_data());

stress/src/traces.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl SpanProcessor for NoOpSpanProcessor {
4242
Ok(())
4343
}
4444

45-
fn shutdown(&mut self) -> TraceResult<()> {
45+
fn shutdown(&self) -> TraceResult<()> {
4646
Ok(())
4747
}
4848
}

0 commit comments

Comments
 (0)