@@ -22,7 +22,7 @@ use agent_data_plane_config::control::ListenAddress;
2222use agent_data_plane_config:: domains:: dogstatsd:: {
2323 FilterAction , MapperProfile , MetricMapping , MetricTagFilterEntry , OriginTagCardinality ,
2424} ;
25- use agent_data_plane_config:: shared:: ForwarderHttpProtocol ;
25+ use agent_data_plane_config:: shared:: { ForwarderHttpProtocol , ZSTD_MINIMUM } ;
2626use agent_data_plane_config:: SalukiConfiguration ;
2727use bytesize:: ByteSize ;
2828use datadog_agent_config:: { drive, DatadogConfigWitness , DatadogConfiguration , TranslateError , TranslateErrors } ;
@@ -952,7 +952,13 @@ impl DatadogConfigWitness for DatadogTranslator<'_> {
952952 }
953953
954954 fn consume_serializer_zstd_compressor_level ( & mut self , value : i64 ) {
955- self . config . shared . endpoints . compression . zstd_compressor_level = value as i32 ;
955+ // TODO: The core Agent streams a fully-resolved config, so its schema default of `1` for
956+ // `serializer_zstd_compressor_level` arrives here as a concrete value. Without this clamp it
957+ // would silently override ADP's intended `ZSTD_MINIMUM` floor. Clamping up cannot tell an
958+ // operator who deliberately set `1` apart from the Agent's default `1`, so both are raised to
959+ // the floor. Follow-up work needs to track each value's source (user-set vs Agent default) so
960+ // we can honor an explicit low level while still applying our floor to the Agent default.
961+ self . config . shared . endpoints . compression . zstd_compressor_level = ( value as i32 ) . max ( ZSTD_MINIMUM ) ;
956962 }
957963
958964 fn consume_site ( & mut self , value : String ) {
@@ -1143,4 +1149,29 @@ mod tests {
11431149 // The error is still surfaced, so startup's strict gate rejects the config.
11441150 assert ! ( errors. is_some( ) , "an unknown action must record a translation error" ) ;
11451151 }
1152+
1153+ #[ test]
1154+ fn zstd_compressor_level_clamps_up_to_the_minimum ( ) {
1155+ use agent_data_plane_config:: shared:: ZSTD_MINIMUM ;
1156+
1157+ // The Agent's schema default of `1` arrives as a concrete value; it must be raised to the
1158+ // ADP floor rather than lowering our compression level.
1159+ let datadog: DatadogConfiguration = serde_json:: from_value ( json ! ( {
1160+ "serializer_zstd_compressor_level" : 1 ,
1161+ } ) )
1162+ . expect ( "datadog source deserializes" ) ;
1163+ let ( config, _) = DatadogTranslator :: new ( & datadog, SalukiConfiguration :: default ( ) ) . translate ( ) ;
1164+ assert_eq ! (
1165+ config. shared. endpoints. compression. zstd_compressor_level, ZSTD_MINIMUM ,
1166+ "a level below the floor is clamped up to it"
1167+ ) ;
1168+
1169+ // A level at or above the floor is used as provided.
1170+ let datadog: DatadogConfiguration = serde_json:: from_value ( json ! ( {
1171+ "serializer_zstd_compressor_level" : 7 ,
1172+ } ) )
1173+ . expect ( "datadog source deserializes" ) ;
1174+ let ( config, _) = DatadogTranslator :: new ( & datadog, SalukiConfiguration :: default ( ) ) . translate ( ) ;
1175+ assert_eq ! ( config. shared. endpoints. compression. zstd_compressor_level, 7 ) ;
1176+ }
11461177}
0 commit comments