mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(fetcher): keep last-good counts on GitHub rate limits + expose fetch metrics
Rate-limited / 5xx / network failures were silently returning 0 from the
commit- and PR-count paths, then overwriting good values in fetcher.db —
turning a traffic spike into permanently-wrong "0 commits" cards. Raise
GitHubTransientError instead so the fetch aborts and the last-good row is
retained; genuine NOT_FOUND still yields 0.
Add a shared fetch-outcome counter (fetch_metrics table, spanning the web
workers and the cron container) surfaced at an unauthenticated GET /metrics
as ghstats_fetch_total{outcome="ok|not_found|rate_limited|error"}, so rate
limits are visible to the monitoring stack instead of dying silently.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18,9 +18,17 @@ def tick(hours: int, active_within_days: int, gc_days: int) -> dict:
|
||||
user = data.get("user")
|
||||
if user is None or (isinstance(user, dict) and user.get("message") == "Not Found"):
|
||||
data = {"error": "not_found"}
|
||||
db.bump_fetch_metric("not_found")
|
||||
else:
|
||||
db.bump_fetch_metric("ok")
|
||||
db.upsert_user(username, data)
|
||||
refreshed += 1
|
||||
except github.GitHubTransientError as e:
|
||||
db.bump_fetch_metric("rate_limited")
|
||||
log.warning("refresh rate-limited for %s (kept last-good): %s", username, e)
|
||||
failed += 1
|
||||
except Exception as e:
|
||||
db.bump_fetch_metric("error")
|
||||
log.warning("refresh failed for %s: %s", username, e)
|
||||
failed += 1
|
||||
gc_removed = db.delete_stale(days=gc_days)
|
||||
|
||||
Reference in New Issue
Block a user