Skip to content

feat(selfhost): enrichment observability — Prometheus counters + Grafana/Loki wiring #1479

Description

@JSONbored

Context

Final slice of the review-enrichment track. The engine seam already emits a selfhost_enrichment_failed warn log; add the Prometheus counters so the existing Grafana/Loki stack observes enrichment volume, failures, and latency, matching how the rest of the self-host engine is instrumented.

Requirements

  • Add gittensory_enrichment_requests_total, gittensory_enrichment_failed (or _total), and an elapsed/latency metric (gittensory_enrichment_elapsed), incremented in src/review/enrichment-wire.ts around the POST (success, failure, elapsed) — mirroring how existing self-host counters are registered/incremented.
  • Keep the metrics on the engine side (the same Prometheus registry the rest of the engine uses); the service can expose its own /metrics later if needed but is out of scope here.
  • No behavior change when the feature is off (a never-called builder increments nothing).

Deliverables

  • Counter registration + increments in src/review/enrichment-wire.ts (and wherever the engine registers Prometheus metrics).
  • Optionally add an enrichment row/panel to the relevant Grafana dashboard JSON so operators see request/failure/latency at a glance.

Acceptance criteria

  • With the feature on, a successful enrich increments _requests_total and records elapsed; a timeout/non-200 increments _failed. With the feature off, no counter moves.
  • Tests cover the success and failure increment paths (both arms) to 97% branch-counted patch on the touched src/** lines.
  • npm run test:coverage (unsharded) 100% patch; npm run test:ci green; npm audit --audit-level=moderate clean. Grafana JSON (if touched) remains valid.

Parent: #1029

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

    Projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions