@@ -614,6 +614,8 @@ impl Default for BatchConfigBuilder {
614614 /// * `OTEL_BLRP_SCHEDULE_DELAY`
615615 /// * `OTEL_BLRP_MAX_EXPORT_BATCH_SIZE`
616616 /// * `OTEL_BLRP_EXPORT_TIMEOUT`
617+ ///
618+ /// Note: Programmatic configuration overrides any value set via the environment variable.
617619 fn default ( ) -> Self {
618620 BatchConfigBuilder {
619621 max_queue_size : OTEL_BLRP_MAX_QUEUE_SIZE_DEFAULT ,
@@ -630,7 +632,11 @@ impl BatchConfigBuilder {
630632 /// Set max_queue_size for [`BatchConfigBuilder`].
631633 /// It's the maximum queue size to buffer logs for delayed processing.
632634 /// 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.
634640 pub fn with_max_queue_size ( mut self , max_queue_size : usize ) -> Self {
635641 self . max_queue_size = max_queue_size;
636642 self
@@ -639,6 +645,10 @@ impl BatchConfigBuilder {
639645 /// Set scheduled_delay for [`BatchConfigBuilder`].
640646 /// It's the delay interval in milliseconds between two consecutive processing of batches.
641647 /// 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.
642652 pub fn with_scheduled_delay ( mut self , scheduled_delay : Duration ) -> Self {
643653 self . scheduled_delay = scheduled_delay;
644654 self
@@ -647,6 +657,10 @@ impl BatchConfigBuilder {
647657 /// Set max_export_timeout for [`BatchConfigBuilder`].
648658 /// It's the maximum duration to export a batch of data.
649659 /// 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.
650664 #[ cfg( feature = "experimental_logs_batch_log_processor_with_async_runtime" ) ]
651665 pub fn with_max_export_timeout ( mut self , max_export_timeout : Duration ) -> Self {
652666 self . max_export_timeout = max_export_timeout;
@@ -658,6 +672,10 @@ impl BatchConfigBuilder {
658672 /// more than one batch worth of logs then it processes multiple batches
659673 /// of logs one batch after the other without any delay.
660674 /// 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.
661679 pub fn with_max_export_batch_size ( mut self , max_export_batch_size : usize ) -> Self {
662680 self . max_export_batch_size = max_export_batch_size;
663681 self
@@ -774,6 +792,27 @@ mod tests {
774792 ) ;
775793 }
776794
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+
777816 #[ test]
778817 fn test_batch_config_configurable_by_env_vars ( ) {
779818 let env_vars = vec ! [
0 commit comments