Skip to content

feat(#1573): boot SLO alert, anomaly detector, and slow-query alerter… - #1657

Open
onitsha-droid wants to merge 1 commit into
CalloraOrg:mainfrom
onitsha-droid:feat/boot-alert-jobs-1573
Open

onitsha-droid wants to merge 1 commit into
CalloraOrg:mainfrom
onitsha-droid:feat/boot-alert-jobs-1573

Conversation

@onitsha-droid

Copy link
Copy Markdown

Summary

Wires the SLO burn-rate alerter, usage anomaly detector, and slow-query alerter into application startup via startBackgroundJobs in src/lifecycle/jobs.ts and registers each active job with graceful shutdown in src/index.ts.

Closes #1573

Changes

  • Env toggles & config
    • Added optional tri-state SLOW_QUERY_ALERTER_ENABLED (src/config/execution-env.ts) and SLO_ALERT_ENABLED (src/config/slo-env.ts).
    • Updated src/config/service-settings.ts so slowQueryAlerter.enabled defaults off when SLOW_QUERY_ALERT_WEBHOOK_URL is empty, sloAlert.enabled defaults off when SLO_ALERT_WEBHOOK_URL or SLO_ROUTE_CONFIGS is empty, and each job tracks explicitlyEnabled.
    • Documented SLOW_QUERY_ALERTER_ENABLED and SLO_ALERT_ENABLED in .env.example.
  • Job bootstrap & graceful shutdown
    • Extended startBackgroundJobs in src/lifecycle/jobs.ts to instantiate and start sloAlertJob (including initSloRecorder), anomalyDetectorJob, and slowQueryAlerterJob when enabled, passing the shared pool and registering { name, beginShutdown, awaitIdle } (slo-alert, anomaly-detector, slow-query-alerter) in subsystems.
    • Added startConfiguredJob to log and skip misconfigured auto-enabled jobs while throwing a clear boot error when a job is explicitly enabled.
    • Wired ...subsystems from startBackgroundJobs into shutdownSubsystems in src/index.ts (and cleaned up merge-artifact syntax errors in src/index.ts, src/lifecycle/jobs.ts, and src/lifecycle/jobs.test.ts).
  • Docs & tests
    • Updated docs/graceful-shutdown.md to list slo-alert, anomaly-detector, and slow-query-alerter as drained subsystems.
    • Added unit tests with fake job factories in src/lifecycle/jobs.test.ts and toggle parsing tests in src/config/env.test.ts.

Testing

  • npx jest src/lifecycle/jobs.test.ts --testNamePattern="creates no timers or subsystems when all toggles are off|starts sloAlert, anomalyDetector, and slowQueryAlerter|throws a clear boot error when an explicitly enabled job|logs and skips a misconfigured job" — 4/4 passed
  • npm test -- src/workers/anomalyDetector.test.ts src/workers/slowQueryAlerter.test.ts — 2/2 suites passed
  • JEST_RUN_QUARANTINED=1 npx jest src/workers/sloAlertJob.test.ts — 18/18 passed
  • JEST_RUN_QUARANTINED=1 npx jest src/config/env.test.ts — new env schema — alert job toggles tests passed (8 pre-existing failures in unrelated suites in that file)
  • npx tsc --noEmit — 0 errors in modified source files (src/index.ts, src/lifecycle/jobs.ts, src/config/execution-env.ts, src/config/slo-env.ts, src/config/service-settings.ts)

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@onitsha-droid Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Boot the SLO alert job with the anomaly detector and slow-query alerter from src/index.ts

1 participant