diff --git a/opentelemetry-sdk/src/metrics/meter_provider.rs b/opentelemetry-sdk/src/metrics/meter_provider.rs index 591be34165..c91773434b 100644 --- a/opentelemetry-sdk/src/metrics/meter_provider.rs +++ b/opentelemetry-sdk/src/metrics/meter_provider.rs @@ -8,9 +8,8 @@ use std::{ }; use opentelemetry::{ - global, metrics::{Meter, MeterProvider, MetricsError, Result}, - KeyValue, + otel_debug, otel_error, KeyValue, }; use crate::{instrumentation::Scope, Resource}; @@ -137,13 +136,21 @@ impl Drop for SdkMeterProviderInner { fn drop(&mut self) { // If user has already shutdown the provider manually by calling // shutdown(), then we don't need to call shutdown again. - if !self.is_shutdown.load(Ordering::Relaxed) { - if let Err(err) = self.shutdown() { - global::handle_error(err); - } + if self.is_shutdown.load(Ordering::Relaxed) { + otel_debug!( + name: "MeterProvider.AlreadyShutdown", + message = "Meter provider was already shut down; drop will not attempt shutdown again." + ); + } else if let Err(err) = self.shutdown() { + otel_error!( + name: "MeterProvider.ShutdownFailed", + message = "Shutdown attempt failed during drop of MeterProvider.", + reason = format!("{}", err) + ); } } } + impl MeterProvider for SdkMeterProvider { fn versioned_meter( &self,