Skip to main content

Registry

Struct Registry 

Source
pub struct Registry { /* private fields */ }
Expand description

A registry mapping metric names (+ optional fixed labels) to metrics.

Implementations§

Source§

impl Registry

Source

pub fn new() -> Self

Create an empty registry.

Source

pub fn counter(&self, key: &str, help: &str) -> Arc<Counter>

Register (or fetch) a counter. key must be a valid Prometheus series name with optional {label="v"} suffix.

Panics if key is already registered as a histogram; a silent overwrite would detach the existing metric from the registry and lose every observation collected against it. Also panics if key contains a byte that would corrupt Prometheus text exposition (cross-line bytes anywhere; " or \\ in the base name — both stay legal inside the label section) — this catches accidental interpolation of attacker-controlled strings into a metric key at registration rather than surfacing corrupt scrape output later.

Source

pub fn histogram(&self, key: &str, help: &str) -> Arc<Histogram>

Register (or fetch) a histogram with default latency buckets.

Panics if key is already registered as a counter; a silent overwrite would detach the existing metric from the registry and lose every observation collected against it. Same key-byte guard as Self::counter.

Source

pub fn histogram_with_bounds( &self, key: &str, help: &str, bounds_us: &[u64], ) -> Arc<Histogram>

Register (or fetch) a histogram with explicit bucket bounds. Use WIDE_LATENCY_BOUNDS_US for spans dominated by network I/O (upstream LLM streaming, reconciler filesystem scans); use DEFAULT_LATENCY_BOUNDS_US for fast internal stages.

Source

pub fn render(&self) -> String

Render the registry in Prometheus text exposition format.

Histogram observations are stored internally in microseconds but rendered in seconds (le bounds and _sum), per Prometheus base-unit convention. Histogram metric names should therefore end in _seconds.

Round-19: HELP text is escaped per the Prometheus text format spec (\\\, LF → \n). A future counter/histogram registration whose HELP contained a newline would otherwise silently corrupt the scrape response — Prometheus would parse the remainder of the HELP text as metric samples and fail.

Trait Implementations§

Source§

impl Default for Registry

Source§

fn default() -> Registry

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

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more