@@ -704,6 +704,8 @@ impl Default for BatchConfigBuilder {
704
704
/// * `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`
705
705
/// * `OTEL_BSP_EXPORT_TIMEOUT`
706
706
/// * `OTEL_BSP_MAX_CONCURRENT_EXPORTS`
707
+ ///
708
+ /// Note: Programmatic configuration overrides any value set via the environment variable.
707
709
fn default ( ) -> Self {
708
710
BatchConfigBuilder {
709
711
max_queue_size : OTEL_BSP_MAX_QUEUE_SIZE_DEFAULT ,
@@ -720,7 +722,11 @@ impl BatchConfigBuilder {
720
722
/// Set max_queue_size for [`BatchConfigBuilder`].
721
723
/// It's the maximum queue size to buffer spans for delayed processing.
722
724
/// If the queue gets full it will drops the spans.
723
- /// The default value of is 2048.
725
+ /// The default value is 2048.
726
+ ///
727
+ /// Corresponding environment variable: `OTEL_BSP_MAX_QUEUE_SIZE`.
728
+ ///
729
+ /// Note: Programmatically setting this will override any value set via the environment variable.
724
730
pub fn with_max_queue_size ( mut self , max_queue_size : usize ) -> Self {
725
731
self . max_queue_size = max_queue_size;
726
732
self
@@ -731,6 +737,10 @@ impl BatchConfigBuilder {
731
737
/// more than one batch worth of spans then it processes multiple batches
732
738
/// of spans one batch after the other without any delay. The default value
733
739
/// is 512.
740
+ ///
741
+ /// Corresponding environment variable: `OTEL_BSP_MAX_EXPORT_BATCH_SIZE`.
742
+ ///
743
+ /// Note: Programmatically setting this will override any value set via the environment variable.
734
744
pub fn with_max_export_batch_size ( mut self , max_export_batch_size : usize ) -> Self {
735
745
self . max_export_batch_size = max_export_batch_size;
736
746
self
@@ -743,6 +753,11 @@ impl BatchConfigBuilder {
743
753
/// The default value is 1.
744
754
/// If the max_concurrent_exports value is default value, it will cause exports to be performed
745
755
/// synchronously on the BatchSpanProcessor task.
756
+ /// The default value is 1.
757
+ ///
758
+ /// Corresponding environment variable: `OTEL_BSP_MAX_CONCURRENT_EXPORTS`.
759
+ ///
760
+ /// Note: Programmatically setting this will override any value set via the environment variable.
746
761
pub fn with_max_concurrent_exports ( mut self , max_concurrent_exports : usize ) -> Self {
747
762
self . max_concurrent_exports = max_concurrent_exports;
748
763
self
@@ -751,6 +766,10 @@ impl BatchConfigBuilder {
751
766
/// Set scheduled_delay_duration for [`BatchConfigBuilder`].
752
767
/// It's the delay interval in milliseconds between two consecutive processing of batches.
753
768
/// The default value is 5000 milliseconds.
769
+ ///
770
+ /// Corresponding environment variable: `OTEL_BSP_SCHEDULE_DELAY`.
771
+ ///
772
+ /// Note: Programmatically setting this will override any value set via the environment variable.
754
773
pub fn with_scheduled_delay ( mut self , scheduled_delay : Duration ) -> Self {
755
774
self . scheduled_delay = scheduled_delay;
756
775
self
@@ -759,6 +778,10 @@ impl BatchConfigBuilder {
759
778
/// Set max_export_timeout for [`BatchConfigBuilder`].
760
779
/// It's the maximum duration to export a batch of data.
761
780
/// The The default value is 30000 milliseconds.
781
+ ///
782
+ /// Corresponding environment variable: `OTEL_BSP_EXPORT_TIMEOUT`.
783
+ ///
784
+ /// Note: Programmatically setting this will override any value set via the environment variable.
762
785
#[ cfg( feature = "experimental_trace_batch_span_processor_with_async_runtime" ) ]
763
786
pub fn with_max_export_timeout ( mut self , max_export_timeout : Duration ) -> Self {
764
787
self . max_export_timeout = max_export_timeout;
@@ -932,6 +955,40 @@ mod tests {
932
955
) ;
933
956
}
934
957
958
+ #[ test]
959
+ fn test_code_based_config_overrides_env_vars ( ) {
960
+ let env_vars = vec ! [
961
+ ( OTEL_BSP_EXPORT_TIMEOUT , Some ( "60000" ) ) ,
962
+ ( OTEL_BSP_MAX_CONCURRENT_EXPORTS , Some ( "5" ) ) ,
963
+ ( OTEL_BSP_MAX_EXPORT_BATCH_SIZE , Some ( "1024" ) ) ,
964
+ ( OTEL_BSP_MAX_QUEUE_SIZE , Some ( "4096" ) ) ,
965
+ ( OTEL_BSP_SCHEDULE_DELAY , Some ( "2000" ) ) ,
966
+ ] ;
967
+
968
+ temp_env:: with_vars ( env_vars, || {
969
+ let config = BatchConfigBuilder :: default ( )
970
+ . with_max_export_batch_size ( 512 )
971
+ . with_max_queue_size ( 2048 )
972
+ . with_scheduled_delay ( Duration :: from_millis ( 1000 ) ) ;
973
+ #[ cfg( feature = "experimental_trace_batch_span_processor_with_async_runtime" ) ]
974
+ let config = {
975
+ config
976
+ . with_max_concurrent_exports ( 10 )
977
+ . with_max_export_timeout ( Duration :: from_millis ( 2000 ) )
978
+ } ;
979
+ let config = config. build ( ) ;
980
+
981
+ assert_eq ! ( config. max_export_batch_size, 512 ) ;
982
+ assert_eq ! ( config. max_queue_size, 2048 ) ;
983
+ assert_eq ! ( config. scheduled_delay, Duration :: from_millis( 1000 ) ) ;
984
+ #[ cfg( feature = "experimental_trace_batch_span_processor_with_async_runtime" ) ]
985
+ {
986
+ assert_eq ! ( config. max_concurrent_exports, 10 ) ;
987
+ assert_eq ! ( config. max_export_timeout, Duration :: from_millis( 2000 ) ) ;
988
+ }
989
+ } ) ;
990
+ }
991
+
935
992
#[ test]
936
993
fn test_batch_config_configurable_by_env_vars ( ) {
937
994
let env_vars = vec ! [
0 commit comments