Struct metrics_prometheus::storage::Immutable

source ·
pub struct Immutable { /* private fields */ }
Expand description

Snapshot of a mutable::Storage, that is not capable of registering metrics in a prometheus::Registry on the fly, but still allowing to change their help description on the fly, once they were registered in the mutable::Storage before snapshot.

In comparison with a metrics::Registry, this immutable Storage provides much less overhead of accessing an already registered metric (just a simple HashMap lookup), however, is not capable of registering new metrics on the fly.

Implementations§

source§

impl Storage

source

pub fn describe<M>(&self, name: &str, description: String)
where M: Bundled, <M as Bundled>::Bundle: Bundle, Self: Get<Collection<<M as Bundled>::Bundle>>,

Changes the help description of the prometheus Metric identified by its name. No-op if this immutable Storage doesn’t contain it.

Accepts only the following prometheus Metrics:

Intended to be used in metrics::Recorder::describe_counter(), metrics::Recorder::describe_gauge() and metrics::Recorder::describe_histogram() implementations.

source

pub fn get_metric<M>(&self, key: &Key) -> Option<Result<Metric<M>, Error>>
where M: Bundled, <M as Bundled>::Bundle: Bundle<Single = M>, Self: Get<Collection<<M as Bundled>::Bundle>>,

Returns a prometheus Metric stored in this immutable Storage and identified by the provided metrics::Key.

Accepts only the following prometheus metrics:

Intended to be used in metrics::Recorder::register_counter(), metrics::Recorder::register_gauge() and metrics::Recorder::register_histogram() implementations.

§Errors

If the identified prometheus Metric doesn’t comply with the labeling of the provided metrics::Key.

Trait Implementations§

source§

impl Debug for Storage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&Storage> for Storage

source§

fn from(mutable: &Storage) -> Self

Creates a new immutable Storage by draining the referred mutable::Storage and leaving it empty.

source§

impl Get<HashMap<String, Describable<Either<GenericCounter<AtomicU64>, MetricVec<CounterVecBuilder<AtomicU64>>>>>> for Storage

source§

fn collection(&self) -> &Collection<PrometheusIntCounter>

Returns a Collection of metric::Bundles stored in this storage.
source§

impl Get<HashMap<String, Describable<Either<GenericGauge<AtomicF64>, MetricVec<GaugeVecBuilder<AtomicF64>>>>>> for Storage

source§

fn collection(&self) -> &Collection<PrometheusGauge>

Returns a Collection of metric::Bundles stored in this storage.
source§

impl Get<HashMap<String, Describable<Either<Histogram, MetricVec<HistogramVecBuilder>>>>> for Storage

source§

fn collection(&self) -> &Collection<PrometheusHistogram>

Returns a Collection of metric::Bundles stored in this storage.

Auto Trait Implementations§

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.