Struct metriken::MetricBuilder
source · pub struct MetricBuilder { /* private fields */ }
Expand description
Builder for creating a dynamic metric.
This can be used to directly create a DynBoxedMetric
or you can convert
this builder into a MetricEntry
for more advanced use cases.
Implementations§
source§impl MetricBuilder
impl MetricBuilder
sourcepub fn new(name: impl Into<Cow<'static, str>>) -> MetricBuilder
pub fn new(name: impl Into<Cow<'static, str>>) -> MetricBuilder
Create a new builder, starting with the metric name.
sourcepub fn description(self, desc: impl Into<Cow<'static, str>>) -> MetricBuilder
pub fn description(self, desc: impl Into<Cow<'static, str>>) -> MetricBuilder
Add a description of this metric.
sourcepub fn metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> MetricBuilder
pub fn metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> MetricBuilder
Add a new key-value metadata entry.
pub fn formatter( self, formatter: fn(_: &MetricEntry, _: Format) -> String, ) -> MetricBuilder
sourcepub fn into_entry(self) -> MetricEntry
pub fn into_entry(self) -> MetricEntry
Convert this builder directly into a MetricEntry
.
sourcepub fn build<T>(self, metric: T) -> DynBoxedMetric<T>where
T: Metric,
pub fn build<T>(self, metric: T) -> DynBoxedMetric<T>where
T: Metric,
Build a DynBoxedMetric
for use with this builder.
Auto Trait Implementations§
impl Freeze for MetricBuilder
impl RefUnwindSafe for MetricBuilder
impl Send for MetricBuilder
impl Sync for MetricBuilder
impl Unpin for MetricBuilder
impl UnwindSafe for MetricBuilder
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