[][src]Struct metrix::instruments::Gauge

pub struct Gauge { /* fields omitted */ }

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 ObservedValues tha can be converted to an i64 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]

Deprecated since 0.10.5:

use method set_tracking

pub fn memorize_extrema(self, d: Duration) -> Self[src]

Deprecated since 0.10.5:

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]

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]

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]

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]

pub fn for_label_deltas_only<L: Eq + Send + 'static>(
    self,
    label: L
) -> GaugeAdapter<L>
[src]

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]

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]

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]

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]

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]

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]

impl Instrument for Gauge[src]

impl PutsSnapshot for Gauge[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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,