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

Abierto
#709 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
38/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
postgresql, rust

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Rust
Estrellas
37
Forks
8
Merge medio
14 h 16 min
PR fusionados (30 d)
244

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de hardbyte/awa

Todos los issues de hardbyte/awa

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.