PrometheusInstance

Struct PrometheusInstance 

Source
pub struct PrometheusInstance<'a, N, ValueSet>
where N: Num + Display + Debug,
{ /* private fields */ }

Implementations§

Source§

impl<'a, N> PrometheusInstance<'a, N, MissingValue>
where N: Num + Display + Debug,

Source

pub fn new() -> Self

Source§

impl<'a, N, ValueSet> PrometheusInstance<'a, N, ValueSet>
where N: Num + Display + Debug,

Source

pub fn with_label<L, V>(self, l: L, v: V) -> Self
where L: Into<&'a str>, V: Into<&'a str>,

Source

pub fn with_timestamp(self, timestamp: u128) -> Self

Adds the optional timestamp to the instance.

Example:

use prometheus_exporter_base::prelude::*;

PrometheusInstance::new()
    .with_timestamp(123)
    .with_value(123);
Source

pub fn with_current_timestamp(self) -> Result<Self, SystemTimeError>

Adds the current timestamp to the instance. The timestamp is calculated as milliseconds from the current UNIX_EPOCH as per specification. Example:

use prometheus_exporter_base::prelude::*;

PrometheusInstance::new()
    .with_current_timestamp()
    .expect("failed to get the UNIX epoch")
    .with_value(123);
Source

pub fn with_value(self, value: N) -> PrometheusInstance<'a, N, Yes>

Adds the current value to the instance. The value will be formatted as float as per specification.

Example:

use prometheus_exporter_base::prelude::*;

PrometheusInstance::new()
    .with_value(123);

Trait Implementations§

Source§

impl<'a, N, ValueSet: Clone> Clone for PrometheusInstance<'a, N, ValueSet>
where N: Num + Display + Debug + Clone,

Source§

fn clone(&self) -> PrometheusInstance<'a, N, ValueSet>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, N, ValueSet: Debug> Debug for PrometheusInstance<'a, N, ValueSet>
where N: Num + Display + Debug + Debug,

Source§

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

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

impl<'a, N> Default for PrometheusInstance<'a, N, MissingValue>
where N: Num + Display + Debug,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, N> RenderToPrometheus for PrometheusInstance<'a, N, Yes>
where N: Num + Display + Debug,

Source§

fn render(&self) -> String

Render must return the instance formatted string without the metric info.

Auto Trait Implementations§

§

impl<'a, N, ValueSet> Freeze for PrometheusInstance<'a, N, ValueSet>
where N: Freeze,

§

impl<'a, N, ValueSet> RefUnwindSafe for PrometheusInstance<'a, N, ValueSet>
where N: RefUnwindSafe, ValueSet: RefUnwindSafe,

§

impl<'a, N, ValueSet> Send for PrometheusInstance<'a, N, ValueSet>
where N: Send, ValueSet: Send,

§

impl<'a, N, ValueSet> Sync for PrometheusInstance<'a, N, ValueSet>
where N: Sync, ValueSet: Sync,

§

impl<'a, N, ValueSet> Unpin for PrometheusInstance<'a, N, ValueSet>
where N: Unpin, ValueSet: Unpin,

§

impl<'a, N, ValueSet> UnwindSafe for PrometheusInstance<'a, N, ValueSet>
where N: UnwindSafe, ValueSet: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.