Skip to content

[3/6] Add the /ui/analytics page - #390

Merged
andrew merged 2 commits into
git-pkgs:mainfrom
wickedOne:analytics-3-page
Oct 2, 2026
Merged

andrew merged 2 commits into
git-pkgs:mainfrom
wickedOne:analytics-3-page

Conversation

@wickedOne

@wickedOne wickedOne commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

/ui/analytics: download volume, per-ecosystem breakdown and a runtime card

Part 3 of six splitting #381 ("analytics dashboard") into reviewable pieces, as the review there asked for. #381 stays open as the umbrella and reference thread until the last of these lands; it is not meant to be merged.

Series: #388 route coverage · #389 ecosystem stats · #390 analytics page · #391 /stats breakdown · #392 Grafana dashboard · #393 source attribution

Needs #389, and branches off it, so until #389 merges the Files changed tab here shows both. The last commit is this part.

/ui/ reported what the cache holds but nothing about what it has served, and most of what /metrics exposes had no home in the UI at all. This adds a second page.

The page carries a ring of download size by ecosystem with the total in the middle (six slices maximum, the tail folded into "Other" and named in the legend), the cache figures from /ui/, a per-ecosystem table, the vulnerability overview, and a Runtime card covering every remaining metric.

No history is stored

The proxy keeps no time series. The page reads the database and the in-process registry at request time and reports current state; history, trends and alerting are Prometheus and Grafana's job. That splits the figures in two and the page says which is which: database-derived figures survive a restart, while everything in the Runtime card lives only in this process's registry and restarts from zero.

When the aggregation fails but a previous snapshot was retained, the page serves the stale figures behind an amber banner saying when they were read. Without that distinction a database down for an hour renders hour-old numbers as current, with the failure visible only in the logs.

Also in here

metrics.Gather() and a small Snapshot type, so the UI can render counters that were never in the database. The Runtime card is its only caller, which is why this is not in part 2.

proxy_response_bytes_total{ecosystem} and byte counting on the response writer -- the Runtime card's "Served" tile is its first consumer. The ecosystem label here comes from the request path, not the package record; the README now sets out all three label sets side by side, since that is the thing most likely to produce a wrong query.

The Security Overview block moves out of dashboard.html into a shared component so the two pages cannot drift.

TestEveryMetricIsSurfaced makes the page a required consumer of every future metric: adding one fails the build until a tile exists. That is deliberate, and per the review it is now written down rather than discovered -- a comment on metricSurface and a line under Code Style in CONTRIBUTING.md.

avgArtifactSize returned an em dash for the empty case, flagged in the review; it returns 0 B. joinLabels and formatDuration return -, where 0 B would be meaningless.

@wickedOne wickedOne changed the title Analytics page Add the /ui/analytics page Oct 1, 2026
@wickedOne wickedOne changed the title Add the /ui/analytics page [3/6] Add the /ui/analytics page Oct 1, 2026
wickedOne and others added 2 commits October 1, 2026 16:15
- 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>
@andrew
andrew merged commit 31b7378 into git-pkgs:main Oct 2, 2026
6 checks passed
@wickedOne
wickedOne deleted the analytics-3-page branch October 2, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants