DurableDashboard.Metrics (DurableDashboard v0.1.0-rc)

Copy Markdown View Source

Dashboard-specific aggregation queries for the overview metrics page.

These are presentation-layer computations — time-windowed throughput, success rates, duration percentiles — that don't belong in the Durable runtime API (Durable.Query). They only read from the existing WorkflowExecution and StepExecution schemas.

Summary

Functions

Duration percentiles (p50, p95, p99) from completed workflows in the window.

Queue depth — count of pending + running workflows per queue.

Status breakdown for the given time window.

Workflow throughput bucketed by 5-minute intervals.

Top failing workflow names in the last 24 hours.

Functions

duration_percentiles(durable, window_minutes \\ 1440)

Duration percentiles (p50, p95, p99) from completed workflows in the window.

Uses PostgreSQL's percentile_cont ordered-set aggregate function. Returns %{p50: ms, p95: ms, p99: ms} or zeroed values if no data.

queue_depth(durable)

Queue depth — count of pending + running workflows per queue.

Returns %{"default" => 5, "priority" => 2}.

status_breakdown(durable, window_minutes \\ 1440)

Status breakdown for the given time window.

Returns %{"completed" => N, "failed" => N, ...}.

throughput(durable, window_minutes \\ 60)

Workflow throughput bucketed by 5-minute intervals.

Returns a list of %{time: iso8601, count: integer} maps ordered by time, covering the last window_minutes.

top_failing(durable, limit \\ 5)

Top failing workflow names in the last 24 hours.

Returns [%{name: "process_order", count: 12}, ...] ordered by count desc.