[2/6] Per-ecosystem cache and download statistics - #389
Merged
Merged
Conversation
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>
wickedOne
force-pushed
the
analytics-2-ecosystem-stats
branch
from
October 1, 2026 14:19
94f3934 to
4ebd805
Compare
…-stats # Conflicts: # README.md
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.
Per-ecosystem cache and download statistics
/metricsreported cache size and artifact count as single numbers with no breakdown, and the database had the figures to break them down all along:artifacts.hit_count x artifacts.size, summed per ecosystem, is the bytes the proxy has actually handed to clients from cache.GetEcosystemStats()returns per-ecosystem packages, versions, artifacts, cache size, downloads and downloaded bytes. It is several grouped aggregations merged in Go rather than one join, so ecosystems with nothing cached still appear and theartifactstable stays optional for a database inherited from git-pkgs. Six gauges are published from it on the existing one-minute cache-stats tick, so the added background cost is a multiple of work that already happened rather than something new.Two details worth a look:
Artifacts whose version or package row has gone missing are reported under
unattributedrather than dropped, so the per-ecosystem figures still add up toproxy_cache_size_bytesandproxy_cached_artifacts_total. A non-zerounattributedis a signal about the database, not noise.The gauges are
Setand selectively deleted rather thanResetand repopulated.Resetfollowed by a repopulating loop leaves a window in which a scrape sees the families empty or half filled, which renders as a gap on any panel built from them. Rows are summed per label first, because normalizing collapses aliases and a database holding bothgemandrubygemsrows arrives as two rows belonging to one label.These are gauges rather than counters because eviction clears an artifact's size and drops its past hits out of the total, so the figure can step downwards. The README says so, and says to chart them with
max_over_timerather thanincrease.New metrics
proxy_ecosystem_downloaded_bytes,proxy_ecosystem_artifact_downloads,proxy_ecosystem_cache_size_bytes,proxy_ecosystem_cached_artifacts,proxy_ecosystem_packages,proxy_ecosystem_versions, all labelledecosystem.Two of these were
proxy_downloaded_bytesandproxy_artifact_downloadsin #381. Renamed to share the prefix with the other four, per the review there -- nothing is published yet, so it costs nothing now and would be a break later.