//! route alert/recovery messages. Domain half of the Alerter split; //! shared dispatch/cooldown plumbing lives in the parent module. use tracing::instrument; use super::{AlertCategory, AlertMeta, Alerter}; impl Alerter { #[instrument(skip_all)] pub async fn send_route_failure_alert( &self, target: &str, label: &str, failed_paths: &[String], ) { let alert_key = format!("route:{target}"); let n = failed_paths.len(); let subject = format!("[PoM] {label}: {n} route(s) failing"); let body = format!( "Target: {label} ({target})\n\ Failed routes:\n{}\n\ Instance: {}\n\ Time: {}\n\n\ - PoM", failed_paths .iter() .map(|p| format!(" - {p}")) .collect::>() .join("\n"), self.instance_name, chrono::Utc::now().to_rfc3339(), ); self.fire_failure( &subject, &body, "high", "pom-routes", Some(target), AlertMeta { key: &alert_key, category: AlertCategory::RouteFailure, from: None, to: None, error: None, }, ) .await; } #[instrument(skip_all)] pub async fn send_route_recovery_alert( &self, target: &str, label: &str, recovered_paths: &[String], ) { let alert_key = format!("route:{target}"); let subject = format!("[PoM] {label}: routes recovered"); let body = format!( "Target: {label} ({target})\n\ Recovered routes:\n{}\n\ Instance: {}\n\ Time: {}\n\n\ - PoM", recovered_paths .iter() .map(|p| format!(" - {p}")) .collect::>() .join("\n"), self.instance_name, chrono::Utc::now().to_rfc3339(), ); self.fire_recovery( &subject, &body, AlertMeta { key: &alert_key, category: AlertCategory::RouteRecovery, from: None, to: None, error: None, }, ) .await; } }