@@ -46,7 +46,11 @@ fn init_logs(is_simple: bool) -> Result<sdklogs::LoggerProvider> {
4646 Ok ( logger_provider)
4747}
4848
49- async fn logs_tokio_helper ( is_simple : bool , log_send_outside_rt : bool ) -> Result < ( ) > {
49+ async fn logs_tokio_helper (
50+ is_simple : bool ,
51+ log_send_outside_rt : bool ,
52+ current_thread : bool ,
53+ ) -> Result < ( ) > {
5054 use crate :: { assert_logs_results_contains, init_logs} ;
5155 test_utils:: start_collector_container ( ) . await ?;
5256
@@ -76,7 +80,14 @@ async fn logs_tokio_helper(is_simple: bool, log_send_outside_rt: bool) -> Result
7680 info ! ( target: "my-target" , uuid = expected_uuid. as_str( ) , "hello from {}. My price is {}." , "banana" , 2.99 ) ;
7781 }
7882 }
79- let _ = logger_provider. shutdown ( ) ;
83+ if current_thread {
84+ let _res = tokio:: runtime:: Handle :: current ( )
85+ . spawn_blocking ( move || logger_provider. shutdown ( ) )
86+ . await
87+ . unwrap ( ) ;
88+ } else {
89+ let _ = logger_provider. shutdown ( ) ;
90+ }
8091 tokio:: time:: sleep ( Duration :: from_secs ( 5 ) ) . await ;
8192 assert_logs_results_contains ( test_utils:: LOGS_FILE , expected_uuid. as_str ( ) ) ?;
8293 Ok ( ( ) )
@@ -175,7 +186,7 @@ mod logtests {
175186 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 4 ) ]
176187 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
177188 pub async fn logs_batch_tokio_multi_thread ( ) -> Result < ( ) > {
178- logs_tokio_helper ( false , false ) . await
189+ logs_tokio_helper ( false , false , false ) . await
179190 }
180191
181192 // logger initialization - Inside RT
@@ -185,7 +196,7 @@ mod logtests {
185196 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
186197 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
187198 pub async fn logs_batch_tokio_multi_with_one_worker ( ) -> Result < ( ) > {
188- logs_tokio_helper ( false , false ) . await
199+ logs_tokio_helper ( false , false , false ) . await
189200 }
190201
191202 // logger initialization - Inside RT
@@ -195,7 +206,7 @@ mod logtests {
195206 #[ tokio:: test( flavor = "current_thread" ) ]
196207 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
197208 pub async fn logs_batch_tokio_current ( ) -> Result < ( ) > {
198- logs_tokio_helper ( false , false ) . await
209+ logs_tokio_helper ( false , false , true ) . await
199210 }
200211
201212 // logger initialization - Inside RT
@@ -205,7 +216,7 @@ mod logtests {
205216 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 4 ) ]
206217 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
207218 pub async fn logs_batch_tokio_log_outside_rt_multi_thread ( ) -> Result < ( ) > {
208- logs_tokio_helper ( false , true ) . await
219+ logs_tokio_helper ( false , true , false ) . await
209220 }
210221
211222 // logger initialization - Inside RT
@@ -215,7 +226,7 @@ mod logtests {
215226 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
216227 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
217228 pub async fn logs_batch_tokio_log_outside_rt_multi_with_one_worker ( ) -> Result < ( ) > {
218- logs_tokio_helper ( false , true ) . await
229+ logs_tokio_helper ( false , true , false ) . await
219230 }
220231
221232 // logger initialization - Inside RT
@@ -225,7 +236,7 @@ mod logtests {
225236 #[ tokio:: test( flavor = "current_thread" ) ]
226237 #[ cfg( any( feature = "tonic-client" , feature = "reqwest-blocking-client" ) ) ]
227238 pub async fn logs_batch_tokio_log_outside_rt_current_thread ( ) -> Result < ( ) > {
228- logs_tokio_helper ( false , true ) . await
239+ logs_tokio_helper ( false , true , true ) . await
229240 }
230241
231242 // logger initialization - Inside RT
@@ -310,7 +321,7 @@ mod logtests {
310321 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 4 ) ]
311322 #[ cfg( feature = "reqwest-blocking-client" ) ]
312323 pub async fn logs_simple_tokio_multi_thread ( ) -> Result < ( ) > {
313- logs_tokio_helper ( true , false ) . await
324+ logs_tokio_helper ( true , false , false ) . await
314325 }
315326
316327 // logger initialization - Inside RT
@@ -324,7 +335,7 @@ mod logtests {
324335 feature = "hyper-client"
325336 ) ) ]
326337 pub async fn logs_simple_tokio_multi_thread ( ) -> Result < ( ) > {
327- logs_tokio_helper ( true , false ) . await
338+ logs_tokio_helper ( true , false , false ) . await
328339 }
329340
330341 // logger initialization - Inside RT
@@ -338,7 +349,7 @@ mod logtests {
338349 feature = "hyper-client"
339350 ) ) ]
340351 pub async fn logs_simple_tokio_multi_with_one_worker ( ) -> Result < ( ) > {
341- logs_tokio_helper ( true , false ) . await
352+ logs_tokio_helper ( true , false , false ) . await
342353 }
343354
344355 // logger initialization - Inside RT
@@ -353,7 +364,7 @@ mod logtests {
353364 feature = "hyper-client"
354365 ) ) ]
355366 pub async fn logs_simple_tokio_current ( ) -> Result < ( ) > {
356- logs_tokio_helper ( true , false ) . await
367+ logs_tokio_helper ( true , false , false ) . await
357368 }
358369}
359370///
0 commit comments