pub struct RelabeledMetricVec<M> {
relabel_threshold: MetricLevel,
metric_level: MetricLevel,
metric: M,
relabel_num: usize,
}
Expand description
For all Relabeled*Vec
below,
- when
metric_level
<=relabel_threshold
, they behaves exactly the same as their inner metric. - when
metric_level
>relabel_threshold
, all their input label values are rewrite to “” when callingwith_label_values
. That’s means the metric vec is aggregated into a single metric.
These wrapper classes add a metric_level
field to corresponding metric.
We could have use one single struct to represent all MetricVec<T: MetricVecBuilder>
, rather
than specializing them one by one. However, that’s undoable because prometheus crate doesn’t
export MetricVecBuilder
implementation like HistogramVecBuilder
.
Fields§
§relabel_threshold: MetricLevel
§metric_level: MetricLevel
§metric: M
§relabel_num: usize
The first relabel_num
labels will be relabeled to empty string
For example, if relabel_num
is 1, and the input labels are ["actor_id", "fragment_id", "table_id"]
, when threshold is reached, the label values will be
["", "<original_fragment_id>", "<original_table_id>"]
.
Implementations§
source§impl<M> RelabeledMetricVec<M>
impl<M> RelabeledMetricVec<M>
pub fn with_metric_level( metric_level: MetricLevel, metric: M, relabel_threshold: MetricLevel, ) -> Self
pub fn with_metric_level_relabel_n( metric_level: MetricLevel, metric: M, relabel_threshold: MetricLevel, relabel_num: usize, ) -> Self
source§impl<T: MetricVecBuilder> RelabeledMetricVec<MetricVec<T>>
impl<T: MetricVecBuilder> RelabeledMetricVec<MetricVec<T>>
pub fn with_label_values(&self, vals: &[&str]) -> T::M
source§impl<T: MetricVecBuilder, const N: usize> RelabeledMetricVec<LabelGuardedMetricVec<T, N>>
impl<T: MetricVecBuilder, const N: usize> RelabeledMetricVec<LabelGuardedMetricVec<T, N>>
pub fn with_guarded_label_values( &self, vals: &[&str; N], ) -> LabelGuardedMetric<T::M, N>
Trait Implementations§
source§impl<M: Clone> Clone for RelabeledMetricVec<M>
impl<M: Clone> Clone for RelabeledMetricVec<M>
source§fn clone(&self) -> RelabeledMetricVec<M>
fn clone(&self) -> RelabeledMetricVec<M>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Collector> Collector for RelabeledMetricVec<T>
impl<T: Collector> Collector for RelabeledMetricVec<T>
Auto Trait Implementations§
impl<M> Freeze for RelabeledMetricVec<M>where
M: Freeze,
impl<M> RefUnwindSafe for RelabeledMetricVec<M>where
M: RefUnwindSafe,
impl<M> Send for RelabeledMetricVec<M>where
M: Send,
impl<M> Sync for RelabeledMetricVec<M>where
M: Sync,
impl<M> Unpin for RelabeledMetricVec<M>where
M: Unpin,
impl<M> UnwindSafe for RelabeledMetricVec<M>where
M: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request
source§impl<M> MetricVecRelabelExt for M
impl<M> MetricVecRelabelExt for M
source§fn relabel(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
Equivalent to
RelabeledMetricVec::with_metric_level
.source§fn relabel_n(
self,
metric_level: MetricLevel,
relabel_threshold: MetricLevel,
relabel_num: usize,
) -> RelabeledMetricVec<M>
fn relabel_n( self, metric_level: MetricLevel, relabel_threshold: MetricLevel, relabel_num: usize, ) -> RelabeledMetricVec<M>
Equivalent to
RelabeledMetricVec::with_metric_level_relabel_n
.source§fn relabel_debug_1(
self,
relabel_threshold: MetricLevel,
) -> RelabeledMetricVec<M>
fn relabel_debug_1( self, relabel_threshold: MetricLevel, ) -> RelabeledMetricVec<M>
Equivalent to
RelabeledMetricVec::with_metric_level_relabel_n
with metric_level
set to
MetricLevel::Debug
and relabel_num
set to 1.