Struct prometheus_client::metrics::exemplar::HistogramWithExemplars
source · pub struct HistogramWithExemplars<S> { /* private fields */ }
Expand description
Open Metrics Histogram
to both measure distributions of discrete events.
and track references to data outside of the metric set.
let histogram = HistogramWithExemplars::new(exponential_buckets(1.0, 2.0, 10));
histogram.observe(4.2, Some(vec![("user_id".to_string(), "42".to_string())]));
You can also use exemplars with families. Just wrap the exemplar in a Family.
#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug, Default)]
pub struct ResultLabel {
pub result: String,
}
#[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug, Default)]
pub struct TraceLabel {
pub trace_id: String,
}
let latency: Family<ResultLabel, HistogramWithExemplars<TraceLabel>> =
Family::new_with_constructor(|| {
HistogramWithExemplars::new(exponential_buckets(1.0, 2.0, 10))
});
latency
.get_or_create(&ResultLabel {
result: "success".to_owned(),
})
.observe(
0.001345422,
Some(TraceLabel {
trace_id: "3a2f90c9f80b894f".to_owned(),
}),
);
Implementations§
Trait Implementations§
source§impl<S> Clone for HistogramWithExemplars<S>
impl<S> Clone for HistogramWithExemplars<S>
source§impl<S: Debug> Debug for HistogramWithExemplars<S>
impl<S: Debug> Debug for HistogramWithExemplars<S>
source§impl<S: EncodeLabelSet> EncodeMetric for HistogramWithExemplars<S>
impl<S: EncodeLabelSet> EncodeMetric for HistogramWithExemplars<S>
source§fn encode(&self, encoder: MetricEncoder<'_, '_>) -> Result<(), Error>
fn encode(&self, encoder: MetricEncoder<'_, '_>) -> Result<(), Error>
Encode the given instance in the OpenMetrics text encoding.
source§fn metric_type(&self) -> MetricType
fn metric_type(&self) -> MetricType
The OpenMetrics metric type of the instance.
source§impl<S> TypedMetric for HistogramWithExemplars<S>
impl<S> TypedMetric for HistogramWithExemplars<S>
source§const TYPE: MetricType = MetricType::Histogram
const TYPE: MetricType = MetricType::Histogram
The OpenMetrics metric type.
Auto Trait Implementations§
impl<S> !RefUnwindSafe for HistogramWithExemplars<S>
impl<S> Send for HistogramWithExemplars<S>where S: Send + Sync,
impl<S> Sync for HistogramWithExemplars<S>where S: Send + Sync,
impl<S> Unpin for HistogramWithExemplars<S>
impl<S> !UnwindSafe for HistogramWithExemplars<S>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more