Struct glean_core::metrics::LabeledMetric
source · [−]pub struct LabeledMetric<T> { /* private fields */ }
Expand description
A labeled metric.
Labeled metrics allow to record multiple sub-metrics of the same type under different string labels.
Implementations
sourceimpl<T> LabeledMetric<T> where
T: MetricType + Clone,
impl<T> LabeledMetric<T> where
T: MetricType + Clone,
sourcepub fn new(submetric: T, labels: Option<Vec<String>>) -> LabeledMetric<T>
pub fn new(submetric: T, labels: Option<Vec<String>>) -> LabeledMetric<T>
Creates a new labeled metric from the given metric instance and optional list of labels.
See get
for information on how static or dynamic labels are handled.
sourcepub fn get(&self, label: &str) -> T
pub fn get(&self, label: &str) -> T
Gets a specific metric for a given label.
If a set of acceptable labels were specified in the metrics.yaml
file,
and the given label is not in the set, it will be recorded under the special OTHER_LABEL
label.
If a set of acceptable labels was not specified in the metrics.yaml
file,
only the first 16 unique labels will be used.
After that, any additional labels will be recorded under the special OTHER_LABEL
label.
Labels must be snake_case
and less than 30 characters.
If an invalid label is used, the metric will be recorded in the special OTHER_LABEL
label.
sourcepub fn get_submetric(&self) -> &T
pub fn get_submetric(&self) -> &T
Gets the template submetric.
The template submetric is the actual metric that is cloned and modified to record for a specific label.
Trait Implementations
sourceimpl<T: Clone> Clone for LabeledMetric<T>
impl<T: Clone> Clone for LabeledMetric<T>
sourcefn clone(&self) -> LabeledMetric<T>
fn clone(&self) -> LabeledMetric<T>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<T> RefUnwindSafe for LabeledMetric<T> where
T: RefUnwindSafe,
impl<T> Send for LabeledMetric<T> where
T: Send,
impl<T> Sync for LabeledMetric<T> where
T: Sync,
impl<T> Unpin for LabeledMetric<T> where
T: Unpin,
impl<T> UnwindSafe for LabeledMetric<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more