[4/6] Report the per-ecosystem breakdown from GET /stats - #391
Merged
Merged
Conversation
This was referenced Oct 1, 2026
This was referenced Oct 1, 2026
- Add GetEcosystemStats, aggregating packages, versions, artifacts, cache size, downloads and downloaded bytes per ecosystem - Publish six proxy_ecosystem_* gauges from it on the existing one-minute cache-stats tick - Set and selectively delete rather than Reset, so no scrape lands on a half-populated vector - Report artifacts with no package row under "unattributed" rather than dropping them, so the figures still add up Part 2 of 6 splitting git-pkgs#381 up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Ring of download size by ecosystem, cache figures, per-ecosystem table, vulnerability overview and a Runtime card - Add metrics.Gather so the page can render counters that were never in the database - Add proxy_response_bytes_total and response-writer byte counting - Serve a retained snapshot behind a staleness banner when the aggregation fails, rather than rendering old figures as current - Extract the security overview into a shared component Part 3 of 6 splitting git-pkgs#381 up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- Add downloaded_bytes, downloads and an ecosystems array, served from the snapshot the gauges and the page already share - Add stats_unavailable so a failed aggregation is distinguishable from an idle proxy - Regenerate the OpenAPI spec Part 4 of 6 splitting git-pkgs#381 up. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
wickedOne
force-pushed
the
analytics-4-stats-breakdown
branch
from
October 1, 2026 14:19
f169c81 to
4b8c5a8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /statsreports the per-ecosystem breakdown/statsanswered from two cheap counters. It now also carriesdownloaded_bytes,downloadsand anecosystemsarray, served from the same 60-second snapshot the gauges and the analytics page read, so a polling client does not re-run the aggregation per request.stats_unavailableRaised in the review of #381: when the aggregation fails with no retained snapshot, zeros and an empty array are indistinguishable from an idle proxy for anything consuming the JSON. The response now carries
stats_unavailable: truein that case.It is a new field with
omitemptyrather than pointer totals, so the field set stays stable for existing consumers and a healthy response is byte-identical to one without the flag. A retained snapshot is served on without the flag -- those figures are stale, not absent, and staleness is surfaced to a human on the page rather than to a machine here.The comment above the call in #381 claimed the breakdown is omitted when there is no snapshot. That held for the array but not for the totals; it now says what the code does.
The endpoint keeps answering with the artifact count and cache size either way: a failing breakdown does not take down an endpoint that worked before it existed.
Tests cover all three states. There were none for the
/statsshape before.