M26: harden clean observability acceptance
This commit is contained in:
@@ -10,7 +10,7 @@ from sqlalchemy import func, select
|
||||
from app.core.config import get_settings
|
||||
from app.core.db import SessionLocal
|
||||
from app.core.observability import OUTBOX_EVENTS
|
||||
from app.models.outbox import DEMO_SCENARIO_ERROR_CODE, OutboxEvent
|
||||
from app.models.outbox import DELIVERY_STATUSES, DEMO_SCENARIO_ERROR_CODE, OutboxEvent
|
||||
|
||||
router = APIRouter(tags=["observability"])
|
||||
settings = get_settings()
|
||||
@@ -26,8 +26,14 @@ def _refresh_database_metrics() -> None:
|
||||
).group_by(OutboxEvent.delivery_status, "demo")
|
||||
).all()
|
||||
OUTBOX_EVENTS.clear()
|
||||
# Keep every time series present even when a state currently contains no rows.
|
||||
# Stable zero-valued series make dashboards and alerts deterministic after resets,
|
||||
# restores and fresh installations instead of turning "zero" into "no data".
|
||||
for scenario in ("synthetic", "operational"):
|
||||
for status in DELIVERY_STATUSES:
|
||||
OUTBOX_EVENTS.labels(scenario, status).set(0)
|
||||
for status, is_demo, count in rows:
|
||||
OUTBOX_EVENTS.labels(str(status), "synthetic" if is_demo else "operational").set(count)
|
||||
OUTBOX_EVENTS.labels("synthetic" if is_demo else "operational", str(status)).set(count)
|
||||
|
||||
|
||||
@router.get("/metrics", include_in_schema=False)
|
||||
|
||||
Reference in New Issue
Block a user