Skip to content

Metrics

Queuety provides a metrics API that computes per-handler statistics from the log table. Use it for monitoring, dashboards, and alerting.

Handler statistics

Get metrics for all handlers within a time window:

PHP
$stats = Queuety::metrics()->handler_stats( 60 ); // last 60 minutes

Each entry in the returned array contains:

Field Description
handler Handler name
completed Number of successful executions
failed Number of failed attempts (failed and buried log events, so one job can count more than once)
avg_ms Average execution duration in milliseconds
p95_ms 95th percentile execution duration
error_rate Failure ratio from 0 to 1: failed / (completed + failed), rounded to four decimals

CLI

Shell
# Metrics for the last 60 minutes (default)
wp queuety metrics

# Metrics for the last 24 hours
wp queuety metrics --minutes=1440

# JSON output
wp queuety metrics --format=json

Example output:

Code
+------------------+-----------+--------+--------+--------+------------+
| handler          | completed | failed | avg_ms | p95_ms | error_rate |
+------------------+-----------+--------+--------+--------+------------+
| send_email       | 142       | 3      | 45     | 120    | 0.0207     |
| process_image    | 87        | 0      | 230    | 450    | 0          |
| call_openai      | 31        | 5      | 2100   | 4500   | 0.1389     |
+------------------+-----------+--------+--------+--------+------------+

Use cases

  • Dashboard widgets. Display throughput and error rates in the WordPress admin.
  • Health checks. Alert when a handler's error rate exceeds a threshold.
  • Performance tuning. Identify slow handlers using p95_ms and optimize them.
  • Capacity planning. Track throughput trends to size your worker pool.