Queue Monitor

Depth, throughput and whether the queue is keeping up. Depth alone says nothing — 40,000 draining at 5,000/s is fine, 300 draining at 2/s is an incident.

src/components/ui/queue-monitor.tsx

About

From the component's own source, where it was written.

Default label formatters, hoisted out of the parameter list.

An arrow function written inline as a default parameter is a value the React Compiler cannot safely reorder, so it bails on the whole component and none of it gets auto-memoised. At module scope it is a stable reference and the component compiles.

Install

npx astralyx-ui add queue-monitor

Usage

import { QueueMonitor } from '@/components/ui/queue-monitor'

<QueueMonitor name="emails" depth={1920} arrivalRate={42} completionRate={61} />

Composer

Change the props and the source below follows.

emails.outbound42.0 in / 61.0 out per s

1,920queued

draining, empty in 2m

processing
18
failed
94
dead letter
12
oldest
Props
tsx
<QueueMonitor
  name="emails"
  depth={1920}
  arrivalRate={42}
  completionRate={61}
/>

Examples

A queue draining

A queue backing up

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

QueueMonitor

Default label formatters, hoisted out of the parameter list.

Extends Omit<ComponentProps<'div'>, 'children'>.

PropTypeDefaultDescription
nameReactNoderequired—
depthnumberrequired—
processingnumber0—
failednumber0—
deadLetterednumber0Never folded into failed. A retryable failure is noise; an exhausted job is lost work a human must decide about.
arrivalRatenumber—Together they give the drain estimate. Set completions below arrivals in the composer to watch it flip to "growing".
completionRatenumber—Together they give the drain estimate. Set completions below arrivals in the composer to watch it flip to "growing".
oldestAtDate—Age of the oldest waiting job, not average wait — averages hide the one job stuck behind a poison message.
historynumber[]—Optional depth sparkline.
nowDate——
localestring'en-GB'—
depthLabelReactNode'queued'—
processingLabelReactNode'processing'—
failedLabelReactNode'failed'—
deadLetterLabelReactNode'dead letter'—
oldestLabelReactNode'oldest'—
drainingLabel(duration: string) => ReactNodeDEFAULT_DRAINING_LABELDrain estimate, given the formatted duration.
growingLabelReactNode'growing — arrivals exceed completions'—
idleLabelReactNode'idle'—