pub struct Counter(/* private fields */);
Expand description
A counter. Can be incremented or added to.
In case of overflow the counter will wrap around. However, internally it uses an unsigned 64-bit integer so for most use cases this should be unlikely.
§Example
#[metric(name = "my.custom.metric")]
static MY_COUNTER: Counter = Counter::new();
fn a_method() {
MY_COUNTER.increment();
// ...
}
Implementations§
Trait Implementations§
Source§impl Metric for Counter
impl Metric for Counter
Source§fn as_any(&self) -> Option<&dyn Any>
fn as_any(&self) -> Option<&dyn Any>
Get the current metric as an
Any
instance. This is meant to allow
custom processing for known metric types.Source§fn value(&self) -> Option<Value<'_>>
fn value(&self) -> Option<Value<'_>>
Get the value of the current metric, should it be enabled. Read more
Source§fn is_enabled(&self) -> bool
fn is_enabled(&self) -> bool
Indicate whether this metric has been set up. Read more
Auto Trait Implementations§
impl !Freeze for Counter
impl RefUnwindSafe for Counter
impl Send for Counter
impl Sync for Counter
impl Unpin for Counter
impl UnwindSafe for Counter
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