-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(webapp,run-engine): queue metrics and health dashboard #4131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ericallam
wants to merge
36
commits into
main
Choose a base branch
from
feat/queue-metrics-and-health
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
c0d5a54
feat(metrics-pipeline): generic Redis-stream to ClickHouse metrics pi…
ericallam 09ab1b1
feat(clickhouse): queue metrics tables and read queries
ericallam c32a1cd
feat(run-engine): emit queue depth, throughput, and scheduling-delay …
ericallam 2d3d32d
feat(webapp): queue metrics ingestion, admin controls, and emission s…
ericallam 305e9a6
feat(tsql): opt-in gap-fill for time-bucketed series
ericallam 982be50
feat(webapp): Queues dashboard and per-org metrics UI flag
ericallam 0143080
chore(webapp): add server-changes note for queue metrics
ericallam d193dc3
chore: apply oxfmt formatting
ericallam bcb017d
chore: use import type for type-only imports
ericallam 946a24d
fix(tsql): avoid polynomial backtracking in ORDER BY direction strip
ericallam 06bb476
fix(tsql): strip ORDER BY direction without a backtracking regex
ericallam e848045
fix(clickhouse): remove semicolons from queue metrics migration comments
ericallam c7befb3
test(clickhouse): rewrite queue metrics test for cumulative counters
ericallam 8cd41b7
fix(metrics-pipeline): use BigInt order keys and namespaced odometer …
ericallam 70f520d
fix(clickhouse): filter zero waits from quantile view and accept stri…
ericallam 5e19143
fix(webapp): fail open on queue metrics and honor sparkline total ove…
ericallam 4b465b7
test(run-engine): import describe from vitest in run-queue metrics test
ericallam 9ce3bd2
fix(tsql): skip gap-fill on descending bucket order
ericallam a33912b
fix(metrics-pipeline): widen order_key packing factor to 1e6
ericallam 9577316
feat(webapp,clickhouse): standard time filter for queue metrics pages
ericallam fa40e59
fix(tsql): register the deltaSumTimestampMerge aggregate
ericallam 79ca47f
chore(webapp): use shared primitives on the admin queue metrics page
ericallam ab0284a
feat(webapp): house style hero charts on the queues list
ericallam ec4d032
feat(clickhouse): queue activity ranking queries
ericallam fbaa4be
feat(webapp): queue allocation view and relevance-ordered queue list
ericallam 3b4722c
fix(tsql): inject time fallbacks into FROM subqueries
ericallam d60696c
feat(clickhouse,tsql): queue metrics rollups and single-scan ranking
ericallam c28b6cf
feat(webapp): serve queue metrics reads from rollups and fix env totals
ericallam df0bbe1
feat(clickhouse,webapp): keep 10-second resolution on the env metrics…
ericallam efdd64f
fix(webapp): include rollup tables in the queue metrics simulator reset
ericallam d162dcf
fix(webapp): update the queue metrics simulator for cumulative counters
ericallam 3c67a0c
feat(webapp): stage fake Redis usage from the queue metrics simulator
ericallam bbd3eaa
fix(webapp): keep the search filter on the ranked queue list's tail
ericallam 279db19
fix(metrics-pipeline): drop metric emits while the metrics Redis is n…
ericallam 23de76b
feat(webapp): remove auto-balance from the allocation view
ericallam c8af713
feat(tsql,webapp): reject cross-queue merges of per-queue counter states
ericallam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| area: webapp | ||
| type: feature | ||
| --- | ||
|
|
||
| Queue metrics and health on the Queues page: per-queue depth, throughput, concurrency, throttling, and scheduling-delay charts, plus a per-queue detail view. Off by default; enabled per organization. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||
| import { useInterval } from "./useInterval"; | ||
|
|
||
| export type MetricResourceRow = Record<string, number | string | null>; | ||
|
|
||
| type MetricResourceResponse = | ||
| | { success: true; data: { rows: MetricResourceRow[] } } | ||
| | { success: false; error: string }; | ||
|
|
||
| export type MetricResourceTimeRange = { | ||
| period: string | null; | ||
| from: string | null; | ||
| to: string | null; | ||
| }; | ||
|
|
||
| export type MetricResourceQueryOptions = { | ||
| organizationId: string; | ||
| projectId: string; | ||
| environmentId: string; | ||
| timeRange: MetricResourceTimeRange; | ||
| defaultPeriod: string; | ||
| queues?: string[]; | ||
| fillGaps?: boolean; | ||
| refreshIntervalMs?: number; | ||
| }; | ||
|
|
||
| /** | ||
| * Client-fetch a TRQL query from the metric resource route (like the dashboard | ||
| * widgets): own loading state, interval + on-focus refresh, abort on change/unmount. | ||
| */ | ||
| export function useMetricResourceQuery(query: string, opts: MetricResourceQueryOptions) { | ||
| const [rows, setRows] = useState<MetricResourceRow[] | null>(null); | ||
| const [isLoading, setIsLoading] = useState(true); | ||
| const [failed, setFailed] = useState(false); | ||
| const abortRef = useRef<AbortController | null>(null); | ||
|
|
||
| const { | ||
| organizationId, | ||
| projectId, | ||
| environmentId, | ||
| defaultPeriod, | ||
| fillGaps, | ||
| refreshIntervalMs = 60_000, | ||
| } = opts; | ||
| const { period, from, to } = opts.timeRange; | ||
| const queuesKey = opts.queues && opts.queues.length > 0 ? opts.queues.join(",") : undefined; | ||
|
|
||
| const load = useCallback(() => { | ||
| abortRef.current?.abort(); | ||
| const controller = new AbortController(); | ||
| abortRef.current = controller; | ||
| setIsLoading(true); | ||
| fetch("/resources/metric", { | ||
| method: "POST", | ||
| headers: { "Content-Type": "application/json" }, | ||
| body: JSON.stringify({ | ||
| query, | ||
| scope: "environment", | ||
| period: period ?? (from || to ? null : defaultPeriod), | ||
| from, | ||
| to, | ||
| fillGaps: !!fillGaps, | ||
| organizationId, | ||
| projectId, | ||
| environmentId, | ||
| ...(queuesKey !== undefined ? { queues: queuesKey.split(",") } : {}), | ||
| }), | ||
| signal: controller.signal, | ||
| }) | ||
| .then((res) => res.json() as Promise<MetricResourceResponse>) | ||
| .then((data) => { | ||
| if (controller.signal.aborted) return; | ||
| if (data.success) { | ||
| setRows(data.data.rows); | ||
| setFailed(false); | ||
| } else { | ||
| setFailed(true); | ||
| } | ||
| setIsLoading(false); | ||
| }) | ||
| .catch((error) => { | ||
| if (error instanceof DOMException && error.name === "AbortError") return; | ||
| if (!controller.signal.aborted) { | ||
| setFailed(true); | ||
| setIsLoading(false); | ||
| } | ||
| }); | ||
| }, [ | ||
| query, | ||
| period, | ||
| from, | ||
| to, | ||
| defaultPeriod, | ||
| fillGaps, | ||
| organizationId, | ||
| projectId, | ||
| environmentId, | ||
| queuesKey, | ||
| ]); | ||
|
|
||
| useEffect(() => { | ||
| load(); | ||
| return () => abortRef.current?.abort(); | ||
| }, [load]); | ||
|
|
||
| useInterval({ interval: refreshIntervalMs, onLoad: false, onFocus: true, callback: load }); | ||
|
|
||
| return { rows: rows ?? [], isLoading, showLoading: isLoading && !rows, failed }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.