QueueMetrics class
Tracks real-time metrics for the queue system.
Provides counters and timing data for monitoring queue health, including throughput, failure rates, and processing durations.
final metrics = QueueMetrics();
worker.onComplete = (job) => metrics.recordSuccess(job);
worker.onFail = (job) => metrics.recordPermanentFailure(job);
// Later, inspect:
print(metrics.snapshot);
Constructors
- QueueMetrics()
- Creates a new QueueMetrics instance.
Properties
- averageProcessingTimeMs → double
-
Average processing time in milliseconds, or 0 if no data.
no setter
- failureRate → double
-
Failure rate as a percentage (0–100).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- p95ProcessingTimeMs → double
-
95th percentile processing time in milliseconds.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
snapshot
→ Map<
String, dynamic> -
Returns a point-in-time snapshot of all metrics.
no setter
- throughput → double
-
Throughput: jobs completed per second since start.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recordDispatch(
) → void - Records a job being dispatched.
-
recordPermanentFailure(
) → void - Records a permanent failure (dead letter).
-
recordProcessing(
) → void - Records a job being picked up for processing.
-
recordProcessingRetry(
) → void - Records a job being retried.
-
recordRetry(
) → void - Records a job failure that will be retried.
-
recordSuccess(
Duration duration) → void -
Records a successful job completion with its
duration. -
recordTimeout(
) → void - Records a job that was killed due to timeout.
-
reset(
) → void - Resets all counters. Useful for testing.
-
start(
) → void - Call when the metrics system starts tracking (e.g., when the worker starts).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited