pub struct PrometheusHandle { /* private fields */ }Expand description
Handle for accessing metrics stored via PrometheusRecorder.
In certain scenarios, it may be necessary to directly handle requests that would otherwise be
handled directly by the HTTP listener, or push gateway background task. PrometheusHandle
allows rendering a snapshot of the current metrics stored by an installed PrometheusRecorder
as a payload conforming to the Prometheus exposition format.
Implementations§
Source§impl PrometheusHandle
impl PrometheusHandle
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Takes a snapshot of the metrics held by the recorder and generates a payload conforming to the Prometheus exposition format.
Sourcepub fn render_to_write(&self, output: &mut impl Write) -> Result<()>
pub fn render_to_write(&self, output: &mut impl Write) -> Result<()>
Takes a snapshot of the metrics held by the recorder and generates a payload conforming to the Prometheus exposition format, incrementally. Use this function to emit metrics as a stream without buffering the entire metrics export.
§Errors
Writing to the provided output fails.
Sourcepub fn render_protobuf(&self) -> Vec<u8> ⓘ
Available on crate feature protobuf only.
pub fn render_protobuf(&self) -> Vec<u8> ⓘ
protobuf only.Takes a snapshot of the metrics held by the recorder and generates a payload conforming to the Prometheus protobuf format.
Sourcepub fn run_upkeep(&self)
pub fn run_upkeep(&self)
Performs upkeeping operations to ensure metrics held by recorder are up-to-date and do not grow unboundedly.
Trait Implementations§
Source§impl Clone for PrometheusHandle
impl Clone for PrometheusHandle
Source§fn clone(&self) -> PrometheusHandle
fn clone(&self) -> PrometheusHandle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more