heartbeat
azure_bootstrap.heartbeat
¶
Background heartbeat + worker-progress watchdog.
The heartbeat thread emits a periodic INFO log with the latency + counter
snapshot so ops dashboards have a baseline pulse. The watchdog fires an
ERROR alert when record_consumer_iteration() hasn't been called within
the silence threshold — useful for any worker loop (Service Bus consumer,
Kafka consumer, polling job).
Functions:
| Name | Description |
|---|---|
record_message_settled |
Stamp the last-settled time. Best-effort, never raises. |
record_consumer_iteration |
Stamp the last-iteration time. Best-effort, never raises. |
metrics_snapshot |
For /api/metrics endpoints. |
start_heartbeat |
Spawn a daemon thread emitting periodic heartbeat logs. |
start_consumer_watchdog |
Spawn a daemon thread that alerts when consumer iteration stalls. |
start_background_monitors |
Spawn both heartbeat + watchdog with env defaults. |
reset_state |
Test-only. Refuses unless AZURE_BOOTSTRAP_ALLOW_RESET=1. |
record_message_settled
¶
Stamp the last-settled time. Best-effort, never raises.
record_consumer_iteration
¶
Stamp the last-iteration time. Best-effort, never raises.
Source code in azure_bootstrap/heartbeat/__init__.py
metrics_snapshot
¶
For /api/metrics endpoints.
start_heartbeat
¶
start_heartbeat(stop_event: Event, *, interval_seconds: float | None = None, snapshot_fn: Callable[[], dict[str, Any]] | None = None) -> Thread
Spawn a daemon thread emitting periodic heartbeat logs.
Returns the thread (or an already-finished placeholder when disabled).
Source code in azure_bootstrap/heartbeat/__init__.py
start_consumer_watchdog
¶
start_consumer_watchdog(stop_event: Event, *, interval_seconds: float | None = None, silence_threshold_seconds: float | None = None, resilence_window_seconds: float | None = None) -> Thread
Spawn a daemon thread that alerts when consumer iteration stalls.
The default resilence_window (1 hour) is intentionally longer than
the alerts dispatcher's 10-min dedup so sustained incidents page hourly,
not every 10 minutes.
Source code in azure_bootstrap/heartbeat/__init__.py
start_background_monitors
¶
Spawn both heartbeat + watchdog with env defaults.
Source code in azure_bootstrap/heartbeat/__init__.py
reset_state
¶
Test-only. Refuses unless AZURE_BOOTSTRAP_ALLOW_RESET=1.