-
-
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
23
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.
+6,118
−173
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9099ff2
feat(metrics-pipeline): generic Redis-stream to ClickHouse metrics pi…
ericallam ce924cd
feat(clickhouse): queue metrics tables and read queries
ericallam d86c584
feat(run-engine): emit queue depth, throughput, and scheduling-delay …
ericallam 173cf79
feat(webapp): queue metrics ingestion, admin controls, and emission s…
ericallam 1ab4747
feat(tsql): opt-in gap-fill for time-bucketed series
ericallam 7cd4648
feat(webapp): Queues dashboard and per-org metrics UI flag
ericallam 864bb08
chore(webapp): add server-changes note for queue metrics
ericallam 72e503d
chore: apply oxfmt formatting
ericallam 54775a1
chore: use import type for type-only imports
ericallam 5ed0838
fix(tsql): avoid polynomial backtracking in ORDER BY direction strip
ericallam 0c642e9
fix(tsql): strip ORDER BY direction without a backtracking regex
ericallam d1cb3fa
fix(clickhouse): remove semicolons from queue metrics migration comments
ericallam b6c626d
test(clickhouse): rewrite queue metrics test for cumulative counters
ericallam e08ee4f
fix(metrics-pipeline): use BigInt order keys and namespaced odometer …
ericallam 4d3ca7b
fix(clickhouse): filter zero waits from quantile view and accept stri…
ericallam 41f857e
fix(webapp): fail open on queue metrics and honor sparkline total ove…
ericallam 193ff71
test(run-engine): import describe from vitest in run-queue metrics test
ericallam 45e978d
fix(tsql): skip gap-fill on descending bucket order
ericallam 31fb262
fix(metrics-pipeline): widen order_key packing factor to 1e6
ericallam 5aa2259
feat(webapp,clickhouse): standard time filter for queue metrics pages
ericallam 7235f69
fix(tsql): register the deltaSumTimestampMerge aggregate
ericallam 84ecb0d
chore(webapp): use shared primitives on the admin queue metrics page
ericallam 9412bf5
feat(webapp): house style hero charts on the queues list
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Comma-joined queue names round-tripped through
split(",")can misparse names containing a literal comma.queuesKeyis joined with","purely to giveuseCallbacka stable primitive dependency, but it's then split back into the array sent in the request body. A queue name containing a comma would be incorrectly split into extra entries, corrupting thequeuesscope sent to/resources/metric.🐛 Proposed fix
Also applies to: 63-67