feat(observability): instrument REES + its main-app client with real Prometheus metrics#5398
Conversation
…Prometheus metrics REES (review-enrichment/) previously had zero /metrics — analyzer success/failure/ timeout rates and request outcomes were invisible. Adds a minimal in-process Prometheus registry to REES itself (request outcomes + per-analyzer run/duration, keyed by analyzer name and status), and separately instruments the main app's client-side call in enrichment-wire.ts (request outcome + latency, from the engine's own observable perspective). The Prometheus scrape target and Grafana dashboard (the remaining deliverables from issue 5367) follow in a separate PR. Part of #5365
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5398 +/- ##
==========================================
- Coverage 94.44% 94.40% -0.04%
==========================================
Files 551 551
Lines 44232 44244 +12
Branches 14657 14659 +2
==========================================
- Hits 41773 41768 -5
- Misses 1784 1801 +17
Partials 675 675
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-12 16:33:35 UTC
⏸️ Suggested Action - Manual Review
Review summary Blockers
Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
…"} outcome on a thrown /v1/enrich exception The /v1/enrich handler recorded ok/service_not_configured/unauthorized/bad_request outcomes, but a thrown exception (e.g. from buildBrief) skipped straight to Hono's app.onError, which has no access to startedAtMs -- so a real server-side failure was invisible in rees_enrich_requests_total despite "error" already being listed in the metric's own HELP text. Wraps the handler body in try/catch, records the outcome there, then rethrows so onError's existing 500 response + Sentry capture are unchanged.
Summary
review-enrichment/) previously had zero/metrics(confirmed live:GET /metrics-> 404) — analyzer success/failure/timeout rates and request outcomes were completely invisible.review-enrichment/src/metrics.ts), mirroring the shape of the main app'ssrc/selfhost/metrics.tspattern but scoped to REES's own much smaller needs (no gauges/redaction — REES is a separate deployable, sometimes run standalone on Railway per its own package description).brief.ts'srunAnalyzerat every one of its 5 outcome branches (ok/degraded/timeout/capped/skipped) withrees_analyzer_runs_total{analyzer,status}(counter) andrees_analyzer_duration_seconds{analyzer}(histogram, only for analyzers that actually executed).GET /metricstoreview-enrichment/src/server.ts, and instruments the/v1/enrichroute withrees_enrich_requests_total{status}+rees_enrich_request_duration_seconds.src/review/enrichment-wire.ts::buildReviewEnrichment— this measures REES from the engine's observable perspective (ok/empty/http_error/timeout/exception/skipped_auth_rejected), which is a genuinely different signal than REES's own server-side counters (e.g. it can distinguish a real timeout from the auth-rejected circuit breaker skipping the call entirely). New metric names registered insrc/selfhost/metrics.ts'sDEFAULT_METRIC_META.src/**changes (Codecov-gated);review-enrichment/has its own dedicated test suite (node --test, not Codecov-tracked — confirmed viacodecov.yml'signorelist only coveringsrc/**).The Prometheus scrape target and Grafana dashboard — the remaining deliverables from the tracking issue for this work — follow in a separate, smaller PR once this instrumentation is in place to query against.
Part of #5365.
Test plan
npm run typechecknpm run test:ci(full local gate: 15046 passed / 12 skipped)npm audit --audit-level=moderate— 0 vulnerabilitiesreview-enrichment's own test suite (npm testinsidereview-enrichment/): 1330 passed / 0 failed, including 18 new tests for the new metrics module +buildBrief's per-analyzer outcome recordingtest/unit/enrichment-wire.test.tscases cover every new branch (ok/empty/http_error/timeout/exception/skipped_auth_rejected), verified viarenderMetrics()output