[Ops] Add failure counters and alerting hooks for background jobs #86
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Observability is decent if someone is watching: structured JSON logs, a token-gated Prometheus
/metricsendpoint (webapp/backend/app/metrics.py), and/ready. But background-job failures only surface aslogger.errorto stdout — e.g.run_scheduled_backup failedatwebapp/backend/app/tasks/reminder_tasks.py:1926, and similar except-paths throughout the task module.Current behavior
A transcription or backup failure at 2am is a log line nobody reads. There is no counter to alert on and no error tracker — the first sign of a broken backup job could be needing a backup that isn't there.
Fix / Spec
webapp/backend/app/metrics.py:backup_failed_totalcelery_task_failed_total{task_name}— implement via a Celerytask_failuresignal handler registered in the Celery app module, so every task is covered without touching each onebot_event_delivery_failed_totalexceptpaths (backup:reminder_tasks.py:1926area; bot delivery: the notify/publish failure paths). Thetask_failuresignal covers the general case.docs/OPERATIONS.md:rate(celery_task_failed_total[15m]) > 0sustained for 15mSENTRY_DSNenv hook —sentry-sdkinit inmain.pyplus the Celery integration, entirely a no-op when the env var is unset. Do not make sentry-sdk a hard runtime requirement of any code path when unset.Acceptance criteria
backup_failed_total, visible at/metrics.celery_task_failed_totalwith its task name.docs/OPERATIONS.md.SENTRY_DSNset.References
webapp/backend/app/metrics.pywebapp/backend/app/tasks/reminder_tasks.py:1926(backup failure path)Filed from the July 2026 full-project review.