pub struct MetricsRegistry { /* private fields */ }Expand description
Thread-safe registry for creating and updating metrics.
All operations are guarded by an internal Mutex, making the registry safe
to share across threads via Arc<MetricsRegistry>.
Implementations§
Source§impl MetricsRegistry
impl MetricsRegistry
Create a registry wrapped in an Arc for sharing.
Sourcepub fn counter(&self, name: &str, labels: HashMap<String, String>) -> i64
pub fn counter(&self, name: &str, labels: HashMap<String, String>) -> i64
Increment a counter by delta (default 1).
Sourcepub fn counter_by(
&self,
name: &str,
labels: HashMap<String, String>,
delta: i64,
) -> i64
pub fn counter_by( &self, name: &str, labels: HashMap<String, String>, delta: i64, ) -> i64
Increment a counter by a specific amount.
Sourcepub fn gauge(&self, name: &str, labels: HashMap<String, String>, value: f64)
pub fn gauge(&self, name: &str, labels: HashMap<String, String>, value: f64)
Set a gauge to value.
Sourcepub fn gauge_add(&self, name: &str, labels: HashMap<String, String>, delta: f64)
pub fn gauge_add(&self, name: &str, labels: HashMap<String, String>, delta: f64)
Add delta to a gauge.
Sourcepub fn histogram_observe(
&self,
name: &str,
labels: HashMap<String, String>,
value: f64,
)
pub fn histogram_observe( &self, name: &str, labels: HashMap<String, String>, value: f64, )
Record a histogram observation.
Sourcepub fn set_default_buckets(&self, boundaries: Vec<f64>)
pub fn set_default_buckets(&self, boundaries: Vec<f64>)
Override the default bucket boundaries for future histogram metrics.
Sourcepub fn get_counter(&self, name: &str, labels: &HashMap<String, String>) -> i64
pub fn get_counter(&self, name: &str, labels: &HashMap<String, String>) -> i64
Get the current counter value (returns 0 if not found).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for MetricsRegistry
impl RefUnwindSafe for MetricsRegistry
impl Send for MetricsRegistry
impl Sync for MetricsRegistry
impl Unpin for MetricsRegistry
impl UnsafeUnpin for MetricsRegistry
impl UnwindSafe for MetricsRegistry
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.