@@ -96,7 +96,6 @@ impl SimpleLogProcessor {
9696
9797impl LogProcessor for SimpleLogProcessor {
9898 fn emit ( & self , record : & mut LogRecord , instrumentation : & InstrumentationLibrary ) {
99- println ! ( "SimpleLogProcessor::Emit" ) ;
10099 // noop after shutdown
101100 if self . is_shutdown . load ( std:: sync:: atomic:: Ordering :: Relaxed ) {
102101 // this is a warning, as the user is trying to log after the processor has been shutdown
@@ -835,9 +834,7 @@ mod tests {
835834 #[ tokio:: test( flavor = "current_thread" ) ]
836835 #[ ignore = "See issue https://github.com/open-telemetry/opentelemetry-rust/issues/1968" ]
837836 async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_multi_thread ( ) {
838- let exporter = InMemoryLogsExporterBuilder :: default ( )
839- . keep_records_on_shutdown ( )
840- . build ( ) ;
837+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
841838 let processor = BatchLogProcessor :: new (
842839 Box :: new ( exporter. clone ( ) ) ,
843840 BatchConfig :: default ( ) ,
@@ -852,9 +849,7 @@ mod tests {
852849
853850 #[ tokio:: test( flavor = "current_thread" ) ]
854851 async fn test_batch_log_processor_shutdown_with_async_runtime_current_flavor_current_thread ( ) {
855- let exporter = InMemoryLogsExporterBuilder :: default ( )
856- . keep_records_on_shutdown ( )
857- . build ( ) ;
852+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
858853 let processor = BatchLogProcessor :: new (
859854 Box :: new ( exporter. clone ( ) ) ,
860855 BatchConfig :: default ( ) ,
@@ -866,9 +861,7 @@ mod tests {
866861
867862 #[ tokio:: test( flavor = "multi_thread" ) ]
868863 async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_multi_thread ( ) {
869- let exporter = InMemoryLogsExporterBuilder :: default ( )
870- . keep_records_on_shutdown ( )
871- . build ( ) ;
864+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
872865 let processor = BatchLogProcessor :: new (
873866 Box :: new ( exporter. clone ( ) ) ,
874867 BatchConfig :: default ( ) ,
@@ -880,9 +873,7 @@ mod tests {
880873
881874 #[ tokio:: test( flavor = "multi_thread" ) ]
882875 async fn test_batch_log_processor_shutdown_with_async_runtime_multi_flavor_current_thread ( ) {
883- let exporter = InMemoryLogsExporterBuilder :: default ( )
884- . keep_records_on_shutdown ( )
885- . build ( ) ;
876+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
886877 let processor = BatchLogProcessor :: new (
887878 Box :: new ( exporter. clone ( ) ) ,
888879 BatchConfig :: default ( ) ,
@@ -1001,9 +992,7 @@ mod tests {
1001992
1002993 #[ test]
1003994 fn test_simple_processor_sync_exporter_without_runtime ( ) {
1004- let exporter = InMemoryLogsExporterBuilder :: default ( )
1005- . keep_records_on_shutdown ( )
1006- . build ( ) ;
995+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
1007996 let processor = SimpleLogProcessor :: new ( Box :: new ( exporter. clone ( ) ) ) ;
1008997
1009998 let mut record: LogRecord = Default :: default ( ) ;
@@ -1016,9 +1005,7 @@ mod tests {
10161005
10171006 #[ tokio:: test( flavor = "multi_thread" , worker_threads = 1 ) ]
10181007 async fn test_simple_processor_sync_exporter_with_runtime ( ) {
1019- let exporter = InMemoryLogsExporterBuilder :: default ( )
1020- . keep_records_on_shutdown ( )
1021- . build ( ) ;
1008+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
10221009 let processor = SimpleLogProcessor :: new ( Box :: new ( exporter. clone ( ) ) ) ;
10231010
10241011 let mut record: LogRecord = Default :: default ( ) ;
@@ -1031,9 +1018,7 @@ mod tests {
10311018
10321019 #[ tokio:: test( flavor = "multi_thread" ) ]
10331020 async fn test_simple_processor_sync_exporter_with_multi_thread_runtime ( ) {
1034- let exporter = InMemoryLogsExporterBuilder :: default ( )
1035- . keep_records_on_shutdown ( )
1036- . build ( ) ;
1021+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
10371022 let processor = Arc :: new ( Mutex :: new ( SimpleLogProcessor :: new ( Box :: new (
10381023 exporter. clone ( ) ,
10391024 ) ) ) ) ;
@@ -1061,9 +1046,7 @@ mod tests {
10611046
10621047 #[ tokio:: test( flavor = "current_thread" ) ]
10631048 async fn test_simple_processor_sync_exporter_with_current_thread_runtime ( ) {
1064- let exporter = InMemoryLogsExporterBuilder :: default ( )
1065- . keep_records_on_shutdown ( )
1066- . build ( ) ;
1049+ let exporter = InMemoryLogsExporterBuilder :: default ( ) . build ( ) ;
10671050 let processor = SimpleLogProcessor :: new ( Box :: new ( exporter. clone ( ) ) ) ;
10681051
10691052 let mut record: LogRecord = Default :: default ( ) ;
@@ -1076,20 +1059,20 @@ mod tests {
10761059
10771060 #[ derive( Debug , Clone ) ]
10781061 struct LogExporterThatRequiresTokio {
1079- event_count : Arc < AtomicU32 > ,
1062+ export_count : Arc < AtomicU32 > ,
10801063 }
10811064
10821065 impl LogExporterThatRequiresTokio {
10831066 /// Creates a new instance of `LogExporterThatRequiresTokio`.
10841067 fn new ( ) -> Self {
10851068 LogExporterThatRequiresTokio {
1086- event_count : Arc :: new ( AtomicU32 :: new ( 0 ) ) ,
1069+ export_count : Arc :: new ( AtomicU32 :: new ( 0 ) ) ,
10871070 }
10881071 }
10891072
10901073 /// Returns the number of logs stored in the exporter.
10911074 fn len ( & self ) -> usize {
1092- self . event_count . load ( Ordering :: Acquire ) as usize
1075+ self . export_count . load ( Ordering :: Acquire ) as usize
10931076 }
10941077 }
10951078
@@ -1100,7 +1083,7 @@ mod tests {
11001083 tokio:: time:: sleep ( Duration :: from_millis ( 50 ) ) . await ;
11011084
11021085 for _ in batch. iter ( ) {
1103- self . event_count . fetch_add ( 1 , Ordering :: Acquire ) ;
1086+ self . export_count . fetch_add ( 1 , Ordering :: Acquire ) ;
11041087 }
11051088 Ok ( ( ) )
11061089 }
@@ -1144,8 +1127,8 @@ mod tests {
11441127 #[ ignore]
11451128 // This test demonstrates a potential deadlock scenario in a multi-threaded Tokio runtime.
11461129 // It spawns Tokio tasks equal to the number of runtime worker threads (4) to emit log events.
1147- // Each task attempts to acquire a mutex on the SimpleLogProcessor. Only one task obtains the lock,
1148- // while the others are blocked, waiting for its release.
1130+ // Each task attempts to acquire a mutex on the exporter in `SimpleLogProcessor::emit`.
1131+ // Only one task obtains the lock, while the others are blocked, waiting for its release.
11491132 //
11501133 // The task holding the lock invokes the LogExporterThatRequiresTokio, which performs an
11511134 // asynchronous operation (e.g., network I/O simulated by `tokio::sleep`). This operation
@@ -1160,9 +1143,7 @@ mod tests {
11601143 // tasks nor the exporter can proceed.
11611144 async fn test_simple_processor_async_exporter_with_all_runtime_worker_threads_blocked ( ) {
11621145 let exporter = LogExporterThatRequiresTokio :: new ( ) ;
1163- let processor = Arc :: new ( Mutex :: new ( SimpleLogProcessor :: new ( Box :: new (
1164- exporter. clone ( ) ,
1165- ) ) ) ) ;
1146+ let processor = Arc :: new ( SimpleLogProcessor :: new ( Box :: new ( exporter. clone ( ) ) ) ) ;
11661147
11671148 let concurrent_emit = 4 ; // number of worker threads
11681149
@@ -1173,10 +1154,7 @@ mod tests {
11731154 let handle = tokio:: spawn ( async move {
11741155 let mut record: LogRecord = Default :: default ( ) ;
11751156 let instrumentation: InstrumentationLibrary = Default :: default ( ) ;
1176- processor_clone
1177- . lock ( )
1178- . unwrap ( )
1179- . emit ( & mut record, & instrumentation) ;
1157+ processor_clone. emit ( & mut record, & instrumentation) ;
11801158 } ) ;
11811159 handles. push ( handle) ;
11821160 }
0 commit comments