pub struct Sensor { /* private fields */ }Expand description
A lock-free exponential moving average (EMA) gauge.
Useful for tracking smoothed rates or throughput where you want to dampen
spikes. The smoothing factor alpha controls responsiveness:
alphaclose to 1.0 → responds quickly to new values (noisy)alphaclose to 0.0 → responds slowly (smooth)
A typical value for per-second throughput is 0.05.
§Example
use prometheus_extensions::Sensor;
let sensor = Sensor::new(0.05);
for _ in 0..100 {
sensor.measure(1000.0);
}
// After many identical measurements, EMA converges to the input value.
assert!((sensor.get() - 1000.0).abs() < 10.0);Implementations§
Auto Trait Implementations§
impl !Freeze for Sensor
impl RefUnwindSafe for Sensor
impl Send for Sensor
impl Sync for Sensor
impl Unpin for Sensor
impl UnsafeUnpin for Sensor
impl UnwindSafe for Sensor
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
Mutably borrows from an owned value. Read more