refactor suppression reason overall

This commit is contained in:
Chris Beck
2025-12-06 19:47:58 -07:00
parent 12f0c99ef9
commit c62bac4a1d
2 changed files with 5 additions and 7 deletions
+5 -5
View File
@@ -22,8 +22,8 @@ pub enum SuppressionReason {
/// Suppressed by route limiters. Contains the index and result for each /// Suppressed by route limiters. Contains the index and result for each
/// route whose filter matched but whose limiter blocked the message. /// route whose filter matched but whose limiter blocked the message.
Routes(Vec<(usize, LimitResult)>), Routes(Vec<(usize, LimitResult)>),
/// Suppressed by an overall limiter. /// Suppressed by an overall limiter at the given index.
Overall(LimitResult), OverallLimiter(usize),
} }
impl fmt::Display for SuppressionReason { impl fmt::Display for SuppressionReason {
@@ -40,8 +40,8 @@ impl fmt::Display for SuppressionReason {
} }
write!(f, "]") write!(f, "]")
} }
SuppressionReason::Overall(result) => { SuppressionReason::OverallLimiter(idx) => {
write!(f, "overall:{result:?}") write!(f, "overall[{idx}]")
} }
} }
} }
@@ -263,7 +263,7 @@ impl LogHandler {
// At least one route passed, now check overall limits // At least one route passed, now check overall limits
if let Err(i) = evaluate_limiter_sequence(&self.overall_limits, log_msg) { if let Err(i) = evaluate_limiter_sequence(&self.overall_limits, log_msg) {
return Err(SuppressionReason::Overall(LimitResult::OverallLimiter(i))); return Err(SuppressionReason::OverallLimiter(i));
} }
// All checks passed // All checks passed
@@ -16,8 +16,6 @@ pub enum LimitResult {
Limiter(usize), Limiter(usize),
/// The event was blocked by a global limiter at the given index. /// The event was blocked by a global limiter at the given index.
GlobalLimiter(usize), GlobalLimiter(usize),
/// The event was blocked by an overall limiter at the given index.
OverallLimiter(usize),
} }
/// A set of limiters for a route, containing both per-origin and global limiters. /// A set of limiters for a route, containing both per-origin and global limiters.