alerts
azure_bootstrap.alerts
¶
Tier 2 tiered-alert dispatcher.
Apps register a sender (any callable matching AlertSender) at startup,
then code anywhere in the app can fire alert_dev_team(...) — the
dispatcher handles dedup, rate-limit, escalation, and HTML rendering.
Modules:
| Name | Description |
|---|---|
dispatcher |
Tiered alert dispatcher: WARN (log-only), ERROR (digest + escalation), CRITICAL (email). |
escalation |
Sliding-window error history for the ERROR→CRITICAL escalation ladder. |
render |
HTML rendering for alert emails and digest fragments. |
Functions:
| Name | Description |
|---|---|
alert_dev_team |
Emit a tiered alert. Best-effort — never raises. |
drain_pending_alerts |
Return and clear the pending-digest list. Used by daily digest builders. |
install_global_exception_hooks |
Wire |
register_dispatcher |
Wire the alerts module to a live sender. Idempotent. |
reset_state |
Test-only. Refuses unless AZURE_BOOTSTRAP_ALLOW_RESET=1. |
render_pending_alerts_html |
Render the pending-alerts digest fragment for inclusion in a daily email. |
bump_counter |
Thread-safe increment. Never raises. |
counter_snapshot |
Return a copy of the counter map. |
alert_dev_team
¶
alert_dev_team(severity: AlertSeverity | str, subject: str, context: dict[str, Any] | None = None, dedup_key: str | None = None) -> None
Emit a tiered alert. Best-effort — never raises.
Source code in azure_bootstrap/alerts/dispatcher.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
drain_pending_alerts
¶
drain_pending_alerts() -> list[AlertRecord]
Return and clear the pending-digest list. Used by daily digest builders.
install_global_exception_hooks
¶
Wire sys.excepthook and the asyncio loop exception handler to fire
CRITICAL alerts. Always chains to the previous handlers.
Source code in azure_bootstrap/alerts/dispatcher.py
register_dispatcher
¶
Wire the alerts module to a live sender. Idempotent.
Source code in azure_bootstrap/alerts/dispatcher.py
reset_state
¶
Test-only. Refuses unless AZURE_BOOTSTRAP_ALLOW_RESET=1.
Source code in azure_bootstrap/alerts/dispatcher.py
render_pending_alerts_html
¶
Render the pending-alerts digest fragment for inclusion in a daily email.
Source code in azure_bootstrap/alerts/render.py
bump_counter
¶
Thread-safe increment. Never raises.