QueueKeeperCheck (queue_keeper_check v0.4.0)

Copy Markdown View Source

Read-only health check for Oban queues.

report = QueueKeeperCheck.run(MyApp.Repo)
IO.puts(QueueKeeperCheck.format(report))

Detects eleven conditions (see checks/0 and QueueKeeperCheck.Config for thresholds):

  • :orphaned - jobs executing far longer than any job should run (execution age only; possibly orphaned by a node crash)
  • :hanging - jobs executing past their per-worker time budget
  • :backlog - too many due jobs, or the oldest due job waiting too long, per queue
  • :stalled - due jobs waiting and nothing in that queue attempted recently (queue stopped, or every slot busy with long-running jobs)
  • :retry_storm - many jobs of one worker failed and awaiting retry, or retried, within a short window
  • :discarded - spike of discarded jobs (silent failures)
  • :cancelled - spike of cancelled jobs
  • :cron_missing - an expected (cron) worker has had no job inserted for too long; opt-in via cron_missing: [expected: %{"MyApp.Nightly" => 90_000}]
  • :dead_workers - a worker has had no job inserted within a window of any positive integer number of days (enqueue inactivity, not proof of unused code). Opt-in via dead_workers: [window_days: 14] (7, 14 and 30 are examples, not a limit). Always a warning. Uses last enqueue (inserted_at) and reports leftover nonterminal or future-scheduled jobs. When the opt-in last-seen ledger is attached, that is the source of truth and the check stays silent until the ledger has been recording for the window (no need to raise the Pruner max_age). Otherwise it falls back to oban_jobs and will not flag workers when finished-job history is shorter than the window. If you omit window_days but set known or discover: true, the window is 7 days (was 14 in 0.3.0)
  • :persisted_jobs - opt-in, report-only reconciliation of nonterminal jobs (including future scheduled and core suspended) against a trusted inventory of deployed workers and effective queues. Classifies missing workers, unconfigured queues, paused queues, no active consumer (only with a supplied consumer snapshot), or insufficient evidence. Off until you pass inventory. Never infers deployment-wide absence from one node. Oban Pro beyond core suspended is untested and unverified
  • :dead_worker_candidates - opt-in combined review of enqueue inactivity and static reachability. A high-confidence candidate has had no enqueue for at least window_days (default 7, inclusive) with sufficient history, and no code or cron reference, and no leftover pending or future-scheduled jobs. Never claims a worker is definitely dead. Insufficient history is unknown

Options: any check name with a keyword list of thresholds, plus

Invalid options raise ArgumentError. Database errors never raise: each check runs on its own, and a check that fails (timeout, missing table or column, connection error) is reported in report.errors with status :error (unless a finding is :critical). After a connection error the remaining checks are skipped.

Summary

Functions

All check names, in the order they run.

Plain-text rendering, one line per finding or error. Queue and worker names come from the database, so control and invisible formatting characters (including newlines and bidirectional overrides) are replaced with ?: a crafted name cannot forge extra lines or reorder text in a terminal or log.

Run the checks against repo and return a QueueKeeperCheck.Report.

Build (but do not send) a Slack incoming-webhook payload. Post it with your own HTTP client, e.g. Req.post!(webhook_url, json: QueueKeeperCheck.slack_payload(report)). &, < and > are escaped as Slack requires, so a queue or worker name cannot inject <!channel> mentions or links.

Functions

checks()

All check names, in the order they run.

format(r)

Plain-text rendering, one line per finding or error. Queue and worker names come from the database, so control and invisible formatting characters (including newlines and bidirectional overrides) are replaced with ?: a crafted name cannot forge extra lines or reorder text in a terminal or log.

run(repo, opts \\ [])

Run the checks against repo and return a QueueKeeperCheck.Report.

slack_payload(r)

Build (but do not send) a Slack incoming-webhook payload. Post it with your own HTTP client, e.g. Req.post!(webhook_url, json: QueueKeeperCheck.slack_payload(report)). &, < and > are escaped as Slack requires, so a queue or worker name cannot inject <!channel> mentions or links.