@@ -614,6 +614,8 @@ impl Default for BatchConfigBuilder {
614
614
/// * `OTEL_BLRP_SCHEDULE_DELAY`
615
615
/// * `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE`
616
616
/// * `OTEL_BLRP_EXPORT_TIMEOUT`
617
+ ///
618
+ /// Note: Programmatic configuration overrides any value set via the environment variable.
617
619
fn default ( ) -> Self {
618
620
BatchConfigBuilder {
619
621
max_queue_size : OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT ,
@@ -630,7 +632,11 @@ impl BatchConfigBuilder {
630
632
/// Set max_queue_size for [`BatchConfigBuilder`].
631
633
/// It's the maximum queue size to buffer logs for delayed processing.
632
634
/// If the queue gets full it will drop the logs.
633
- /// The default value of is 2048.
635
+ /// The default value is 2048.
636
+ ///
637
+ /// Corresponding environment variable: `OTEL_BLRP_MAX_QUEUE_SIZE`.
638
+ ///
639
+ /// Note: Programmatically setting this will override any value set via the environment variable.
634
640
pub fn with_max_queue_size ( mut self , max_queue_size : usize ) -> Self {
635
641
self . max_queue_size = max_queue_size;
636
642
self
@@ -639,6 +645,10 @@ impl BatchConfigBuilder {
639
645
/// Set scheduled_delay for [`BatchConfigBuilder`].
640
646
/// It's the delay interval in milliseconds between two consecutive processing of batches.
641
647
/// The default value is 1000 milliseconds.
648
+ ///
649
+ /// Corresponding environment variable: `OTEL_BLRP_SCHEDULE_DELAY`.
650
+ ///
651
+ /// Note: Programmatically setting this will override any value set via the environment variable.
642
652
pub fn with_scheduled_delay ( mut self , scheduled_delay : Duration ) -> Self {
643
653
self . scheduled_delay = scheduled_delay;
644
654
self
@@ -647,6 +657,10 @@ impl BatchConfigBuilder {
647
657
/// Set max_export_timeout for [`BatchConfigBuilder`].
648
658
/// It's the maximum duration to export a batch of data.
649
659
/// The default value is 30000 milliseconds.
660
+ ///
661
+ /// Corresponding environment variable: `OTEL_BLRP_EXPORT_TIMEOUT`.
662
+ ///
663
+ /// Note: Programmatically setting this will override any value set via the environment variable.
650
664
#[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
651
665
pub fn with_max_export_timeout ( mut self , max_export_timeout : Duration ) -> Self {
652
666
self . max_export_timeout = max_export_timeout;
@@ -658,6 +672,10 @@ impl BatchConfigBuilder {
658
672
/// more than one batch worth of logs then it processes multiple batches
659
673
/// of logs one batch after the other without any delay.
660
674
/// The default value is 512.
675
+ ///
676
+ /// Corresponding environment variable: `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE`.
677
+ ///
678
+ /// Note: Programmatically setting this will override any value set via the environment variable.
661
679
pub fn with_max_export_batch_size ( mut self , max_export_batch_size : usize ) -> Self {
662
680
self . max_export_batch_size = max_export_batch_size;
663
681
self
@@ -774,6 +792,27 @@ mod tests {
774
792
) ;
775
793
}
776
794
795
+ #[ test]
796
+ fn test_code_based_config_overrides_env_vars ( ) {
797
+ let env_vars = vec ! [
798
+ ( OTEL_BLRP_SCHEDULE_DELAY , Some ( "2000" ) ) ,
799
+ ( OTEL_BLRP_MAX_QUEUE_SIZE , Some ( "4096" ) ) ,
800
+ ( OTEL_BLRP_MAX_EXPORT_BATCH_SIZE , Some ( "1024" ) ) ,
801
+ ] ;
802
+
803
+ temp_env:: with_vars ( env_vars, || {
804
+ let config = BatchConfigBuilder :: default ( )
805
+ . with_max_queue_size ( 2048 )
806
+ . with_scheduled_delay ( Duration :: from_millis ( 1000 ) )
807
+ . with_max_export_batch_size ( 512 )
808
+ . build ( ) ;
809
+
810
+ assert_eq ! ( config. scheduled_delay, Duration :: from_millis( 1000 ) ) ;
811
+ assert_eq ! ( config. max_queue_size, 2048 ) ;
812
+ assert_eq ! ( config. max_export_batch_size, 512 ) ;
813
+ } ) ;
814
+ }
815
+
777
816
#[ test]
778
817
fn test_batch_config_configurable_by_env_vars ( ) {
779
818
let env_vars = vec ! [
0 commit comments