Metrics for maintenance health: due-work lag, maintenance errors, leadership and runtime version

Aperta
#709 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
postgresql, rust

Direzione di ricerca

Start with awa-metrics/src/lib.rs, the telemetry reference, and docs/grafana/README.md; trace existing metric recording and maintenance branches, then review related issues #703 and #627 for context. The work spans queue metrics, maintenance and cron instrumentation, tests, alert rules, and dashboard panels. It is done when the proposed metrics are emitted and documented, tests cover them, matching alerts and panels exist, and the README gaps are removed or narrowed.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

The dashboards README lists four things awa's metrics can't show (docs/grafana/README.md, "What the dashboards cannot show"). The first and last of them stop a promotion stall from being alerted on directly:

  • Due-but-unpromoted work. awa.queue.depth{awa.job.state="scheduled"} counts every deferred job whether or not it is due, and awa.queue.lag only sees jobs already in the ready lanes.
  • Maintenance leader identity. Leadership is an in-process flag with no metric.
  • Runtime version. No metric reports which awa version a runtime runs.
  • Maintenance task failures. Failed promotion, rescue, prune and cron queries are logged with error! and not counted. The awa.maintenance.branch.duration timer records whether the body failed or not, and awa.maintenance.promote.* records successful batches only.

A real case: in 0.6.10, scheduled promotion failed client-side ("too many arguments for query") whenever a 4,096-row batch was due at once (fixed in 0.6.12). Promotion stopped for every queue for about ten hours. In metrics, that looked like a large scheduled depth and a flat promotion rate, which a busy deployment with jobs scheduled days ahead shows normally too. The only direct signal was an error! log per tick, emitted by whichever runtime held the maintenance lease. Error trackers attribute that log to that application, not to awa.

Proposal

These are all additions. No existing name, type or attribute key changes, per the stability policy (ADR-036). Names follow awa-metrics' rules and the OpenTelemetry naming guidance. Failures follow Recording errors: an error.type attribute on the operation's duration histogram, omitted on success, rather than a separate error counter.

Metric Instrument Unit Attributes Meaning
awa.queue.due.lag gauge (f64) s awa.job.queue, awa.job.state (scheduled | retryable) now - min(run_at) over deferred jobs whose run_at <= now; 0 when none are due. The deferred counterpart of awa.queue.lag.
awa.queue.due.depth gauge (i64) {job} awa.job.queue, awa.job.state Deferred jobs that are due but not yet promoted.
awa.maintenance.branch.duration (existing) histogram s add error.type when the branch body fails Makes every maintenance branch's failures countable from the metric that already exists.
awa.maintenance.promote.duration (existing) histogram s record failed batches too, with error.type Failure rate of promotion itself, per awa.job.state.
awa.maintenance.prune.duration (existing) histogram s add error.type Same for prune. Rotate and rescue get a .duration with error.type too, if not covered by the branch timer.
awa.maintenance.leader gauge (i64) {runtime} none (the exporter's resource identifies the runtime) 1 on the runtime holding the maintenance lease, 0 elsewhere. sum should be 1, and changes() counts handovers.
awa.runtime.info gauge, constant 1 {runtime} awa.version, awa.storage.engine Version and storage per runtime, for mixed-version rollouts.
awa.cron.fire.delay histogram s awa.job.queue, awa.job.kind Time from a periodic job's scheduled fire time to its enqueue. Missed fires are recorded with error.type (for example missed), using the existing missed-fire policy.

error.type values stay low-cardinality: the AwaError variant or a fixed class such as database, timeout, bind_limit or lock_not_available, never the message.

With these, a promotion stall is max(awa_queue_due_lag_seconds) > N, and a failing branch is rate(awa_maintenance_branch_duration_seconds_count{error_type!=""}[5m]) > 0. Both are independent of which application holds the lease. Queries over a due backlog should use the deferred_jobs (state, run_at, …) due index so queue_stats stays cheap. If that isn't possible, compute it in the promote branch, which already scans due rows.

Also found

  • awa.job.inserted is defined (awa-metrics/src/lib.rs) but never recorded. Emit it on the insert paths, or document it as reserved.
  • awa.cron.reconciliation.decisions and awa.cron.retired have no unit ({decision}, {schedule}), and the decisions counter uses a bare outcome key where everything else is namespaced (awa.cron.outcome). Adding the units doesn't change Prometheus names. Renaming the key is breaking, so it fits 0.7's metric review, emitting both until then if wanted.
  • Semantic-convention alignment for 0.7, for discussion rather than this issue. Spans already use messaging conventions (ADR-039, #454). Metrics use awa.job.queue rather than messaging.destination.name, and split outcomes across awa.job.completed/.failed/.retried where the recording-errors guidance would put error.type on awa.job.duration. The messaging metrics conventions are still Development, and none of them covers depth or lag, so awa's own names stay the right home for those.

Related: #703 (prune lock failures), #627 (rescue backlog).

Done when

  • The metrics above are emitted, documented in the telemetry reference, and covered by tests in awa-metrics.
  • docs/grafana/alerts/awa-alerts-prometheus.yaml gains a due-lag alert and a maintenance-error alert, and the dashboards gain matching panels.
  • The four entries in "What the dashboards cannot show" are removed or narrowed.
Lingua principale
Rust
Stelle
37
Fork
8
Merge medio
14h 16m
PR unite (30g)
244

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hardbyte/awa

Tutte le issue di hardbyte/awa

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.