11use core:: fmt;
2+ use opentelemetry:: {
3+ metrics:: { Meter , MeterProvider } ,
4+ otel_debug, otel_error, otel_info, InstrumentationScope ,
5+ } ;
6+ use std:: time:: Duration ;
27use std:: {
38 collections:: HashMap ,
49 sync:: {
@@ -7,11 +12,6 @@ use std::{
712 } ,
813} ;
914
10- use opentelemetry:: {
11- metrics:: { Meter , MeterProvider } ,
12- otel_debug, otel_error, otel_info, InstrumentationScope ,
13- } ;
14-
1515use crate :: error:: OTelSdkResult ;
1616use crate :: Resource ;
1717
@@ -109,13 +109,18 @@ impl SdkMeterProvider {
109109 ///
110110 /// There is no guaranteed that all telemetry be flushed or all resources have
111111 /// been released on error.
112- pub fn shutdown ( & self ) -> OTelSdkResult {
112+ pub fn shutdown_with_timeout ( & self , _timeout : Duration ) -> OTelSdkResult {
113113 otel_debug ! (
114114 name: "MeterProvider.Shutdown" ,
115115 message = "User initiated shutdown of MeterProvider."
116116 ) ;
117117 self . inner . shutdown ( )
118118 }
119+
120+ /// shutdown with default timeout
121+ pub fn shutdown ( & self ) -> OTelSdkResult {
122+ self . shutdown_with_timeout ( Duration :: from_secs ( 5 ) )
123+ }
119124}
120125
121126impl SdkMeterProviderInner {
@@ -130,7 +135,7 @@ impl SdkMeterProviderInner {
130135 }
131136 }
132137
133- fn shutdown ( & self ) -> OTelSdkResult {
138+ fn shutdown_with_timeout ( & self , _timeout : Duration ) -> OTelSdkResult {
134139 if self
135140 . shutdown_invoked
136141 . swap ( true , std:: sync:: atomic:: Ordering :: SeqCst )
@@ -141,6 +146,10 @@ impl SdkMeterProviderInner {
141146 self . pipes . shutdown ( )
142147 }
143148 }
149+
150+ fn shutdown ( & self ) -> OTelSdkResult {
151+ self . shutdown_with_timeout ( Duration :: from_secs ( 5 ) )
152+ }
144153}
145154
146155impl Drop for SdkMeterProviderInner {
0 commit comments