[][src]Struct prometheus_exporter_base::PrometheusCounter

pub struct PrometheusCounter<'a> {
    pub counter_name: &'a str,
    pub counter_type: &'a str,
    pub counter_help: &'a str,
}

Fields

counter_name: &'a strcounter_type: &'a strcounter_help: &'a str

Methods

impl<'a> PrometheusCounter<'a>[src]

pub fn new(
    counter_name: &'a str,
    counter_type: &'a str,
    counter_help: &'a str
) -> PrometheusCounter<'a>
[src]

pub fn render_header(&self) -> String[src]

pub fn render_counter<N>(
    &self,
    attributes: Option<&[(&'a str, &'a str)]>,
    value: N
) -> String where
    N: Display
[src]

Returns the valid Prometheus string, given the optional attributes and the value. The counter name is in &self.

Arguments

  • attributes - A slice of pairs indicating Attribute-Value. It is optional.
  • value - A Display-able value that will be appended as counter value.

Example

 use prometheus_exporter_base::PrometheusCounter;
 let pc = PrometheusCounter::new("folder_size", "counter", "Size of the folder");
 let mut s = pc.render_header();
 let mut attributes = Vec::new();
 attributes.push(("folder", "/var/log/"));
 s.push_str(&pc.render_counter(Some(&attributes), 1024));
 attributes[0].1 = "/tmp";
 s.push_str(&pc.render_counter(Some(&attributes), 5_000_000));

Auto Trait Implementations

impl<'a> Send for PrometheusCounter<'a>

impl<'a> Sync for PrometheusCounter<'a>

Blanket Implementations

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

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

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.

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

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

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

impl<T> Erased for T