Struct prometheus::Registry[][src]

pub struct Registry { /* fields omitted */ }

A struct for registering Prometheus collectors, collecting their metrics, and gathering them into MetricFamilies for exposition.

Implementations

impl Registry[src]

pub fn new() -> Registry[src]

new creates a Registry.

pub fn new_custom(
    prefix: Option<String>,
    labels: Option<HashMap<String, String>>
) -> Result<Registry>
[src]

Create a new registry, with optional custom prefix and labels.

pub fn register(&self, c: Box<dyn Collector>) -> Result<()>[src]

register registers a new Collector to be included in metrics collection. It returns an error if the descriptors provided by the Collector are invalid or if they — in combination with descriptors of already registered Collectors — do not fulfill the consistency and uniqueness criteria described in the documentation of Desc.

If the provided Collector is equal to a Collector already registered (which includes the case of re-registering the same Collector), the AlreadyReg error returns.

pub fn unregister(&self, c: Box<dyn Collector>) -> Result<()>[src]

unregister unregisters the Collector that equals the Collector passed in as an argument. (Two Collectors are considered equal if their Describe method yields the same set of descriptors.) The function returns error when the Collector is not registered.

pub fn gather(&self) -> Vec<MetricFamily>[src]

gather calls the Collect method of the registered Collectors and then gathers the collected metrics into a lexicographically sorted slice of MetricFamily protobufs.

Trait Implementations

impl Clone for Registry[src]

impl Debug for Registry[src]

impl Default for Registry[src]

Auto Trait Implementations

impl !RefUnwindSafe for Registry

impl Send for Registry

impl Sync for Registry

impl Unpin for Registry

impl !UnwindSafe for Registry

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.