pub enum ScaleLadder {
Ns,
Us,
Bytes,
Ticks,
Unitless,
None,
}Expand description
Closed enumeration of auto-scale ladders driving format dispatch.
Picks the unit family up the type system rather than a free-form
&'static str tag. Each AggRule variant maps to exactly one
ladder via AggRule::ladder; each super::DerivedMetricDef entry
carries a ladder via super::DerivedMetricDef::ladder; the cgroup-
level render path passes a ladder directly. A registry typo or
drift between accessor newtype and ladder choice fails to compile
at the registry edit site rather than silently routing through
an “unknown unit” pass-through arm at render time.
The six ladder variants and their step-up rules:
Ns: ns → µs (×1e3) → ms (×1e6) → s (×1e9). Decimal prefixes — SI time, not binary. Used forAggRule::SumNs(cumulative ns counters),AggRule::MaxPeak(lifetime ns high-water marks),AggRule::MaxGaugeNs(instantaneous ns gauges), and the"ns"derived-metric ladder.Us: µs → ms (×1e3) → s (×1e6). Decimal SI prefixes. The cgroupcpu_usage_usecandthrottled_usecfields are reported by the kernel in microseconds; this ladder scales them up the same way theNsladder scales nanoseconds.Bytes: B → KiB → MiB → GiB → TiB. IEC binary prefixes (×1024) for byte counts. Used forAggRule::SumBytes,AggRule::MaxPeakBytes, and any byte-typed derived metric.Ticks: ticks → Kticks (×1e3) → Mticks (×1e6). Decimal prefixes for clock-tick counts (utime_clock_ticks,stime_clock_ticks); the unit itself is opaque (the kernel’sUSER_HZrate is host-dependent), so an SI prefix is the most we can promise.Unitless: “” → K → M → G. Decimal prefixes for non-dimensional counters (wakeups, migrations, csw, syscall counts). Used forAggRule::SumCountandAggRule::MaxGaugeCount.None: no ladder — values render as the bare integer with no unit suffix and no scaling. Used forAggRule::Mode/AggRule::ModeChar/AggRule::ModeBool(categorical strings),AggRule::RangeI32/AggRule::RangeU32(bounded ordinals), andAggRule::Affinity(cpuset summaries) — theAggregatedstd::fmt::Displayimpl handles render for these directly.
The threshold for stepping up is |value| >= next_scale.
Sign is preserved through scaling (negative deltas pass
through). Zero stays at base unit.
Variants§
Implementations§
Source§impl ScaleLadder
impl ScaleLadder
Sourcepub fn base_unit(&self) -> &'static str
pub fn base_unit(&self) -> &'static str
Base unit string for this ladder — what auto_scale
returns for a value at the bottom of the ladder. Used by
the format helpers to detect whether a value stepped up
(auto_scale(v).1 != ladder.base_unit() ⇒ stepped up,
render with the scaled unit; equal ⇒ no step-up, render
the bare integer with the base unit suffix).
Trait Implementations§
Source§impl Clone for ScaleLadder
impl Clone for ScaleLadder
Source§fn clone(&self) -> ScaleLadder
fn clone(&self) -> ScaleLadder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScaleLadder
impl Debug for ScaleLadder
Source§impl Hash for ScaleLadder
impl Hash for ScaleLadder
Source§impl PartialEq for ScaleLadder
impl PartialEq for ScaleLadder
impl Copy for ScaleLadder
impl Eq for ScaleLadder
impl StructuralPartialEq for ScaleLadder
Auto Trait Implementations§
impl Freeze for ScaleLadder
impl RefUnwindSafe for ScaleLadder
impl Send for ScaleLadder
impl Sync for ScaleLadder
impl Unpin for ScaleLadder
impl UnwindSafe for ScaleLadder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more