Skip to content

Add trigger-rate history storage, API and interactive viewer - #4

Open
jmbenlloch wants to merge 2 commits into
masterfrom
feature/rate-history
Open

jmbenlloch wants to merge 2 commits into
masterfrom
feature/rate-history

Conversation

@jmbenlloch

Copy link
Copy Markdown
Contributor

Duck currently retains only per-run rate summaries, so operators cannot inspect how the trigger rate evolved. This adds persistent per-GDC samples, a bounded counter-based history API, and an interactive current-run plot.

Changes

  • Store timestamped event/byte counters, current rates and run averages every approximately five seconds in rateSamples, while preserving rates summaries. Add indexed reads, idempotent writes, bounded retries and reset handling; associate samples with their message run.
  • Add GetRateHistory with whole-run or explicit time windows and a maximum of 2000 bins. Compute interval rates from counter differences, distribute deltas across bin boundaries and sum GDC contributions. Stream indexed reads in a read-only snapshot, include boundary samples and distinguish incomplete coverage from a measured zero.
  • Add an ECharts viewer with Auto polling, manual time windows, drag selection, persistent Back navigation, responsive layouts and current-run following. Small detector configurations show the table beside the plot; larger configurations remain stacked. Update generated Go/TypeScript clients.
  • Add an optional fluctuating simulator profile and UDP receiver-restart recovery. Keep simulator lifecycle messages separate from acquisition readiness. Add regression tests and a mocked Chromium flow covering selection, Back, adaptive requests and layout.

Validation

  • All 638 frontend unit tests passed before the final zoom-history test; all 21 focused zoom-history/statistics tests passed after that change.
  • Frontend type checking and production build passed.
  • Chromium flow passed for drag selection, Back, wheel zoom, UTC windows, Auto mode, current-run-only display, mobile layout, and small/large detector layouts.
  • Go race tests passed for the writer, history API and simulator; vet/build checks passed for the changed programs.
  • Isolated MySQL 9.7.4 tests verified migration repeatability, idempotent writes, run isolation, counter-based aggregation, boundary samples, resets and indexed reads.
  • A real one-LDC/one-GDC generator stack verified event flow, stored history, browser/WebSocket operation, finer zoom queries and automatic generator recovery across Stop/Start. The stack is now stopped; no detector deployment was changed.

The broader existing API race suite is not clean: TestUpdateRunStatistics_DisabledDevices_Skipped has a race reproduced on unchanged master. Focused history API race tests pass.

Deployment and limits

Apply database/migrations/20261104_add_rate_samples.sql to each acquisition schema before deploying the new reader. Deploy the API and frontend together for the viewer. GDC/LDC updates are not required; the simulator profile is optional and defaults to constant rate.

Coverage currently uses the GDCs observed in each run, explicitly reported as observed_run_history, rather than an expected-configuration snapshot. Reader retries use a bounded in-memory queue, not durable buffering. History reads have a ten-second deadline and still scale with the selected raw window; future caching/rollups can preserve the same API contract. The optional demo point limit is unset by default. Generated local demo configuration, database data and browser artifacts are excluded from the PR.

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