#[non_exhaustive]pub enum Aggregated {
Sum(u64),
Max(u64),
OrdinalRange {
min: i64,
max: i64,
},
Mode {
tallies: BTreeMap<String, usize>,
total: usize,
},
Affinity(AffinitySummary),
Absent,
}Expand description
Aggregated metric value for a single super::ThreadGroup.
Carries both a numeric projection (used for delta math and
sort order) and a display form. Not every rule produces a
numeric — the categorical rules
(super::AggRule::Mode / super::AggRule::ModeChar /
super::AggRule::ModeBool) aggregate to a string, which has no
scalar — so the numeric is optional and rows without one
fall to the bottom of the default sort.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Sum(u64)
Group-wide sum produced by the
super::AggRule::SumCount / super::AggRule::SumNs /
super::AggRule::SumTicks / super::AggRule::SumBytes rules. The
dispatch unwraps the typed newtype’s inner u64 after
the crate::metric_types::Summable::sum_across
reduction; storage stays u64 to preserve full precision
across the entire schedstats / byte / tick range with
no lossy cast at aggregation time. The render-time
auto-scale ladder is derived from the typed accessor
newtype via super::AggRule::ladder — there is no
separate unit tag on the metric def.
Max(u64)
Group-wide maximum produced by the
super::AggRule::MaxPeak / super::AggRule::MaxGaugeNs /
super::AggRule::MaxGaugeCount rules. Distinct variant from
Sum so a downstream consumer that wants to surface
“the worst single thread” rather than “the
summed-across-threads value” can match without name-
matching against the metric registry. Storage is u64 to
preserve full ns precision across the entire schedstats
range (no as f64 lossy cast at aggregation time).
OrdinalRange
Group-wide [min, max] interval produced by the
super::AggRule::RangeI32 / super::AggRule::RangeU32 rules.
Both bounds widen to i64 at the dispatch boundary
(i64::from(OrdinalI32.0) / i64::from(OrdinalU32.0))
— OrdinalI32 carries a signed kernel-side range
(nice includes negative values) and OrdinalU32 fits
into i64 losslessly, so a single signed scalar
represents both ordinal widths without losing the sign
from OrdinalI32 or wrapping the magnitude from
OrdinalU32. Delta math takes the midpoint
((min + max) / 2) so a one-sided shift surfaces in
the rendered delta column.
Mode
Categorical aggregate carrying per-value counts across
the bucket. tallies maps each observed value to its
occurrence count; total is the bucket size (count of
every contributor, including any empty-string fallbacks).
The mode (most-frequent value) is derived on demand via
Aggregated::mode_value / Aggregated::mode_count
so cross-bucket merges (N:1 fudge) compose correctly:
unioning two buckets’ tallies gives the true cross-bucket
frequency for each value, not just the per-bucket
max-count. Empty buckets surface as tallies: empty, total: bucket_size; the renderer handles the empty case
by emitting ~ in place of the mode value.
Affinity(AffinitySummary)
Absent
The metric’s capture-gated family was NOT measured for any thread in the
group — the taskstats genetlink query failed for every thread (the
query-level ThreadState::taskstats_measured flag is false: CONFIG_TASKSTATS
off / no CAP_NET_ADMIN / query raced exit), or — for the jemalloc byte
counters — no thread’s per-thread probe READ succeeded (non-jemalloc
process, probe could not attach, or the read failed) — distinct from a
measured zero. (A sub-family disabled while the query still succeeds — e.g.
CONFIG_TASK_XACCT off, or the kernel.task_delayacct sysctl off, with the
other family on — now IS Absent: the measured predicate ANDs the per-thread
query-Ok with the per-sub-family active flag baked from host probes. See the
taskstats_measured field doc.) Produced by super::aggregate’s
caller when the family has a
measured predicate, the bucket is non-empty, and no contributing thread
captured it. numeric() returns None, so a derived metric consuming it
(e.g. total_offcpu_delay_ns, live_heap_estimate) short-circuits to
absent rather than computing from a sentinel 0, and the renderer prints
“-” rather than “0”. A MEASURED zero stays Sum(0) and renders “0”.
Implementations§
Source§impl Aggregated
impl Aggregated
Sourcepub fn numeric(&self) -> Option<f64>
pub fn numeric(&self) -> Option<f64>
Scalar projection for delta math. None when the rule
produces no meaningful scalar (categorical mode, affinity
with heterogeneous cpusets).
Sourcepub fn mode_single(
value: impl Into<String>,
count: usize,
total: usize,
) -> Aggregated
pub fn mode_single( value: impl Into<String>, count: usize, total: usize, ) -> Aggregated
Construct an Aggregated::Mode from a single
(value, count, total) triple, common in test fixtures
and the single-bucket aggregate path. Equivalent to
inserting (value, count) into a fresh tally map.
count == 0 produces an empty tally (the empty-bucket
shape), preserving the historical contract that an
empty Mode renders as ~ while still carrying a
well-defined total for the rendered “(count/total)”
suffix.
Sourcepub fn mode_value(&self) -> &str
pub fn mode_value(&self) -> &str
The most-frequent value tracked by an Aggregated::Mode,
or the empty string when the tallies map is empty (an
empty bucket whose total may still be non-zero, e.g.
when every contributor produced no categorical sample).
Ties on count are broken by lexicographic order on the
VALUE — the lex-smallest key wins. Deterministic across
runs and matches the historical Mode contract under the
old value, count shape.
Sourcepub fn mode_count(&self) -> usize
pub fn mode_count(&self) -> usize
The frequency count of the mode value. Zero when the
tallies map is empty (no contributor produced a
categorical sample). Same tie-break as
Self::mode_value.
Trait Implementations§
Source§impl Clone for Aggregated
impl Clone for Aggregated
Source§fn clone(&self) -> Aggregated
fn clone(&self) -> Aggregated
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Aggregated
impl Debug for Aggregated
Auto Trait Implementations§
impl Freeze for Aggregated
impl RefUnwindSafe for Aggregated
impl Send for Aggregated
impl Sync for Aggregated
impl Unpin for Aggregated
impl UnwindSafe for Aggregated
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<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