Skip to main content

Module log_throttle

Module log_throttle 

Expand description

A “log at most once per interval, and say how many you swallowed” counter (cratestack#846).

Exists because the two failure paths that most need a log line are also the two an attacker can drive: a rate-limit store outage emits one WARN per request, and the request rate during an outage is whatever the caller chooses. An unthrottled per-request WARN turns a store outage into a log-volume amplifier on top of everything else — the incident that produced this crate’s fail-open policy would have written one line per request for as long as Redis was down.

Deliberately not a general-purpose rate limiter: no token bucket, no configuration, no allocation. The suppressed count is what makes the throttle honest — an operator reading the log sees “…and 4,812 more”, not a single line that understates the blast radius.

Structs§

LogThrottle
Decides whether the caller should emit its log line now, and how many it has swallowed since the last one it allowed.

Enums§

ThrottleDecision
Returned by LogThrottle::check: either “emit, and mention this many suppressed since last time” or “stay quiet”.