@@ -57,8 +57,10 @@ pub(crate) const OTEL_BLRP_SCHEDULE_DELAY: &str = "OTEL_BLRP_SCHEDULE_DELAY";
57
57
/// Default delay interval between two consecutive exports.
58
58
pub ( crate ) const OTEL_BLRP_SCHEDULE_DELAY_DEFAULT : u64 = 1_000 ;
59
59
/// Maximum allowed time to export data.
60
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
60
61
pub ( crate ) const OTEL_BLRP_EXPORT_TIMEOUT : & str = "OTEL_BLRP_EXPORT_TIMEOUT" ;
61
62
/// Default maximum allowed time to export data.
63
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
62
64
pub ( crate ) const OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT : u64 = 30_000 ;
63
65
/// Maximum queue size.
64
66
pub ( crate ) const OTEL_BLRP_MAX_QUEUE_SIZE : & str = "OTEL_BLRP_MAX_QUEUE_SIZE" ;
@@ -229,7 +231,6 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>;
229
231
/// - This processor supports the following configurations:
230
232
/// - **Queue size**: Maximum number of log records that can be buffered.
231
233
/// - **Batch size**: Maximum number of log records to include in a single export.
232
- /// - **Export timeout**: Maximum duration allowed for an export operation.
233
234
/// - **Scheduled delay**: Frequency at which the batch is exported.
234
235
///
235
236
/// When using this processor with the OTLP Exporter, the following exporter
@@ -255,7 +256,6 @@ type LogsData = Box<(LogRecord, InstrumentationScope)>;
255
256
/// .with_max_queue_size(2048)
256
257
/// .with_max_export_batch_size(512)
257
258
/// .with_scheduled_delay(Duration::from_secs(5))
258
- /// .with_max_export_timeout(Duration::from_secs(30))
259
259
/// .build(),
260
260
/// )
261
261
/// .build();
@@ -525,12 +525,7 @@ impl BatchLogProcessor {
525
525
let count_of_logs = logs. len ( ) ; // Count of logs that will be exported
526
526
total_exported_logs += count_of_logs;
527
527
528
- result = export_with_timeout_sync (
529
- config. max_export_timeout ,
530
- exporter,
531
- logs,
532
- last_export_time,
533
- ) ; // This method clears the logs vec after exporting
528
+ result = export_batch_sync ( exporter, logs, last_export_time) ; // This method clears the logs vec after exporting
534
529
535
530
current_batch_size. fetch_sub ( count_of_logs, Ordering :: Relaxed ) ;
536
531
}
@@ -656,8 +651,7 @@ impl BatchLogProcessor {
656
651
}
657
652
658
653
#[ allow( clippy:: vec_box) ]
659
- fn export_with_timeout_sync < E > (
660
- _: Duration , // TODO, enforcing timeout in exporter.
654
+ fn export_batch_sync < E > (
661
655
exporter : & E ,
662
656
batch : & mut Vec < Box < ( LogRecord , InstrumentationScope ) > > ,
663
657
last_export_time : & mut Instant ,
@@ -733,6 +727,7 @@ pub struct BatchConfig {
733
727
pub ( crate ) max_export_batch_size : usize ,
734
728
735
729
/// The maximum duration to export a batch of data.
730
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
736
731
pub ( crate ) max_export_timeout : Duration ,
737
732
}
738
733
@@ -748,6 +743,7 @@ pub struct BatchConfigBuilder {
748
743
max_queue_size : usize ,
749
744
scheduled_delay : Duration ,
750
745
max_export_batch_size : usize ,
746
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
751
747
max_export_timeout : Duration ,
752
748
}
753
749
@@ -764,6 +760,7 @@ impl Default for BatchConfigBuilder {
764
760
max_queue_size : OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT ,
765
761
scheduled_delay : Duration :: from_millis ( OTEL_BLRP_SCHEDULE_DELAY_DEFAULT ) ,
766
762
max_export_batch_size : OTEL_BLRP_MAX_EXPORT_BATCH_SIZE_DEFAULT ,
763
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
767
764
max_export_timeout : Duration :: from_millis ( OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT ) ,
768
765
}
769
766
. init_from_env_vars ( )
@@ -791,6 +788,7 @@ impl BatchConfigBuilder {
791
788
/// Set max_export_timeout for [`BatchConfigBuilder`].
792
789
/// It's the maximum duration to export a batch of data.
793
790
/// The default value is 30000 milliseconds.
791
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
794
792
pub fn with_max_export_timeout ( mut self , max_export_timeout : Duration ) -> Self {
795
793
self . max_export_timeout = max_export_timeout;
796
794
self
@@ -816,6 +814,7 @@ impl BatchConfigBuilder {
816
814
BatchConfig {
817
815
max_queue_size : self . max_queue_size ,
818
816
scheduled_delay : self . scheduled_delay ,
817
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
819
818
max_export_timeout : self . max_export_timeout ,
820
819
max_export_batch_size,
821
820
}
@@ -843,6 +842,7 @@ impl BatchConfigBuilder {
843
842
self . scheduled_delay = Duration :: from_millis ( scheduled_delay) ;
844
843
}
845
844
845
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
846
846
if let Some ( max_export_timeout) = env:: var ( OTEL_BLRP_EXPORT_TIMEOUT )
847
847
. ok ( )
848
848
. and_then ( |s| u64:: from_str ( & s) . ok ( ) )
@@ -946,6 +946,7 @@ mod tests {
946
946
config. scheduled_delay,
947
947
Duration :: from_millis( OTEL_BLRP_SCHEDULE_DELAY_DEFAULT )
948
948
) ;
949
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
949
950
assert_eq ! (
950
951
config. max_export_timeout,
951
952
Duration :: from_millis( OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT )
@@ -969,6 +970,7 @@ mod tests {
969
970
let config = temp_env:: with_vars ( env_vars, BatchConfig :: default) ;
970
971
971
972
assert_eq ! ( config. scheduled_delay, Duration :: from_millis( 2000 ) ) ;
973
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
972
974
assert_eq ! ( config. max_export_timeout, Duration :: from_millis( 60000 ) ) ;
973
975
assert_eq ! ( config. max_queue_size, 4096 ) ;
974
976
assert_eq ! ( config. max_export_batch_size, 1024 ) ;
@@ -989,6 +991,7 @@ mod tests {
989
991
config. scheduled_delay,
990
992
Duration :: from_millis( OTEL_BLRP_SCHEDULE_DELAY_DEFAULT )
991
993
) ;
994
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
992
995
assert_eq ! (
993
996
config. max_export_timeout,
994
997
Duration :: from_millis( OTEL_BLRP_EXPORT_TIMEOUT_DEFAULT )
@@ -997,15 +1000,18 @@ mod tests {
997
1000
998
1001
#[ test]
999
1002
fn test_batch_config_with_fields ( ) {
1000
- let batch = BatchConfigBuilder :: default ( )
1003
+ let batch_builder = BatchConfigBuilder :: default ( )
1001
1004
. with_max_export_batch_size ( 1 )
1002
1005
. with_scheduled_delay ( Duration :: from_millis ( 2 ) )
1003
- . with_max_export_timeout ( Duration :: from_millis ( 3 ) )
1004
- . with_max_queue_size ( 4 )
1005
- . build ( ) ;
1006
+ . with_max_queue_size ( 4 ) ;
1007
+
1008
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
1009
+ let batch_builder = batch_builder. with_max_export_timeout ( Duration :: from_millis ( 3 ) ) ;
1010
+ let batch = batch_builder. build ( ) ;
1006
1011
1007
1012
assert_eq ! ( batch. max_export_batch_size, 1 ) ;
1008
1013
assert_eq ! ( batch. scheduled_delay, Duration :: from_millis( 2 ) ) ;
1014
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
1009
1015
assert_eq ! ( batch. max_export_timeout, Duration :: from_millis( 3 ) ) ;
1010
1016
assert_eq ! ( batch. max_queue_size, 4 ) ;
1011
1017
}
@@ -1029,6 +1035,8 @@ mod tests {
1029
1035
builder. config. max_queue_size,
1030
1036
OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT
1031
1037
) ;
1038
+
1039
+ #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
1032
1040
assert_eq ! (
1033
1041
builder. config. max_export_timeout,
1034
1042
Duration :: from_millis( 2046 )
@@ -1049,7 +1057,6 @@ mod tests {
1049
1057
let expected = BatchConfigBuilder :: default ( )
1050
1058
. with_max_export_batch_size ( 1 )
1051
1059
. with_scheduled_delay ( Duration :: from_millis ( 2 ) )
1052
- . with_max_export_timeout ( Duration :: from_millis ( 3 ) )
1053
1060
. with_max_queue_size ( 4 )
1054
1061
. build ( ) ;
1055
1062
@@ -1059,7 +1066,6 @@ mod tests {
1059
1066
let actual = & builder. config ;
1060
1067
assert_eq ! ( actual. max_export_batch_size, 1 ) ;
1061
1068
assert_eq ! ( actual. scheduled_delay, Duration :: from_millis( 2 ) ) ;
1062
- assert_eq ! ( actual. max_export_timeout, Duration :: from_millis( 3 ) ) ;
1063
1069
assert_eq ! ( actual. max_queue_size, 4 ) ;
1064
1070
}
1065
1071
0 commit comments