fix(discovery-index): record the declared cache-lookup and github-request-outcome metrics#7500
Conversation
…uest-outcome metrics
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
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 #7500 +/- ##
==========================================
- Coverage 91.41% 91.40% -0.02%
==========================================
Files 717 717
Lines 73036 73047 +11
Branches 21635 21638 +3
==========================================
Hits 66766 66766
- Misses 5227 5234 +7
- Partials 1043 1047 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-20 13:57:17 UTC
Review summary Nits — 4 non-blocking
Flagged checks (non-blocking)
Decision drivers
Context & advisory signals — never blocks the verdict
Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver 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://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
What
Wires up two metrics that
packages/discovery-indexalready declares inDEFAULT_METRIC_METAbut never actually records, sodiscovery_index_cache_lookups_totalanddiscovery_index_github_requests_totalstay at zero on a live instance.Closes #7432
Details
discovery-query.ts— at bothTtlCache.getOrComputecall sites (the result cache inrunDiscoveryQuery, the policy cache inresolveRepoAiPolicy), recorddiscovery_index_cache_lookups_total { cache: "result"|"policy", outcome: "hit"|"miss" }."miss"= the compute callback actually ran;"hit"= it didn't. Detected with amissedflag set as the first line of the compute callback, thenincr(...)after the call resolves.github-client.ts— infetchWithRetry, recorddiscovery_index_github_requests_total { outcome: "ok"|"retried"|"failed" }: one"retried"immediately before eachsleepFn(per attempt beyond the first), and one"ok"/"failed"(response.ok ? "ok" : "failed") at the return — the retried increments are in addition to, never instead of, the terminal ok/failed. Adds the file's firstimport { incr } from "./metrics.js".No retry/return logic changed, and
DEFAULT_METRIC_META/ the metric contract is untouched — this is purely wiring the missingincr()calls.Validation
test/unit/discovery-index/{discovery-query,github-client}.test.ts: cache miss-then-hit for both the result and policy caches; a single 200 → oneok; a 500-then-200 → oneretried+ oneok; an all-500 max-attempts exhaustion →retried-per-extra-attempt + onefailed. Counters are reset per test.git diff --checkclean; the discovery-index contract test still passes (18/18).