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 behave exactly the same as their inner metric. - when
metric_level>relabel_threshold, the firstrelabel_numlabels 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.
§Note
CAUTION! Relabelling might cause expected result!
For counters (including histogram because it uses counters internally), it’s usually natural to sum up the count from multiple labels.
For the rest (such as Gauge), the semantics becomes “any/last of the recorded value”. Please be cautious.
Fields§
§relabel_threshold: MetricLevel§metric_level: MetricLevel§metric: M§relabel_num: usizeThe 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>>
Source§impl<T: MetricVecBuilder> RelabeledMetricVec<LabelGuardedMetricVec<T>>
impl<T: MetricVecBuilder> RelabeledMetricVec<LabelGuardedMetricVec<T>>
pub fn with_guarded_label_values<V: AsRef<str> + Debug>( &self, vals: &[V], ) -> LabelGuardedMetric<T::M>
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>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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>
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>
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>
T in a tonic::RequestSource§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>
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>
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>
RelabeledMetricVec::with_metric_level_relabel_n with metric_level set to
MetricLevel::Debug and relabel_num set to 1.