Skip to main content

ExecutorMetrics

Struct ExecutorMetrics 

Source
pub struct ExecutorMetrics {
    pub tasks_spawned: AtomicU64,
    pub tasks_completed: AtomicU64,
    pub tasks_failed: AtomicU64,
    pub tasks_cancelled: AtomicU64,
    pub total_execution_time: AtomicU64,
    pub active_workers: AtomicUsize,
    pub idle_workers: AtomicUsize,
    pub total_workers: AtomicUsize,
    pub pending_tasks: AtomicUsize,
    pub max_queue_depth: AtomicUsize,
    pub started_at: Instant,
    pub last_updated_after_ns: AtomicU64,
}
Expand description

Executor performance metrics.

Every field is written by a real production path; untracked quantities (process memory, CPU utilization) deliberately have no fields here.

Fields§

§tasks_spawned: AtomicU64

Tasks accepted by the executor.

§tasks_completed: AtomicU64

Tasks whose body ran to completion.

§tasks_failed: AtomicU64

Tasks whose body panicked or reported failure.

§tasks_cancelled: AtomicU64

Tasks whose cancel request was honored before the body ran.

§total_execution_time: AtomicU64

Accumulated task body execution time in nanoseconds.

§active_workers: AtomicUsize

Workers currently running a task body.

§idle_workers: AtomicUsize

Workers parked waiting for work.

§total_workers: AtomicUsize

Workers owned by the pool.

§pending_tasks: AtomicUsize

Tasks queued and not yet started.

§max_queue_depth: AtomicUsize

High-water mark of the pending queue.

§started_at: Instant

Executor construction instant; the metrics epoch.

§last_updated_after_ns: AtomicU64

Nanoseconds after started_at of the last metrics update.

Implementations§

Source§

impl ExecutorMetrics

Source

pub fn new() -> Self

Create new metrics tracker

Source

pub fn record_task_spawned(&self)

Record a new task being spawned

Source

pub fn record_task_completed(&self, execution_time: Duration)

Record a task completion with execution time

Source

pub fn record_task_failed(&self)

Record a task failure

Source

pub fn record_task_cancelled(&self)

Record a task whose cancel request was honored before its body ran.

Source

pub fn update_worker_counts(&self, active: usize, idle: usize, total: usize)

Update worker count metrics

Source

pub fn update_queue_metrics(&self, pending: usize)

Update queue metrics

Source

pub fn throughput(&self) -> f64

Get current throughput (tasks per second)

Source

pub fn success_rate(&self) -> f64

Get success rate as percentage

Source

pub fn average_task_duration(&self) -> Duration

Get average task duration

Source

pub fn worker_utilization(&self) -> f64

Get worker utilization percentage

Source

pub fn uptime(&self) -> Duration

Get uptime

Source

pub fn last_updated(&self) -> Instant

Get the last metrics update timestamp.

Source

pub fn reset(&self)

Reset all metrics (useful for testing)

Trait Implementations§

Source§

impl Debug for ExecutorMetrics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExecutorMetrics

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.