fix(metrics): stop the datapoints tab scanning every metric row ever written

/metrics?tab=datapoints with no time parameters did not load at all. Utils.parseTime
returns (Nothing, Nothing) when given no from/to/since — unlike TimePicker.parseTimeRange,
which falls back to defaultSince — and getDataPointsData only emitted its date filter when
the upper bound was present. So the tab ran

  SELECT metric_name, COUNT(*) FROM otel_metrics WHERE project_id = ? GROUP BY metric_name

across the project's entire metrics history, inline, blocking the page. On the demo project
(~2.4M metric rows per hour) it never returns: TimeFusion cancels it with 57014 statement
timeout and the page renders nothing. Unbounded aggregates are also what has OOM-killed
TimeFusion before.

Two halves. The window is now required rather than (Maybe, Maybe), so the query cannot be
built without one — the caller has to decide, instead of silently getting no filter. And the
handler falls back to the time picker's own defaultSince, so the control and the data agree
rather than the picker reading empty while the query scans everything.

Verified: ?tab=datapoints answered in 2.5s with a window and hung without one; the existing
Test 4.1 covers the no-parameter call and now asserts the picker shows its default.
This commit is contained in:
Anthony Alaribe 2026-09-02 09:43:36 +02:00
commit 6cf9b1715d
4 changed files with 31 additions and 9 deletions