pub struct TaskQueueStats {
pub total_submitted: u64,
pub completed: u64,
pub failed: u64,
pub in_flight: u64,
pub total_latency_nanos: u128,
pub completed_latency_samples: u64,
}Expand description
Snapshot of task queue statistics for observability.
Obtained via TaskQueue::stats.
Fields§
§total_submitted: u64Total number of tasks submitted to the queue.
completed: u64Number of tasks that completed successfully.
failed: u64Number of tasks that failed (panicked).
in_flight: u64Number of tasks currently being executed by workers.
total_latency_nanos: u128Sum of end-to-end latencies (enqueue -> completion) in nanoseconds for every task that has finished (successfully or with a panic).
completed_latency_samples: u64Number of completed tasks that have contributed to total_latency_nanos.
Implementations§
Source§impl TaskQueueStats
impl TaskQueueStats
Sourcepub fn average_latency(&self) -> Option<Duration>
pub fn average_latency(&self) -> Option<Duration>
Return the average end-to-end task latency (enqueue -> completion).
Returns None when no tasks have completed yet.
§Example
use philiprehberger_task_queue::TaskQueue;
let queue = TaskQueue::new(1);
queue.submit(|| 1 + 1).join().unwrap();
let stats = queue.stats();
assert!(stats.average_latency().is_some());
queue.shutdown();Trait Implementations§
Source§impl Clone for TaskQueueStats
impl Clone for TaskQueueStats
Source§fn clone(&self) -> TaskQueueStats
fn clone(&self) -> TaskQueueStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for TaskQueueStats
impl RefUnwindSafe for TaskQueueStats
impl Send for TaskQueueStats
impl Sync for TaskQueueStats
impl Unpin for TaskQueueStats
impl UnsafeUnpin for TaskQueueStats
impl UnwindSafe for TaskQueueStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more