@@ -555,6 +555,7 @@ mod tests {
555555 use opentelemetry:: { logs:: LogResult , KeyValue } ;
556556 use std:: sync:: { Arc , Mutex } ;
557557 use std:: time:: Duration ;
558+ //use num_cpus;
558559
559560 #[ derive( Debug , Clone ) ]
560561 struct MockLogExporter {
@@ -1159,16 +1160,21 @@ mod tests {
11591160 assert_eq ! ( exporter. len( ) . await , 1 ) ;
11601161 }
11611162
1162- #[ tokio:: test( flavor = "multi_thread" ) ]
1163- async fn test_simple_processor_async_exporter_with_multi_thread_runtime ( ) {
1163+ #[ tokio:: test( flavor = "multi_thread" , worker_threads = 4 ) ]
1164+ #[ ignore]
1165+ // all threads are blocked running blocked::export(), and the exporter further needs tokio
1166+ // runtime to progress on this blocked thread, resulting in deadlock.
1167+ async fn test_simple_processor_async_exporter_with_multi_thread_runtime_all_cores_blocked ( ) {
11641168 let exporter = LogExporterThatRequiresTokioSpawn :: new ( ) ;
11651169 let processor = Arc :: new ( Mutex :: new ( SimpleLogProcessor :: new ( Box :: new (
11661170 exporter. clone ( ) ,
11671171 ) ) ) ) ;
11681172
1173+ let concurrent_emit = 5 ; // number of worker sthreads + 1
1174+
11691175 let mut handles = vec ! [ ] ;
1170- // send 4 events concurrently
1171- for _ in 0 ..4 {
1176+ // send 2 events concurrently
1177+ for _ in 0 ..concurrent_emit {
11721178 let processor_clone = Arc :: clone ( & processor) ;
11731179 let handle = tokio:: spawn ( async move {
11741180 let mut record: LogRecord = Default :: default ( ) ;
@@ -1184,7 +1190,21 @@ mod tests {
11841190 for handle in handles {
11851191 handle. await . unwrap ( ) ;
11861192 }
1187- assert_eq ! ( exporter. len( ) . await , 4 ) ;
1193+ assert_eq ! ( exporter. len( ) . await , 2 ) ;
1194+ }
1195+
1196+ #[ tokio:: test( flavor = "multi_thread" ) ]
1197+ async fn test_simple_processor_async_exporter_with_multi_thread_runtime ( ) {
1198+ let exporter = LogExporterThatRequiresTokioSpawn :: new ( ) ;
1199+
1200+ let processor = SimpleLogProcessor :: new ( Box :: new ( exporter. clone ( ) ) ) ;
1201+
1202+ let mut record: LogRecord = Default :: default ( ) ;
1203+ let instrumentation: InstrumentationLibrary = Default :: default ( ) ;
1204+
1205+ processor. emit ( & mut record, & instrumentation) ;
1206+
1207+ assert_eq ! ( exporter. len( ) . await , 1 ) ;
11881208 }
11891209
11901210 #[ tokio:: test( flavor = "current_thread" ) ]
0 commit comments