[−][src]Struct metrix::instruments::Gauge
Simply returns the value that has been observed last.
Reacts Observation::Observation::ObservedOneValue
with the following values:
ObservedValue::ChangedBy
whoich increments or decrements the value- All
ObservedValue
s tha can be converted to ani64
which directly set the value
Examples
let mut gauge = Gauge::new_with_defaults("example"); assert_eq!(None, gauge.get()); let update = Update::ObservationWithValue(12.into(), Instant::now()); gauge.update(&update); assert_eq!(Some(12), gauge.get());
use metrix::{ChangeBy, Increment, Decrement}; let mut gauge = Gauge::new_with_defaults("example"); gauge.set(12.into()); assert_eq!(Some(12), gauge.get()); let update = Update::ObservationWithValue(Increment.into(), Instant::now()); gauge.update(&update); assert_eq!(Some(13), gauge.get()); let update = Update::ObservationWithValue(Decrement.into(), Instant::now()); gauge.update(&update); assert_eq!(Some(12), gauge.get()); let update = Update::ObservationWithValue(ChangeBy(-12).into(), Instant::now()); gauge.update(&update); assert_eq!(Some(0), gauge.get());
Methods
impl Gauge
[src]
pub fn new<T: Into<String>>(name: T) -> Gauge
[src]
pub fn new_with_defaults<T: Into<String>>(name: T) -> Gauge
[src]
pub fn get_name(&self) -> &str
[src]
pub fn set_name<T: Into<String>>(&mut self, name: T)
[src]
pub fn name<T: Into<String>>(self, name: T) -> Self
[src]
pub fn set_title<T: Into<String>>(&mut self, title: T)
[src]
pub fn title<T: Into<String>>(self, title: T) -> Self
[src]
pub fn set_description<T: Into<String>>(&mut self, description: T)
[src]
pub fn description<T: Into<String>>(self, description: T) -> Self
[src]
pub fn set_memorize_extrema(&mut self, d: Duration)
[src]
use method set_tracking
pub fn memorize_extrema(self, d: Duration) -> Self
[src]
use method tracking
pub fn tracking(self, for_seconds: usize) -> Self
[src]
Enables tracking of value for the last for_seconds
seconds.
For each interval of a second there will be a record that tracks
the minimum and maximum values of the gauge within an interval.
Also a sum and a counter to calculate averages will be recorded.
If tracking is enabled, the following fields will be added:
[gauge_name]_peak
: The peak value of all records[gauge_name]_peak_min
: The smallest of the peak values of all records[gauge_name]_peak_avg
: The average of the peak values for all records[gauge_name]_bottom
: The bottom value of all records[gauge_name]_bottom_max
: The biggest bottom value of all records[gauge_name]_bottom_avg
: The average of all bottom values for all records[gauge_name]_avg
: The average of all values for all records
pub fn set_tracking(&mut self, for_seconds: usize)
[src]
Enables tracking of value for the last for_seconds
seconds.
For each interval of a second there will be a record that tracks
the minimum and maximum values of the gauge within an interval.
Also a sum and a counter to calculate averages will be recorded.
If tracking is enabled, the following fields will be added:
[gauge_name]_peak
: The peak value of all records[gauge_name]_peak_min
: The smallest of the peak values of all records[gauge_name]_peak_avg
: The average of the peak values for all records[gauge_name]_bottom
: The bottom value of all records[gauge_name]_bottom_max
: The biggest bottom value of all records[gauge_name]_bottom_avg
: The average of all bottom values for all records[gauge_name]_avg
: The average of all values for all records
pub fn set_display_time_unit(&mut self, display_time_unit: TimeUnit)
[src]
pub fn display_time_unit(self, display_time_unit: TimeUnit) -> Self
[src]
pub fn accept<L: Eq + Send + 'static, F: Into<LabelFilter<L>>>(
self,
accept: F
) -> GaugeAdapter<L>
[src]
self,
accept: F
) -> GaugeAdapter<L>
pub fn for_label<L: Eq + Send + 'static>(self, label: L) -> GaugeAdapter<L>
[src]
Creates an GaugeAdapter
that makes this instrument
react on observations on the given label.
pub fn for_labels<L: Eq + Send + 'static>(
self,
labels: Vec<L>
) -> GaugeAdapter<L>
[src]
self,
labels: Vec<L>
) -> GaugeAdapter<L>
Creates an GaugeAdapter
that makes this instrument
react on observations with the given labels.
If labels
is empty the instrument will not react to any observations
pub fn for_all_labels<L: Eq + Send + 'static>(self) -> GaugeAdapter<L>
[src]
Creates an GaugeAdapter
that makes this instrument react on
all observations.
pub fn for_labels_by_predicate<L, P>(
self,
label_predicate: P
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
P: Fn(&L) -> bool + Send + 'static,
[src]
self,
label_predicate: P
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
P: Fn(&L) -> bool + Send + 'static,
Creates a GaugeAdapter
that makes this instrument react on
observations with labels specified by the predicate.
pub fn adapter<L: Eq + Send + 'static>(self) -> GaugeAdapter<L>
[src]
Creates an GaugeAdapter
that makes this instrument to rect to no
observations.
pub fn deltas_only<L: Eq + Send + 'static, F: Into<LabelFilter<L>>>(
self,
accept: F
) -> GaugeAdapter<L>
[src]
self,
accept: F
) -> GaugeAdapter<L>
pub fn for_label_deltas_only<L: Eq + Send + 'static>(
self,
label: L
) -> GaugeAdapter<L>
[src]
self,
label: L
) -> GaugeAdapter<L>
Creates a new adapter which dispatches observations
with the given label to the Gauge
The Gauge will only be dispatched message that increment or decrement the value
pub fn for_labels_deltas_only<L: Eq + Send + 'static>(
self,
labels: Vec<L>
) -> GaugeAdapter<L>
[src]
self,
labels: Vec<L>
) -> GaugeAdapter<L>
Creates a new adapter which dispatches observations
with the given labels to the Gauge
If labels
is empty, no observations will be dispatched
The Gauge will only be dispatched message that increment or decrement the value
pub fn for_labels_deltas_only_by_predicate<L, P>(
self,
label_predicate: P
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
P: Fn(&L) -> bool + Send + 'static,
[src]
self,
label_predicate: P
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
P: Fn(&L) -> bool + Send + 'static,
pub fn inc_dec_on<L: Eq + Send + 'static, INCR: Into<LabelFilter<L>>, DECR: Into<LabelFilter<L>>>(
self,
accept_incr: INCR,
accept_decr: DECR
) -> GaugeAdapter<L>
[src]
self,
accept_incr: INCR,
accept_decr: DECR
) -> GaugeAdapter<L>
Creates a new adapter which dispatches observations
with the given labels to the Gauge
which only increment or
decrement the Gauge
The Gauge
will increment on any observation with label increment_on
and decrement for any observation with label decrement_on
.
increment_on
is evaluated first so
increment_on
and decrement_on
should not be the same label.
pub fn inc_dec_on_many<L: Eq + Send + 'static>(
self,
increment_on: Vec<L>,
decrement_on: Vec<L>
) -> GaugeAdapter<L>
[src]
self,
increment_on: Vec<L>,
decrement_on: Vec<L>
) -> GaugeAdapter<L>
Creates a new adapter which dispatches observations
with the given labels to the Gauge
which only increment or
decrement the Gauge
The Gauge
will increment on any observation with a label in increment_on
and decrement for any observation with a label in decrement_on
.
increment_on
is evaluated first so
increment_on
and decrement_on
should share labels.
pub fn inc_dec_by_predicates<L, PINC, PDEC>(
self,
predicate_incr: PINC,
predicate_decr: PDEC
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
PINC: Fn(&L) -> bool + Send + 'static,
PDEC: Fn(&L) -> bool + Send + 'static,
[src]
self,
predicate_incr: PINC,
predicate_decr: PDEC
) -> GaugeAdapter<L> where
L: Eq + Send + 'static,
PINC: Fn(&L) -> bool + Send + 'static,
PDEC: Fn(&L) -> bool + Send + 'static,
pub fn set(&mut self, observed: ObservedValue)
[src]
pub fn get(&self) -> Option<i64>
[src]
Trait Implementations
impl Descriptive for Gauge
[src]
impl<L> From<Gauge> for GaugeAdapter<L> where
L: Clone + Eq + Send + 'static,
[src]
L: Clone + Eq + Send + 'static,
fn from(gauge: Gauge) -> GaugeAdapter<L>
[src]
impl Instrument for Gauge
[src]
impl PutsSnapshot for Gauge
[src]
fn put_snapshot(&self, into: &mut Snapshot, descriptive: bool)
[src]
impl Updates for Gauge
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Gauge
impl Send for Gauge
impl !Sync for Gauge
impl Unpin for Gauge
impl UnwindSafe for Gauge
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,