-
-
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
40
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.
+8,229
−179
Open
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
73efe53
feat(metrics-pipeline): generic Redis-stream to ClickHouse metrics pi…
ericallam 7c7e9f0
feat(clickhouse): queue metrics tables and read queries
ericallam dbd725e
feat(run-engine): emit queue depth, throughput, and scheduling-delay …
ericallam 761ebbe
feat(webapp): queue metrics ingestion, admin controls, and emission s…
ericallam a3d88c1
feat(tsql): opt-in gap-fill for time-bucketed series
ericallam e44e3ce
feat(webapp): Queues dashboard and per-org metrics UI flag
ericallam 9036161
chore(webapp): add server-changes note for queue metrics
ericallam a9003c0
chore: apply oxfmt formatting
ericallam 118a18d
chore: use import type for type-only imports
ericallam 79660ad
fix(tsql): avoid polynomial backtracking in ORDER BY direction strip
ericallam 83cb71d
fix(tsql): strip ORDER BY direction without a backtracking regex
ericallam f2f1921
fix(clickhouse): remove semicolons from queue metrics migration comments
ericallam f088d4a
test(clickhouse): rewrite queue metrics test for cumulative counters
ericallam 24cdb36
fix(metrics-pipeline): use BigInt order keys and namespaced odometer …
ericallam 28a0c91
fix(clickhouse): filter zero waits from quantile view and accept stri…
ericallam 877519c
fix(webapp): fail open on queue metrics and honor sparkline total ove…
ericallam 7a0f14e
test(run-engine): import describe from vitest in run-queue metrics test
ericallam a9ac17a
fix(tsql): skip gap-fill on descending bucket order
ericallam 969cf88
fix(metrics-pipeline): widen order_key packing factor to 1e6
ericallam 1f4249e
feat(webapp,clickhouse): standard time filter for queue metrics pages
ericallam a2ab1dc
fix(tsql): register the deltaSumTimestampMerge aggregate
ericallam 3131fc5
chore(webapp): use shared primitives on the admin queue metrics page
ericallam aea59d9
feat(webapp): house style hero charts on the queues list
ericallam 42139c2
feat(clickhouse): queue activity ranking queries
ericallam 52ee876
feat(webapp): queue allocation view and relevance-ordered queue list
ericallam 23ea178
fix(tsql): inject time fallbacks into FROM subqueries
ericallam 0a2ce25
feat(clickhouse,tsql): queue metrics rollups and single-scan ranking
ericallam cde3fa0
feat(webapp): serve queue metrics reads from rollups and fix env totals
ericallam c29f8bd
feat(clickhouse,webapp): keep 10-second resolution on the env metrics…
ericallam 3991214
fix(webapp): include rollup tables in the queue metrics simulator reset
ericallam 3c59e8b
fix(webapp): update the queue metrics simulator for cumulative counters
ericallam fc40fa2
feat(webapp): stage fake Redis usage from the queue metrics simulator
ericallam 5851eb7
fix(webapp): keep the search filter on the ranked queue list's tail
ericallam 6ed899a
fix(metrics-pipeline): drop metric emits while the metrics Redis is n…
ericallam 9750ceb
feat(webapp): remove auto-balance from the allocation view
ericallam e6ae16e
feat(tsql,webapp): reject cross-queue merges of per-queue counter states
ericallam cbe5444
refactor(clickhouse,webapp): use the stored quantile list in all merg…
ericallam 5511df5
fix(tsql): satisfy the tenant column type in the merge guard test schema
ericallam f339c97
fix(clickhouse): dedup retried metric batches in the MV target tiers
ericallam b7f943d
fix(webapp,metrics-pipeline): review hardening for overflow counters,…
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.
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.