pub struct DynPinnedMetric<M>
where M: Metric,
{ /* private fields */ }
Expand description

A dynamic metric that stores the metric inline.

This is a dynamic metric that relies on pinning guarantees to ensure that the stored metric can be safely accessed from other threads looking through the global dynamic metrics registry. As it requires pinning, it is somewhat unweildy to use. Most use cases can probably use DynBoxedMetric instead.

To use this, first create the DynPinnedMetric and then, once it is pinned, call register any number of times with all of the names the metric should be registered under. When the DynPinnedMetric instance is dropped it will unregister all the metric entries added via register.

§Example

let my_dyn_metric = pin!(DynPinnedMetric::new(Counter::new()));
my_dyn_metric.as_ref().register(MetricBuilder::new("a.dynamic.counter").into_entry());

Implementations§

source§

impl<M> DynPinnedMetric<M>
where M: Metric,

source

pub fn new(metric: M) -> DynPinnedMetric<M>

Create a new DynPinnedMetric with the provided internal metric.

This does not register the metric. To do that call register.

source

pub fn register(self: Pin<&DynPinnedMetric<M>>, entry: MetricEntry)

Register this metric in the global list of dynamic metrics with name.

Calling this multiple times will result in the same metric being registered multiple times under potentially different names.

Trait Implementations§

source§

impl<M> Deref for DynPinnedMetric<M>
where M: Metric,

§

type Target = M

The resulting type after dereferencing.
source§

fn deref(&self) -> &<DynPinnedMetric<M> as Deref>::Target

Dereferences the value.
source§

impl<M> Drop for DynPinnedMetric<M>
where M: Metric,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<M> Freeze for DynPinnedMetric<M>
where M: Freeze,

§

impl<M> RefUnwindSafe for DynPinnedMetric<M>
where M: RefUnwindSafe,

§

impl<M> Send for DynPinnedMetric<M>

§

impl<M> Sync for DynPinnedMetric<M>

§

impl<M> !Unpin for DynPinnedMetric<M>

§

impl<M> UnwindSafe for DynPinnedMetric<M>
where M: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.