@@ -344,39 +344,40 @@ impl GenerateConfig for Config {
344344#[ derive( Debug , Snafu ) ]
345345pub enum BuildError {
346346 #[ snafu( display(
347- "cache_size_per_key set on per-tag entry `{tag_key}` but the inherited mode is \
348- `exact `, where it has no effect. Remove the field or switch to `probabilistic` mode."
347+ "cache_size_per_key set on per-tag entry `{tag_key}` but the inherited mode is not \
348+ `probabilistic `, where it has no effect. Remove the field or switch to `probabilistic` mode."
349349 ) ) ]
350- CacheSizeInExactMode { tag_key : String } ,
350+ CacheSizeRequiresProbabilistic { tag_key : String } ,
351351}
352352
353353impl Config {
354354 fn validate ( & self ) -> crate :: Result < ( ) > {
355- // Global per_tag_limits: validate against the global mode.
356- if self . global . mode == Mode :: Exact {
355+ // Global per_tag_limits: cache_size_per_key only applies in probabilistic mode.
356+ if ! matches ! ( self . global. mode, Mode :: Probabilistic ( _ ) ) {
357357 for ( tag_key, tag_cfg) in & self . per_tag_limits {
358358 if let PerTagMode :: LimitOverride {
359359 cache_size_per_key : Some ( _) ,
360360 ..
361361 } = tag_cfg. mode
362362 {
363- return Err ( Box :: new ( BuildError :: CacheSizeInExactMode {
363+ return Err ( Box :: new ( BuildError :: CacheSizeRequiresProbabilistic {
364364 tag_key : tag_key. clone ( ) ,
365365 } ) ) ;
366366 }
367367 }
368368 }
369369
370- // Per-metric per_tag_limits: validate against each per-metric mode.
370+ // Per-metric per_tag_limits: cache_size_per_key only applies when the per-metric
371+ // mode is probabilistic (not exact, and not excluded).
371372 for per_metric in self . per_metric_limits . values ( ) {
372- if per_metric. config . mode == OverrideMode :: Exact {
373+ if ! matches ! ( per_metric. config. mode, OverrideMode :: Probabilistic ( _ ) ) {
373374 for ( tag_key, tag_cfg) in & per_metric. per_tag_limits {
374375 if let PerTagMode :: LimitOverride {
375376 cache_size_per_key : Some ( _) ,
376377 ..
377378 } = tag_cfg. mode
378379 {
379- return Err ( Box :: new ( BuildError :: CacheSizeInExactMode {
380+ return Err ( Box :: new ( BuildError :: CacheSizeRequiresProbabilistic {
380381 tag_key : tag_key. clone ( ) ,
381382 } ) ) ;
382383 }
0 commit comments