@@ -756,7 +756,7 @@ mod tests {
756756 use opentelemetry:: logs:: LogRecord ;
757757 use opentelemetry:: InstrumentationScope ;
758758 use opentelemetry:: KeyValue ;
759- use std:: sync:: atomic:: { AtomicUsize , Ordering } ;
759+ use std:: sync:: atomic:: { AtomicBool , AtomicUsize , Ordering } ;
760760 use std:: sync:: { Arc , Mutex } ;
761761 use std:: time:: Duration ;
762762
@@ -839,6 +839,29 @@ mod tests {
839839 assert_eq ! ( config. max_queue_size, 4096 ) ;
840840 assert_eq ! ( config. max_export_batch_size, 1024 ) ;
841841 }
842+ #[ test]
843+ fn test_force_flush_being_called ( ) {
844+ #[ derive( Debug , Clone ) ]
845+ struct MockExporter {
846+ export_called : Arc < AtomicBool > ,
847+ }
848+ impl LogExporter for MockExporter {
849+ async fn export ( & self , _batch : LogBatch < ' _ > ) -> OTelSdkResult {
850+ self . export_called . store ( true , Ordering :: SeqCst ) ;
851+ Ok ( ( ) )
852+ }
853+ }
854+ let exporter = MockExporter {
855+ export_called : Arc :: new ( AtomicBool :: new ( false ) ) ,
856+ } ;
857+ let processor = BatchLogProcessor :: new ( exporter. clone ( ) , BatchConfig :: default ( ) ) ;
858+ let scope = opentelemetry:: InstrumentationScope :: builder ( "my-crate" )
859+ . with_schema_url ( "https://opentelemetry.io/schemas/1.17.0" )
860+ . build ( ) ;
861+ processor. emit ( & mut SdkLogRecord :: new ( ) , & scope) ;
862+ processor. force_flush ( ) . unwrap ( ) ;
863+ assert ! ( exporter. export_called. load( Ordering :: SeqCst ) ) ;
864+ }
842865
843866 #[ test]
844867 fn test_batch_config_max_export_batch_size_validation ( ) {
0 commit comments