Skip to content

feat(admin): live time-series trend on Metrics view (v26.05.09)#20

Merged
ancongui merged 1 commit into
mainfrom
feat/admin-metrics-live-trend
May 31, 2026
Merged

feat(admin): live time-series trend on Metrics view (v26.05.09)#20
ancongui merged 1 commit into
mainfrom
feat/admin-metrics-live-trend

Conversation

@ancongui
Copy link
Copy Markdown
Contributor

Summary

Brings live time-series to the admin Metrics view. Selecting a numeric metric now opens a rolling Chart.js trend that polls the metric on the configured refresh interval (60-point window), instead of a static value snapshot.

What's new

  • Live trend chart (themed via the existing charts.js Chart.js helper), polled at the admin refreshInterval.
  • Value / Rate (Δ/s) toggle — downward steps are shown honestly (a real gauge decrease or a counter reset on restart), not clamped; Rate applies to gauges too, so blanket-zeroing would be wrong.
  • Pause/Resume, a Current / Min / Max / Avg summary strip, and a measurement selector for multi-series (tagged) Prometheus metrics (switching reseeds the series).
  • The measurements table refreshes live alongside the chart.
  • Non-numeric metrics (e.g. python.version) show a snapshot + note instead of an empty chart.

Correctness / lifecycle

  • Race-safe: a load-generation token drops superseded detail fetches and in-flight poll ticks, so switching metrics can't write a stale reading into the new metric's chart/buffer.
  • The returned cleanup tears down the interval + destroys the chart on navigation — no dangling timers.
  • Responsive: list/detail split stacks on mobile and the canvas resizes. Verified zero horizontal overflow at 390px and side-by-side at 1440px, in dark + light themes.

Bonus: cache correctness

  • The SPA shell is now served with Cache-Control: no-cache so version-stamped (?v=…) asset URLs are revalidated after an upgrade. Previously a heuristically cached index.html could keep referencing the prior version's CSS/JS.

Verification

  • Verified live via Playwright on a running demo: chart render + polling, Value/Rate, Pause freezing the buffer, multi-measurement selector + reseed, non-numeric handling, light theme, mobile (no overflow, canvas resize), navigation cleanup (poll stops, canvas removed), and race-safe rapid switching.
  • Reviewed with a multi-agent adversarial workflow (4 dimensions, findings independently verified); the two confirmed findings — a poll-tick race and Rate-mode counter resets — are fixed/addressed in this PR.

Tests & gates

  • 2 new SPA-shell tests (no-cache header + ?v= version stamp).
  • ruff check ✓, ruff format --check ✓, mypy --strict (577 files) ✓, pytest tests/admin tests/web352 passed.

Version

Bumps to v26.05.09 (pyproject 26.5.9, __version__ = "26.05.09", uv.lock). CHANGELOG + admin docs updated.

Selecting a numeric metric now opens a rolling Chart.js time-series that
polls the metric on the configured refresh interval (60-point window),
replacing the static value snapshot:

- Value / Rate (Δ/s) toggle; downward steps shown honestly (gauge decrease
  or counter reset), not clamped — Rate applies to gauges too.
- Pause/Resume, Current/Min/Max/Avg summary, measurement selector for
  multi-series (tagged) Prometheus metrics (reseeds on switch), and a
  live-refreshing measurements table.
- Non-numeric metrics show a snapshot + note instead of an empty chart.
- Race-safe: a load-generation token drops superseded detail fetches AND
  in-flight poll ticks so a switch can't contaminate the new metric; the
  returned cleanup tears down the timer + chart on navigation (no leaks).
- Responsive split (stacks on mobile, canvas resizes); verified zero
  overflow at 390px and side-by-side at 1440px, dark + light themes.

Also: serve the SPA shell with Cache-Control: no-cache so version-stamped
(?v=) asset URLs are revalidated after an upgrade (a heuristically cached
index.html could otherwise keep pointing at the previous version's assets).

Tests: 2 new SPA-shell assertions (no-cache header + version stamp).
Gates green: ruff, ruff format, mypy --strict (577 files); 352 admin+web
tests pass. Verified live via Playwright (desktop/light/mobile/lifecycle).
@ancongui ancongui merged commit 2efd458 into main May 31, 2026
5 checks passed
@ancongui ancongui deleted the feat/admin-metrics-live-trend branch May 31, 2026 18:44
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.

1 participant