@@ -132,7 +132,6 @@ pub struct BatchLogProcessor {
132132 message_sender : SyncSender < BatchMessage > , // Control channel to store control messages for the worker thread
133133 handle : Mutex < Option < thread:: JoinHandle < ( ) > > > ,
134134 forceflush_timeout : Duration ,
135- shutdown_timeout : Duration ,
136135 export_log_message_sent : Arc < AtomicBool > ,
137136 current_batch_size : Arc < AtomicUsize > ,
138137 max_export_batch_size : usize ,
@@ -256,7 +255,7 @@ impl LogProcessor for BatchLogProcessor {
256255 }
257256 }
258257
259- fn shutdown ( & self ) -> OTelSdkResult {
258+ fn shutdown ( & self , timeout : Duration ) -> OTelSdkResult {
260259 let dropped_logs = self . dropped_logs_count . load ( Ordering :: Relaxed ) ;
261260 let max_queue_size = self . max_queue_size ;
262261 if dropped_logs > 0 {
@@ -272,7 +271,7 @@ impl LogProcessor for BatchLogProcessor {
272271 match self . message_sender . try_send ( BatchMessage :: Shutdown ( sender) ) {
273272 Ok ( _) => {
274273 receiver
275- . recv_timeout ( self . shutdown_timeout )
274+ . recv_timeout ( timeout )
276275 . map ( |_| {
277276 // join the background thread after receiving back the
278277 // shutdown signal
@@ -287,7 +286,7 @@ impl LogProcessor for BatchLogProcessor {
287286 name: "BatchLogProcessor.Shutdown.Timeout" ,
288287 message = "BatchLogProcessor shutdown timing out."
289288 ) ;
290- OTelSdkError :: Timeout ( self . shutdown_timeout )
289+ OTelSdkError :: Timeout ( timeout )
291290 }
292291 _ => {
293292 otel_error ! (
@@ -436,7 +435,7 @@ impl BatchLogProcessor {
436435 & current_batch_size,
437436 & config,
438437 ) ;
439- let _ = exporter. shutdown ( ) ;
438+ let _ = exporter. shutdown ( Duration :: from_secs ( 5 ) ) ;
440439 let _ = sender. send ( result) ;
441440
442441 otel_debug ! (
@@ -488,7 +487,6 @@ impl BatchLogProcessor {
488487 message_sender,
489488 handle : Mutex :: new ( Some ( handle) ) ,
490489 forceflush_timeout : Duration :: from_secs ( 5 ) , // TODO: make this configurable
491- shutdown_timeout : Duration :: from_secs ( 5 ) , // TODO: make this configurable
492490 dropped_logs_count : AtomicUsize :: new ( 0 ) ,
493491 max_queue_size,
494492 export_log_message_sent : Arc :: new ( AtomicBool :: new ( false ) ) ,
@@ -922,7 +920,7 @@ mod tests {
922920
923921 processor. emit ( & mut record, & instrumentation) ;
924922 processor. force_flush ( ) . unwrap ( ) ;
925- processor. shutdown ( ) . unwrap ( ) ;
923+ processor. shutdown ( Duration :: from_secs ( 5 ) ) . unwrap ( ) ;
926924 // todo: expect to see errors here. How should we assert this?
927925 processor. emit ( & mut record, & instrumentation) ;
928926 assert_eq ! ( 1 , exporter. get_emitted_logs( ) . unwrap( ) . len( ) ) ;
@@ -934,27 +932,27 @@ mod tests {
934932 let exporter = InMemoryLogExporterBuilder :: default ( ) . build ( ) ;
935933 let processor = BatchLogProcessor :: new ( exporter. clone ( ) , BatchConfig :: default ( ) ) ;
936934
937- processor. shutdown ( ) . unwrap ( ) ;
935+ processor. shutdown ( Duration :: from_secs ( 5 ) ) . unwrap ( ) ;
938936 }
939937
940938 #[ tokio:: test( flavor = "current_thread" ) ]
941939 async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_current_thread ( ) {
942940 let exporter = InMemoryLogExporterBuilder :: default ( ) . build ( ) ;
943941 let processor = BatchLogProcessor :: new ( exporter. clone ( ) , BatchConfig :: default ( ) ) ;
944- processor. shutdown ( ) . unwrap ( ) ;
942+ processor. shutdown ( Duration :: from_secs ( 5 ) ) . unwrap ( ) ;
945943 }
946944
947945 #[ tokio:: test( flavor = "multi_thread" ) ]
948946 async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_multi_thread ( ) {
949947 let exporter = InMemoryLogExporterBuilder :: default ( ) . build ( ) ;
950948 let processor = BatchLogProcessor :: new ( exporter. clone ( ) , BatchConfig :: default ( ) ) ;
951- processor. shutdown ( ) . unwrap ( ) ;
949+ processor. shutdown ( Duration :: from_secs ( 5 ) ) . unwrap ( ) ;
952950 }
953951
954952 #[ tokio:: test( flavor = "multi_thread" ) ]
955953 async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_current_thread ( ) {
956954 let exporter = InMemoryLogExporterBuilder :: default ( ) . build ( ) ;
957955 let processor = BatchLogProcessor :: new ( exporter. clone ( ) , BatchConfig :: default ( ) ) ;
958- processor. shutdown ( ) . unwrap ( ) ;
956+ processor. shutdown ( Duration :: from_secs ( 5 ) ) . unwrap ( ) ;
959957 }
960958}
0 commit comments