Skip to content

Commit

Permalink
Merge branch 'main' into zhongyang/close-sdk-APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyCpp authored May 28, 2024
2 parents 13bde88 + 0ce6a6d commit 2d64b24
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions opentelemetry-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
- Added `non_exhaustive` annotation to [`trace::Config`]. Marked [`config`] as deprecated since it's only a wrapper for `Config::default`
- Removed [`Tracer::tracer_provder`] and [`Tracer::instrument_libraries`] as it's not part of the spec.

- **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.

## v0.23.0

- Fix SimpleSpanProcessor to be consistent with log counterpart. Also removed
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/src/trace/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ mod tests {
}
}

fn shutdown(&mut self) -> TraceResult<()> {
fn shutdown(&self) -> TraceResult<()> {
self.force_flush()
}
}
Expand Down
16 changes: 8 additions & 8 deletions opentelemetry-sdk/src/trace/span_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub trait SpanProcessor: Send + Sync + std::fmt::Debug {
fn force_flush(&self) -> TraceResult<()>;
/// Shuts down the processor. Called when SDK is shut down. This is an
/// opportunity for processors to do any cleanup required.
fn shutdown(&mut self) -> TraceResult<()>;
fn shutdown(&self) -> TraceResult<()>;
}

/// A [SpanProcessor] that passes finished spans to the configured
Expand Down Expand Up @@ -137,7 +137,7 @@ impl SpanProcessor for SimpleSpanProcessor {
Ok(())
}

fn shutdown(&mut self) -> TraceResult<()> {
fn shutdown(&self) -> TraceResult<()> {
if let Ok(mut exporter) = self.exporter.lock() {
exporter.shutdown();
Ok(())
Expand Down Expand Up @@ -249,7 +249,7 @@ impl<R: RuntimeChannel> SpanProcessor for BatchSpanProcessor<R> {
.and_then(|identity| identity)
}

fn shutdown(&mut self) -> TraceResult<()> {
fn shutdown(&self) -> TraceResult<()> {
let (res_sender, res_receiver) = oneshot::channel();
self.message_sender
.try_send(BatchMessage::Shutdown(res_sender))
Expand Down Expand Up @@ -687,7 +687,7 @@ mod tests {
#[test]
fn simple_span_processor_on_end_calls_export() {
let exporter = InMemorySpanExporterBuilder::new().build();
let mut processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
let processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
let span_data = new_test_export_span_data();
processor.on_end(span_data.clone());
assert_eq!(exporter.get_finished_spans().unwrap()[0], span_data);
Expand Down Expand Up @@ -720,7 +720,7 @@ mod tests {
#[test]
fn simple_span_processor_shutdown_calls_shutdown() {
let exporter = InMemorySpanExporterBuilder::new().build();
let mut processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
let processor = SimpleSpanProcessor::new(Box::new(exporter.clone()));
let span_data = new_test_export_span_data();
processor.on_end(span_data.clone());
assert!(!exporter.get_finished_spans().unwrap().is_empty());
Expand Down Expand Up @@ -876,7 +876,7 @@ mod tests {
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
..Default::default()
};
let mut processor =
let processor =
BatchSpanProcessor::new(Box::new(exporter), config, runtime::TokioCurrentThread);
let handle = tokio::spawn(async move {
loop {
Expand Down Expand Up @@ -976,7 +976,7 @@ mod tests {
delay_for: Duration::from_millis(if !time_out { 5 } else { 60 }),
delay_fn: async_std::task::sleep,
};
let mut processor = BatchSpanProcessor::new(Box::new(exporter), config, runtime::AsyncStd);
let processor = BatchSpanProcessor::new(Box::new(exporter), config, runtime::AsyncStd);
processor.on_end(new_test_export_span_data());
let flush_res = processor.force_flush();
if time_out {
Expand All @@ -1000,7 +1000,7 @@ mod tests {
delay_for: Duration::from_millis(if !time_out { 5 } else { 60 }),
delay_fn: tokio::time::sleep,
};
let mut processor =
let processor =
BatchSpanProcessor::new(Box::new(exporter), config, runtime::TokioCurrentThread);
tokio::time::sleep(Duration::from_secs(1)).await; // skip the first
processor.on_end(new_test_export_span_data());
Expand Down
2 changes: 1 addition & 1 deletion stress/src/traces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl SpanProcessor for NoOpSpanProcessor {
Ok(())
}

fn shutdown(&mut self) -> TraceResult<()> {
fn shutdown(&self) -> TraceResult<()> {
Ok(())
}
}
Expand Down

0 comments on commit 2d64b24

Please sign in to comment.