Skip to content

Commit

Permalink
Catch missing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
scottgerring committed Dec 24, 2024
1 parent 26bbdc4 commit de49068
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
13 changes: 10 additions & 3 deletions opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,12 @@ impl<R: RuntimeChannel> BatchLogProcessor<R> {
)
.await;

exporter.shutdown();
if let Err(shutdown_error) = exporter.shutdown() {
otel_debug!(

Check warning on line 192 in opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs#L192

Added line #L192 was not covered by tests
name: "BatchLogProcessor.Shutdown.Error",
error = format!("{}", shutdown_error),

Check warning on line 194 in opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/logs/log_processor_with_async_runtime.rs#L194

Added line #L194 was not covered by tests
);
}

if let Err(send_error) = ch.send(result) {
otel_debug!(
Expand Down Expand Up @@ -282,7 +287,7 @@ where

#[cfg(all(test, feature = "testing", feature = "logs"))]
mod tests {
use crate::export::logs::{LogBatch, LogExporter};
use crate::export::logs::{LogBatch, LogExporter, ShutdownResult};
use crate::logs::log_processor::{
OTEL_BLRP_EXPORT_TIMEOUT, OTEL_BLRP_MAX_EXPORT_BATCH_SIZE, OTEL_BLRP_MAX_QUEUE_SIZE,
OTEL_BLRP_SCHEDULE_DELAY,
Expand Down Expand Up @@ -325,7 +330,9 @@ mod tests {
async { Ok(()) }
}

fn shutdown(&mut self) {}
fn shutdown(&mut self) -> ShutdownResult {
Ok(())
}

fn set_resource(&mut self, resource: &Resource) {
self.resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,12 @@ impl<R: RuntimeChannel> BatchSpanProcessorInternal<R> {
// Stream has terminated or processor is shutdown, return to finish execution.
BatchMessage::Shutdown(ch) => {
self.flush(Some(ch)).await;
self.exporter.shutdown();
if let Err(shutdown_error) = self.exporter.shutdown() {
otel_debug!(

Check warning on line 291 in opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs#L291

Added line #L291 was not covered by tests
name: "BatchSpanProcessor.ShutdownError",
msg = format!("{:?}", shutdown_error)

Check warning on line 293 in opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-sdk/src/trace/span_processor_with_async_runtime.rs#L293

Added line #L293 was not covered by tests
);
}
return false;
}
// propagate the resource
Expand Down

0 comments on commit de49068

Please sign in to comment.