pub struct SystemCpuTracker { /* private fields */ }Expand description
Aggregate machine CPU utilization from cumulative CPU-time totals (§8.3).
The percentage is busy_delta / (busy_delta + idle_delta). That divisor is
CPU time rather than wall time, which makes the result self-normalizing: it
is already a share of all logical CPUs, so it lands in 0..=100 without
ever being told the CPU count, and a sample interval that drifts from 1 s to
4 s cannot distort it.
The reading Instant is retained even though the percentage does not use
it, so that a keyed set of per-core trackers can prune cores that stopped
reporting after a CPU hotplug event.
Implementations§
Source§impl SystemCpuTracker
impl SystemCpuTracker
Sourcepub const fn is_warming_up(&self) -> bool
pub const fn is_warming_up(&self) -> bool
Whether the next reading will be the first, and so warming up (§8.2).
Sourcepub const fn last_observed_at(&self) -> Option<Instant>
pub const fn last_observed_at(&self) -> Option<Instant>
When the last reading was accepted, or None while warming up.
Sourcepub fn forget_baseline(&mut self)
pub fn forget_baseline(&mut self)
Drops the baseline so the next reading warms up again.
Sourcepub fn observe(
&mut self,
totals: CpuTimeTotals,
at: Instant,
) -> MetricState<Percent>
pub fn observe( &mut self, totals: CpuTimeTotals, at: Instant, ) -> MetricState<Percent>
Folds one cumulative CPU-time reading in and publishes machine usage.
Trait Implementations§
Source§impl Clone for SystemCpuTracker
impl Clone for SystemCpuTracker
Source§fn clone(&self) -> SystemCpuTracker
fn clone(&self) -> SystemCpuTracker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SystemCpuTracker
Source§impl Debug for SystemCpuTracker
impl Debug for SystemCpuTracker
Source§impl Default for SystemCpuTracker
impl Default for SystemCpuTracker
Source§fn default() -> SystemCpuTracker
fn default() -> SystemCpuTracker
Source§impl DeltaTracker for SystemCpuTracker
impl DeltaTracker for SystemCpuTracker
Source§type Reading = CpuTimeTotals
type Reading = CpuTimeTotals
Source§fn with_config(_config: Self::Config) -> Self
fn with_config(_config: Self::Config) -> Self
Source§fn observe_reading(
&mut self,
reading: Self::Reading,
at: Instant,
) -> MetricState<Self::Value>
fn observe_reading( &mut self, reading: Self::Reading, at: Instant, ) -> MetricState<Self::Value>
at.Source§fn last_observed_at(&self) -> Option<Instant>
fn last_observed_at(&self) -> Option<Instant>
None while warming up.