pub trait SampledStatKind: Send + Sync {
// Required methods
fn update(
&self,
sample: &mut Sample,
config: &MetricConfig,
value: f64,
time_ms: i64,
);
fn combine(
&self,
samples: &[Sample],
config: &MetricConfig,
now: i64,
) -> f64;
// Provided methods
fn is_windowed_count(&self) -> bool { ... }
fn is_windowed_sum(&self) -> bool { ... }
}Expand description
The per-subclass behaviour of a SampledStat.
Java’s SampledStat is abstract with update/combine provided by each
subclass and an initialValue passed to the constructor. We model those
abstract methods as this trait object held by the concrete SampledStat
struct, plus the initial_value stored on the struct. newSample is NOT
virtual in Java, so it stays on SampledStat itself.
Required Methods§
Provided Methods§
Sourcefn is_windowed_count(&self) -> bool
fn is_windowed_count(&self) -> bool
Whether this is a WindowedCount (counts invocations rather than summing
values). Used by crate::common::metrics::stats::Meter to decide
whether the total records 1.0, mirroring Java’s
rate.stat instanceof WindowedCount check. Defaults to false; only
WindowedCount overrides it.
Sourcefn is_windowed_sum(&self) -> bool
fn is_windowed_sum(&self) -> bool
Whether this is a WindowedSum (or a subclass of it). Meter only
supports a WindowedSum/WindowedCount rate stat, mirroring Java’s
instanceof WindowedSum guard. Defaults to false.