feat(webapp): default the queue metrics period to 1 hour and remember it - #4438
feat(webapp): default the queue metrics period to 1 hour and remember it#4438ericallam wants to merge 7 commits into
Conversation
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughQueue metrics now use shared period utilities. The utilities validate periods, read remembered periods from cookies, persist valid selections, resolve URL or default values, apply organization limits, and clip query windows. Queue list and queue detail pages derive defaults from requests, resolve metric ranges, and remember selected periods. Metric cards and concurrency-key resources use the shared default period and query-window limits. A changelog entry documents the behavior. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The Queues list and queue detail pages opened on a 1 day window and reset to it on every navigation. They now default to 1 hour, and the last period picked is kept in a cookie the loaders read, so the first render is already on the remembered window instead of painting the default and re-fetching. Both pages resolve the period once (URL param, then absolute range, then the remembered default) and pass it down, so the picker and every chart query agree on one value. Absolute from/to ranges are not remembered.
…c periods A hand-edited `?period=garbage` or `?period=9999d` was passed straight to the metric queries, so the charts and the SSR'd table could end up on different windows. Period resolution now rejects anything the picker could not produce (including windows past the 30 day retention), and the queues list loader resolves through the same path the client queries use.
The queue-metric queries that go straight to ClickHouse (the queues list table and the concurrency-keys endpoint) never applied the org's query-period limit, so a hand-typed `?period=` could read further back than the plan allows. Every query through executeQuery is already clipped this way; both of these now clip with the same limit, capped at the 30 day retention. A remembered period longer than the plan allows is clamped to the plan maximum, and the picker now renders the resolved window rather than the raw search param, so the label can no longer disagree with the data on screen. The plan cap is resolved once per load and handed to the page, replacing the copy each route derived from the client-side subscription.
87dc09a to
7c6cbec
Compare
@trigger.dev/build
trigger.dev
@trigger.dev/core
@trigger.dev/python
@trigger.dev/react-hooks
@trigger.dev/redis-worker
@trigger.dev/rsc
@trigger.dev/schema-to-json
@trigger.dev/sdk
commit: |
A date range that ends before the plan's earliest queryable time had its start pulled forward past its own end, sending an inverted window to ClickHouse. It now collapses to an empty window, which is what the enforced lower bound in executeQuery produces for the same request: no rows.
The period pattern only accepted a count of up to four digits, so a custom duration the picker allows (10000 minutes, a little under 7 days) was treated as unusable and quietly replaced with the default. The count is now unbounded and the retention bound is what rules a window out. Resolution also clamps the period from the URL, not just the remembered default, so a period wider than the plan's query period shows the window the data actually covers instead of the one that was asked for. The plan lookup reads through the limit cache and is skipped entirely on the classic Queues page, which has no time filter: the page revalidates on an interval, so an uncached platform call would repeat for the life of the tab.
…es it Rounding the plan's query period up to a whole day would have let these pages read further back than every other metric query for a sub-day limit. The budget is now used as-is, matching the bound executeQuery enforces, and the period string derived from it steps down to hours or minutes so a fractional budget still yields a window inside it.
c40f779 to
e59f65a
Compare
The query-period lookup runs before the block that renders the Queues page without metrics when ClickHouse is unavailable, so a failure reading the limit would have cost the whole page rather than the time filter. It now falls back to the retention cap, which is the widest window the data can cover anyway.
e59f65a to
c699187
Compare
Summary
The Queues list and queue detail pages opened on a 1 day window, and went back to it every time you navigated between queues or reloaded. They now default to the last hour, and the period you pick is remembered across navigations and refreshes.
Design
The last period is stored in a
queueMetricsPeriodcookie, written client-side whenever aperiodlands in the URL and read by both loaders. A cookie rather than localStorage because the queues list renders its per-queue metrics columns server-side: with localStorage the page would paint the 1 hour default and then re-fetch, and the picker would flash the wrong window.Both pages resolve the window once, in one place, and pass it down:
That keeps the picker pill and every chart query on the same value, so no call site falls back to its own default. Periods the picker could never produce (a hand-edited
?period=garbage, or a window past the 30 day retention) fall back to the default, and the picker renders the resolved window rather than the raw search param so the label can't disagree with the data. Absolute from/to ranges, including drag-to-zoom, are not remembered, since they would pin later visits to a window that has gone stale.While wiring that up: the two queue-metric queries that go straight to ClickHouse (the list table and the concurrency-keys endpoint) never applied the org's
queryPeriodDayslimit, so a hand-typed?period=read further back than the plan allows. Everything behind/resources/metricis already clipped that way byexecuteQuery; both of these now clip with the same limit, capped at the retention window, and the plan cap is resolved once per load and handed to the page instead of each route deriving its own copy from the client-side subscription.Verified on both pages: default with no cookie is 1 hr, picking 6 hrs survives navigating away and back to a param-free URL and a hard reload, clearing the cookie returns to 1 hr, an oversized period falls back without being remembered, and an absolute range still renders as a range.