SIGN IN SIGN UP

fix(exporters): keep limiting after the first dropped alert

shouldSendLimitAlert returned `count > max && !isNotified`, which is one
value carrying two decisions. The first alert past the limit is dropped
and sets isNotified; that makes the condition false for every later
alert in the same minute, so they are all sent. The limiter therefore
dropped exactly one alert per minute and let the rest through.

admitAlert returns the two decisions separately: admitted is false for
every alert past the limit, notify is true only for the first one.

Three smaller things fixed with it:
  - ReportAlertSuppressed(..., "rate_limit") now fires for every dropped
    alert instead of once per minute, so the metric becomes usable.
  - The window reset no longer swallows the alert that triggers it. The
    old code returned early without counting, so the effective limit was
    max + 1.
  - sendAlertLimitReached no longer reads count and startTime without
    holding the lock.

A limit of zero or less means no limit. Validate() already replaces a
zero with the default, so this only guards an exporter built by hand.

Documented in docs/features/alert-rate-limit.md.

Signed-off-by: Alon Liwsky <40373481+AlonLiwsky@users.noreply.github.com>
A
Alon Liwsky committed
7571aae1988313687cb1b98720e811cb0da61daa
Parent: de4676b