glean_core/traits/
dual_labeled_counter.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use crate::{CounterMetric, ErrorType};
6
7/// A description for the [`DualLabeledCounterMetric`](crate::metrics::DualLabeledCounterMetric) type.
8///
9/// When changing this trait, make sure all the operations are
10/// implemented in the related type in `../metrics/`.
11pub trait DualLabeledCounter {
12    /// Gets a specific counter for a given key/category pair.
13    ///
14    /// If a set of acceptable keys or categorires were specified in the `metrics.yaml` file,
15    /// and the given label is not in the set, it will be recorded under the special `OTHER_LABEL` label.
16    ///
17    /// If a set of acceptable keys and/or categories was not specified in the `metrics.yaml` file,
18    /// only the first 16 unique labels will be used.
19    /// After that, any additional labels will be recorded under the special `OTHER_LABEL` label.
20    ///
21    /// Labels must have a maximum of 111 characters, and may comprise any printable ASCII characters.
22    /// If an invalid label is used, the metric will be recorded in the special `OTHER_LABEL` label.
23    fn get(&self, key: &str, category: &str) -> CounterMetric;
24
25    /// **Exported for test purposes.**
26    ///
27    /// Gets the number of recorded errors for the given metric and error type.
28    ///
29    /// # Arguments
30    ///
31    /// * `error` - The type of error
32    ///
33    /// # Returns
34    ///
35    /// The number of errors reported.
36    fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32;
37}