diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/glean/tests/pytest/metrics_test_output | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/glean/tests/pytest/metrics_test_output')
-rw-r--r-- | toolkit/components/glean/tests/pytest/metrics_test_output | 138 |
1 files changed, 114 insertions, 24 deletions
diff --git a/toolkit/components/glean/tests/pytest/metrics_test_output b/toolkit/components/glean/tests/pytest/metrics_test_output index 76808cc984..0f93eb032d 100644 --- a/toolkit/components/glean/tests/pytest/metrics_test_output +++ b/toolkit/components/glean/tests/pytest/metrics_test_output @@ -6,6 +6,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + pub enum DynamicLabel { } pub mod test { @@ -16,6 +17,9 @@ pub mod test { use glean::HistogramType; use once_cell::sync::Lazy; + #[allow(unused_imports)] + use std::convert::TryFrom; + #[allow(non_upper_case_globals)] /// generated from test.boolean_metric /// @@ -361,13 +365,40 @@ pub mod test_nested { use glean::HistogramType; use once_cell::sync::Lazy; + #[allow(unused_imports)] + use std::convert::TryFrom; + + pub type AnObjectObject = Vec<AnObjectObjectItem>; + + #[derive(Debug, Hash, Eq, PartialEq, ::glean::traits::__serde::Serialize, ::glean::traits::__serde::Deserialize)] + #[serde(deny_unknown_fields)] + pub struct AnObjectObjectItem { + pub colour: Option<String>, + pub diameter: Option<i64>, + } + + #[allow(non_upper_case_globals)] + /// generated from test.nested.an_object + /// + /// An example object + pub static an_object: Lazy<ObjectMetric<AnObjectObject>> = Lazy::new(|| { + ObjectMetric::new(16.into(), CommonMetricData { + name: "an_object".into(), + category: "test.nested".into(), + send_in_pings: vec!["metrics".into()], + lifetime: Lifetime::Ping, + disabled: false, + ..Default::default() + }) + }); + #[allow(non_upper_case_globals)] /// generated from test.nested.datetime_metric /// /// A multi-line /// description pub static datetime_metric: Lazy<DatetimeMetric> = Lazy::new(|| { - DatetimeMetric::new(16.into(), CommonMetricData { + DatetimeMetric::new(17.into(), CommonMetricData { name: "datetime_metric".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -383,7 +414,7 @@ pub mod test_nested { /// A multi-line /// description pub static event_metric: Lazy<EventMetric<NoExtraKeys>> = Lazy::new(|| { - EventMetric::new(17.into(), CommonMetricData { + EventMetric::new(18.into(), CommonMetricData { name: "event_metric".into(), category: "test.nested".into(), send_in_pings: vec!["events".into()], @@ -415,7 +446,7 @@ pub mod test_nested { /// A multi-line /// description pub static event_metric_with_extra: Lazy<EventMetric<EventMetricWithExtraExtra>> = Lazy::new(|| { - EventMetric::new(18.into(), CommonMetricData { + EventMetric::new(19.into(), CommonMetricData { name: "event_metric_with_extra".into(), category: "test.nested".into(), send_in_pings: vec!["events".into()], @@ -431,7 +462,7 @@ pub mod test_nested { /// A multi-line /// description pub static external_denominator: Lazy<DenominatorMetric> = Lazy::new(|| { - DenominatorMetric::new(19.into(), CommonMetricData { + DenominatorMetric::new(20.into(), CommonMetricData { name: "external_denominator".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -448,7 +479,7 @@ pub mod test_nested { /// description pub static optimizable_counter_metric: Lazy<CounterMetric> = Lazy::new(|| { CounterMetric::codegen_new( - 20, + 21, "test.nested", "optimizable_counter_metric", "metrics" @@ -461,7 +492,7 @@ pub mod test_nested { /// A multi-line /// description pub static quantity_metric: Lazy<QuantityMetric> = Lazy::new(|| { - QuantityMetric::new(21.into(), CommonMetricData { + QuantityMetric::new(22.into(), CommonMetricData { name: "quantity_metric".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -477,7 +508,7 @@ pub mod test_nested { /// A multi-line /// description pub static rate_metric: Lazy<RateMetric> = Lazy::new(|| { - RateMetric::new(22.into(), CommonMetricData { + RateMetric::new(23.into(), CommonMetricData { name: "rate_metric".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -493,7 +524,7 @@ pub mod test_nested { /// A multi-line /// description pub static rate_with_external_denominator: Lazy<NumeratorMetric> = Lazy::new(|| { - NumeratorMetric::new(23.into(), CommonMetricData { + NumeratorMetric::new(24.into(), CommonMetricData { name: "rate_with_external_denominator".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -509,7 +540,7 @@ pub mod test_nested { /// A multi-line /// description pub static uuid_metric: Lazy<UuidMetric> = Lazy::new(|| { - UuidMetric::new(24.into(), CommonMetricData { + UuidMetric::new(25.into(), CommonMetricData { name: "uuid_metric".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], @@ -538,7 +569,7 @@ pub(crate) mod __glean_metric_maps { pub static COUNTER_MAP: Lazy<HashMap<MetricId, &Lazy<CounterMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(2); map.insert(2.into(), &super::test::counter_metric); - map.insert(20.into(), &super::test_nested::optimizable_counter_metric); + map.insert(21.into(), &super::test_nested::optimizable_counter_metric); map }); @@ -586,41 +617,100 @@ pub(crate) mod __glean_metric_maps { pub static DATETIME_MAP: Lazy<HashMap<MetricId, &Lazy<DatetimeMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(16.into(), &super::test_nested::datetime_metric); + map.insert(17.into(), &super::test_nested::datetime_metric); map }); pub static DENOMINATOR_MAP: Lazy<HashMap<MetricId, &Lazy<DenominatorMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(19.into(), &super::test_nested::external_denominator); + map.insert(20.into(), &super::test_nested::external_denominator); map }); pub static QUANTITY_MAP: Lazy<HashMap<MetricId, &Lazy<QuantityMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(21.into(), &super::test_nested::quantity_metric); + map.insert(22.into(), &super::test_nested::quantity_metric); map }); pub static RATE_MAP: Lazy<HashMap<MetricId, &Lazy<RateMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(22.into(), &super::test_nested::rate_metric); + map.insert(23.into(), &super::test_nested::rate_metric); map }); pub static NUMERATOR_MAP: Lazy<HashMap<MetricId, &Lazy<NumeratorMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(23.into(), &super::test_nested::rate_with_external_denominator); + map.insert(24.into(), &super::test_nested::rate_with_external_denominator); map }); pub static UUID_MAP: Lazy<HashMap<MetricId, &Lazy<UuidMetric>>> = Lazy::new(|| { let mut map = HashMap::with_capacity(1); - map.insert(24.into(), &super::test_nested::uuid_metric); + map.insert(25.into(), &super::test_nested::uuid_metric); map }); + pub(crate) fn set_object_by_id(metric_id: u32, value: String) -> Result<(), ()> { + match metric_id { + 16 => { + super::test_nested::an_object.set_string(value); + Ok(()) + } + _ => Err(()), + } + } + + /// Wrapper to get the currently stored object for object metric as a string. + /// + /// # Arguments + /// + /// * `metric_id` - The metric's ID to look up + /// * `ping_name` - (Optional) The ping name to look into. + /// Defaults to the first value in `send_in_pings`. + /// + /// # Returns + /// + /// Returns the recorded object serialized as a JSON string or `None` if nothing stored. + /// + /// # Panics + /// + /// Panics if no object by the given metric ID could be found. + pub(crate) fn object_test_get_value(metric_id: u32, ping_name: Option<String>) -> Option<String> { + match metric_id { + 16 => super::test_nested::an_object.test_get_value_as_str(ping_name.as_deref()), + _ => panic!("No object for metric id {}", metric_id), + } + } + + /// Check the provided object for errors. + /// + /// # Arguments + /// + /// * `metric_id` - The metric's ID to look up + /// + /// # Returns + /// + /// Returns a string for the recorded error or `None`. + /// + /// # Panics + /// + /// Panics if no object by the given metric ID could be found. + #[allow(unused_variables)] + pub(crate) fn object_test_get_error(metric_id: u32) -> Option<String> { + #[cfg(feature = "with_gecko")] + match metric_id { + 16 => test_get_errors!(super::test_nested::an_object), + _ => panic!("No object for metric id {}", metric_id), + } + + #[cfg(not(feature = "with_gecko"))] + { + return None; + } + } + /// Wrapper to record an event based on its metric ID. /// /// # Arguments @@ -635,7 +725,7 @@ pub(crate) mod __glean_metric_maps { /// or an `EventRecordingError::InvalidExtraKey` if the `extra` map could not be deserialized. pub(crate) fn record_event_by_id(metric_id: u32, extra: HashMap<String, String>) -> Result<(), EventRecordingError> { match metric_id { - 17 => { + 18 => { assert!( extra_keys_len(&super::test_nested::event_metric) != 0 || extra.is_empty(), "No extra keys allowed, but some were passed" @@ -644,7 +734,7 @@ pub(crate) mod __glean_metric_maps { super::test_nested::event_metric.record_raw(extra); Ok(()) } - 18 => { + 19 => { assert!( extra_keys_len(&super::test_nested::event_metric_with_extra) != 0 || extra.is_empty(), "No extra keys allowed, but some were passed" @@ -673,7 +763,7 @@ pub(crate) mod __glean_metric_maps { /// but some are passed in. pub(crate) fn record_event_by_id_with_time(metric_id: MetricId, timestamp: u64, extra: HashMap<String, String>) -> Result<(), EventRecordingError> { match metric_id { - MetricId(17) => { + MetricId(18) => { if extra_keys_len(&super::test_nested::event_metric) == 0 && !extra.is_empty() { return Err(EventRecordingError::InvalidExtraKey); } @@ -681,7 +771,7 @@ pub(crate) mod __glean_metric_maps { super::test_nested::event_metric.record_with_time(timestamp, extra); Ok(()) } - MetricId(18) => { + MetricId(19) => { if extra_keys_len(&super::test_nested::event_metric_with_extra) == 0 && !extra.is_empty() { return Err(EventRecordingError::InvalidExtraKey); } @@ -710,8 +800,8 @@ pub(crate) mod __glean_metric_maps { /// Panics if no event by the given metric ID could be found. pub(crate) fn event_test_get_value_wrapper(metric_id: u32, ping_name: Option<String>) -> Option<Vec<RecordedEvent>> { match metric_id { - 17 => super::test_nested::event_metric.test_get_value(ping_name.as_deref()), - 18 => super::test_nested::event_metric_with_extra.test_get_value(ping_name.as_deref()), + 18 => super::test_nested::event_metric.test_get_value(ping_name.as_deref()), + 19 => super::test_nested::event_metric_with_extra.test_get_value(ping_name.as_deref()), _ => panic!("No event for metric id {}", metric_id), } } @@ -735,8 +825,8 @@ pub(crate) mod __glean_metric_maps { pub(crate) fn event_test_get_error(metric_id: u32) -> Option<String> { #[cfg(feature = "with_gecko")] match metric_id { - 17 => test_get_errors!(super::test_nested::event_metric), - 18 => test_get_errors!(super::test_nested::event_metric_with_extra), + 18 => test_get_errors!(super::test_nested::event_metric), + 19 => test_get_errors!(super::test_nested::event_metric_with_extra), _ => panic!("No event for metric id {}", metric_id), } |