Skip to content

Introduce Comprehensive Background Worker Observability #396

Closed

Description

@RentnerKev

Analysis baseline: main @ 3ec3455 — 9 November 2026.

Priority: P3

Context / Current Behavior

Foundation health reports controller/database/Valkey connectivity. The existing authorized support export has a strict allowlist, partial/unavailable sections, component/revision metadata, aggregate certificate/job counts and a 64 KiB maximum. Rust has tracing and task-failure reporting; individual Bun workers log some availability transitions. Scale/reliability fixtures capture CPU, memory, connections and process file descriptors.

These foundations do not provide a consistent view of worker progress, oldest due work, exhausted deliveries, lease recovery or contention. Rust /ready confirms certificate/Caddy readiness and revision probing, not that every autonomous task is progressing. Process liveness and successful initialization alone cannot establish worker health.

Problem Statement

It is hard to distinguish an idle healthy worker from a stalled loop, admission saturation, slow upstreams, database contention or restore pause. Capacity and isolation decisions need separate measurements of throughput, delay, cost and recovery. Logging every job or labeling metrics by host/destination would create unacceptable overhead and disclosure risk.

Proposed Architecture / Solution

Add a small shared worker-status vocabulary and bounded aggregate metrics at existing execution/claim/commit boundaries. Use in-memory counters and fixed histograms for execution observations, with carefully bounded sampling of durable backlog/age where needed. Expose authorized aggregate diagnostics through the existing management/report path; no mandatory Prometheus, OpenTelemetry collector or new service.

Implementation Scope

  • Define stable subsystem IDs and states: starting, idle/running, retrying/degraded, maintenance-paused, stopping/stopped and failed, with last attempted/successful progress and next due/retry.
  • Measure execution/queue/scheduling duration, successes/failures, retry and exhausted counts, running jobs, backlog/oldest age, lease recovery and cancellation/drain outcomes.
  • Record configured/effective concurrency, utilization and admission/busy/rejection counts; separate interactive and scheduled diagnostics.
  • Sample DB lock wait/hold time, transaction timeout/pool utilization where available, plus event-loop lag and component resource usage through existing fixture/OS boundaries.
  • Use structured, bounded event names and safe correlation fields across Bun/controller boundaries. Avoid repeated outage spam and distinguish recovery events.
  • Define reset/epoch and counter-overflow behavior; absent evidence must be unavailable/unknown, never healthy zero.
  • Add diagnostics fields compatibly, explicitly versioning the support contract if required and preserving its size/sanitization limits.
  • Keep status collection off hot request paths; no full history scans, unbounded per-policy objects or per-request reconstruction of global state just to render metrics.

Security and Reliability Considerations

Retain export permissions, no automatic upload and allowlisted aggregate output. Never include domains, upstream addresses, recipients, Docker labels, payloads, credentials, keys, raw errors or high-cardinality IDs as metric labels. Bound histogram buckets, retained time windows and log rates. Observability failure must not stop workers or hold database locks longer. Separate management readiness, proxy readiness and worker degradation; do not make one optional integration outage shut down healthy traffic.

Acceptance Criteria

  • Every significant subsystem in Define Long-Term Rust Background Runtime Ownership #401 is represented with a stable owner, health/progress meaning and explicit intentional omissions.
  • Backlog, oldest pending/due age, running count, retries, admission failures and last progress distinguish healthy idle, overload, dependency outage and maintenance pause.
  • Fixed counters/histograms and bounded sampling have a predeclared measured CPU/RSS/query overhead budget; saturated label/payload inputs cannot increase metric cardinality without bound.
  • Existing management diagnostics/support export shows partial data when dependencies fail, within a verified size bound and compatible version contract.
  • Injected worker stall/failure/recovery produces truthful status and structured events without a success heartbeat based only on timer execution.
  • Secret/redaction tests cover nested hostile error/payload data and all new fields; unauthorized direct calls still fail.
  • Baseline/candidate evidence separately reports CPU, memory, throughput, latency, scalability and recovery rather than treating them as interchangeable improvements.

Testing Requirements

Extend existing support-report allowlist, authorization, aggregation and UI/service tests. Add deterministic clock/counter tests for idle, slow, failed, exhausted, reset and maintenance states; cardinality/size and logger-failure tests; bounded-load overhead measurements in #397. Verify diagnostics remain bounded when database/controller/Valkey are unavailable. No long soak is required for the first observability increment.

Dependencies / Related Issues

#177 already implemented sanitized runtime reports; extend it rather than replacing it. Can start alongside #401 and #397 without waiting for architecture migrations. #395 owns worker lifecycle changes; this issue owns observation/schema/diagnostics conventions. Capacity and isolation issues #392, #393, #399, #400 and #403 consume these measurements incrementally, without making unrelated implementation wait for every metric.

Relevant Source Files

Activity

  1. added this to the 3.2 milestone on Nov 9, 2026
  2. added
    enhancement
    area: runtime
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: runtimeenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions