pub struct RuntimeMetrics { /* private fields */ }
Expand description
Handle to the Runtime
’s metrics.
Unlike [tokio::runtime::RuntimeMetrics
] this handle returns the relative
increase in values since the last time the specific metric was queried.
This makes it possible to emit these metrics as counters more easily through statsd.
It also exposes some other runtime metrics which Tokio does not directly
expose through the [tokio::runtime::RuntimeMetrics
] handle.
Implementations§
source§impl RuntimeMetrics
impl RuntimeMetrics
sourcepub fn num_idle_threads(&self) -> usize
pub fn num_idle_threads(&self) -> usize
Returns the amount of current threads idle.
sourcepub fn num_alive_tasks(&self) -> usize
pub fn num_alive_tasks(&self) -> usize
Returns the amount of currently alive tasks in the runtime.
See also: [tokio::runtime::RuntimeMetrics::num_alive_tasks
].
sourcepub fn blocking_queue_depth(&self) -> usize
pub fn blocking_queue_depth(&self) -> usize
Returns the number of tasks currently scheduled in the blocking
thread pool, spawned using spawn_blocking
.
See also: [tokio::runtime::RuntimeMetrics::blocking_queue_depth
].
sourcepub fn budget_forced_yield_count(&self) -> u64
pub fn budget_forced_yield_count(&self) -> u64
Returns the number of times that tasks have been forced to yield back to the scheduler after exhausting their task budgets.
See also: [tokio::runtime::RuntimeMetrics::budget_forced_yield_count
]
Returns the difference since the function was last called.
sourcepub fn num_blocking_threads(&self) -> usize
pub fn num_blocking_threads(&self) -> usize
Returns the number of additional threads spawned by the runtime.
See also: [tokio::runtime::RuntimeMetrics::num_blocking_threads
].
sourcepub fn num_idle_blocking_threads(&self) -> usize
pub fn num_idle_blocking_threads(&self) -> usize
Returns the number of idle threads, which have spawned by the runtime
for spawn_blocking
calls.
See also: [tokio::runtime::RuntimeMetrics::num_idle_blocking_threads
].
sourcepub fn num_workers(&self) -> usize
pub fn num_workers(&self) -> usize
Returns the number of worker threads used by the runtime.
See also: [tokio::runtime::RuntimeMetrics::num_workers
].
sourcepub fn worker_local_queue_depth(&self, worker: usize) -> usize
pub fn worker_local_queue_depth(&self, worker: usize) -> usize
Returns the number of tasks currently scheduled in the given worker’s local queue.
See also: [tokio::runtime::RuntimeMetrics::worker_local_queue_depth
].
sourcepub fn worker_mean_poll_time(&self, worker: usize) -> Duration
pub fn worker_mean_poll_time(&self, worker: usize) -> Duration
Returns the mean duration of task polls, in nanoseconds.
See also: [tokio::runtime::RuntimeMetrics::worker_mean_poll_time
].
sourcepub fn worker_local_schedule_count(&self, worker: usize) -> u64
pub fn worker_local_schedule_count(&self, worker: usize) -> u64
Returns the number of tasks scheduled from within the runtime on the given worker’s local queue.
See also: [tokio::runtime::RuntimeMetrics::worker_local_schedule_count
]
Returns the difference since the function was last called.
sourcepub fn worker_noop_count(&self, worker: usize) -> u64
pub fn worker_noop_count(&self, worker: usize) -> u64
Returns the number of times the given worker thread unparked but performed no work before parking again.
See also: [tokio::runtime::RuntimeMetrics::worker_noop_count
]
Returns the difference since the function was last called.
sourcepub fn worker_overflow_count(&self, worker: usize) -> u64
pub fn worker_overflow_count(&self, worker: usize) -> u64
Returns the number of times the given worker thread saturated its local queue.
See also: [tokio::runtime::RuntimeMetrics::worker_overflow_count
]
Returns the difference since the function was last called.
sourcepub fn worker_park_count(&self, worker: usize) -> u64
pub fn worker_park_count(&self, worker: usize) -> u64
Returns the total number of times the given worker thread has parked.
See also: [tokio::runtime::RuntimeMetrics::worker_park_count
]
Returns the difference since the function was last called.
sourcepub fn worker_poll_count(&self, worker: usize) -> u64
pub fn worker_poll_count(&self, worker: usize) -> u64
Returns the number of tasks the given worker thread has polled.
See also: [tokio::runtime::RuntimeMetrics::worker_poll_count
]
Returns the difference since the function was last called.
sourcepub fn worker_steal_count(&self, worker: usize) -> u64
pub fn worker_steal_count(&self, worker: usize) -> u64
Returns the number of tasks the given worker thread stole from another worker thread.
See also: [tokio::runtime::RuntimeMetrics::worker_steal_count
]
Returns the difference since the function was last called.
sourcepub fn worker_steal_operations(&self, worker: usize) -> u64
pub fn worker_steal_operations(&self, worker: usize) -> u64
Returns the number of times the given worker thread stole tasks from another worker thread.
See also: [tokio::runtime::RuntimeMetrics::worker_steal_operations
]
Returns the difference since the function was last called.
sourcepub fn worker_total_busy_duration(&self, worker: usize) -> Duration
pub fn worker_total_busy_duration(&self, worker: usize) -> Duration
Returns the amount of time the given worker thread has been busy, in seconds.
See also: [tokio::runtime::RuntimeMetrics::worker_total_busy_duration
].
Returns the difference since the function was last called.