Struct prometrics::metrics::Counter
[−]
[src]
pub struct Counter(_);
Counter
is a cumulative metric that represents a single numerical value that only ever goes up.
Cloned counters share the same value.
Examples
use prometrics::metrics::CounterBuilder; let mut counter = CounterBuilder::new("foo_total").namespace("example").finish().unwrap(); assert_eq!(counter.metric_name().to_string(), "example_foo_total"); assert_eq!(counter.value(), 0.0); counter.increment(); assert_eq!(counter.value(), 1.0);
Methods
impl Counter
[src]
pub fn new(name: &str) -> Result<Self>
[src]
Makes a new Counter
instance.
Note that it is recommended to create this via CounterBuilder
.
pub fn metric_name(&self) -> &MetricName
[src]
Returns the name of this counter.
pub fn help(&self) -> Option<&str>
[src]
Returns the help of this counter.
pub fn labels(&self) -> &Labels
[src]
Returns the labels of this counter.
pub fn labels_mut(&mut self) -> LabelsMut
[src]
Returns the mutable labels of this counter.
pub fn timestamp(&self) -> &Timestamp
[src]
Returns the timestamp of this counter.
pub fn timestamp_mut(&mut self) -> TimestampMut
[src]
Returns the mutable timestamp of this counter.
pub fn value(&self) -> f64
[src]
Returns the value of this counter.
pub fn increment(&self)
[src]
Increments this counter.
pub fn add(&self, count: f64) -> Result<()>
[src]
Adds count
to this counter.
pub fn add_u64(&self, count: u64)
[src]
Adds count
to this counter.
pub fn time<F, T>(&self, f: F) -> T where
F: FnOnce() -> T,
[src]
F: FnOnce() -> T,
Measures the exeuction time of f
and adds its duration to the counter in seconds.
pub fn collector(&self) -> CounterCollector
[src]
Returns a collector for this counter.
Trait Implementations
impl From<Counter> for Metric
[src]
impl Debug for Counter
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for Counter
[src]
fn clone(&self) -> Counter
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more