pub struct AlertRuntime {
pub enabled: bool,
/* private fields */
}Expand description
Compiled alerting runtime, carried on the proxy Runtime.
Fields§
§enabled: boolImplementations§
Source§impl AlertRuntime
impl AlertRuntime
Sourcepub fn build(cfg: &AlertsCfg) -> Self
pub fn build(cfg: &AlertsCfg) -> Self
Compile from config. enabled folds in “has a non-empty webhook_url” so a misconfigured
switch (on, but no URL) is inert rather than trying to POST nowhere on every crossing.
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
An inert runtime (alerting off) — the default when [alerts] is absent.
Sourcepub fn decide_budget(&self, budget: &str, ratio: f64) -> bool
pub fn decide_budget(&self, budget: &str, ratio: f64) -> bool
Decide whether a budget’s ratio should fire an alert now, updating the edge-trigger
state: fire only on the transition into the alert zone (was-below → now at/above the
threshold); reset when it drops back below so a later crossing re-alerts. Pure of IO, so the
dedup logic is directly testable.
Sourcepub fn fire_budget_alert(&self, budget: &str, ratio: f64)
pub fn fire_budget_alert(&self, budget: &str, ratio: f64)
Fire a Slack-compatible budget alert when the ratio first crosses the threshold. No-op unless enabled and the crossing is fresh. Fire-and-forget — any webhook error is swallowed at debug.