summaryrefslogtreecommitdiffstats
path: root/third_party/rust/glean-core/src/metrics
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/glean-core/src/metrics
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/glean-core/src/metrics')
-rw-r--r--third_party/rust/glean-core/src/metrics/event.rs16
-rw-r--r--third_party/rust/glean-core/src/metrics/memory_unit.rs2
-rw-r--r--third_party/rust/glean-core/src/metrics/metrics_enabled_config.rs2
-rw-r--r--third_party/rust/glean-core/src/metrics/ping.rs31
-rw-r--r--third_party/rust/glean-core/src/metrics/string.rs2
-rw-r--r--third_party/rust/glean-core/src/metrics/text.rs2
-rw-r--r--third_party/rust/glean-core/src/metrics/time_unit.rs1
-rw-r--r--third_party/rust/glean-core/src/metrics/timespan.rs1
-rw-r--r--third_party/rust/glean-core/src/metrics/timing_distribution.rs2
-rw-r--r--third_party/rust/glean-core/src/metrics/url.rs2
10 files changed, 47 insertions, 14 deletions
diff --git a/third_party/rust/glean-core/src/metrics/event.rs b/third_party/rust/glean-core/src/metrics/event.rs
index c7aefd9cd6..74f90f4867 100644
--- a/third_party/rust/glean-core/src/metrics/event.rs
+++ b/third_party/rust/glean-core/src/metrics/event.rs
@@ -175,9 +175,21 @@ impl EventMetric {
.into()
.unwrap_or_else(|| &self.meta().inner.send_in_pings[0]);
- glean
+ let events = glean
.event_storage()
- .test_get_value(&self.meta, queried_ping_name)
+ .test_get_value(&self.meta, queried_ping_name);
+
+ events.map(|mut evts| {
+ for ev in &mut evts {
+ let Some(extra) = &mut ev.extra else { continue };
+ extra.remove("glean_timestamp");
+ if extra.is_empty() {
+ ev.extra = None;
+ }
+ }
+
+ evts
+ })
}
/// **Test-only API (exported for FFI purposes).**
diff --git a/third_party/rust/glean-core/src/metrics/memory_unit.rs b/third_party/rust/glean-core/src/metrics/memory_unit.rs
index ce51b975fa..19006a594e 100644
--- a/third_party/rust/glean-core/src/metrics/memory_unit.rs
+++ b/third_party/rust/glean-core/src/metrics/memory_unit.rs
@@ -2,8 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-use std::convert::TryFrom;
-
use serde::{Deserialize, Serialize};
use crate::error::{Error, ErrorKind};
diff --git a/third_party/rust/glean-core/src/metrics/metrics_enabled_config.rs b/third_party/rust/glean-core/src/metrics/metrics_enabled_config.rs
index 26d0deff31..b36cbc150a 100644
--- a/third_party/rust/glean-core/src/metrics/metrics_enabled_config.rs
+++ b/third_party/rust/glean-core/src/metrics/metrics_enabled_config.rs
@@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-use std::{collections::HashMap, convert::TryFrom};
+use std::collections::HashMap;
use serde::{Deserialize, Serialize};
diff --git a/third_party/rust/glean-core/src/metrics/ping.rs b/third_party/rust/glean-core/src/metrics/ping.rs
index e60284b1e2..5defab7a71 100644
--- a/third_party/rust/glean-core/src/metrics/ping.rs
+++ b/third_party/rust/glean-core/src/metrics/ping.rs
@@ -31,6 +31,11 @@ struct InnerPing {
pub include_info_sections: bool,
/// The "reason" codes that this ping can send
pub reason_codes: Vec<String>,
+
+ /// Whether this ping is enabled.
+ /// Note: Data for disabled pings is still recorded.
+ /// It will not be cleared out on submit.
+ enabled: bool,
}
impl fmt::Debug for PingType {
@@ -68,6 +73,26 @@ impl PingType {
include_info_sections: bool,
reason_codes: Vec<String>,
) -> Self {
+ Self::new_internal(
+ name,
+ include_client_id,
+ send_if_empty,
+ precise_timestamps,
+ include_info_sections,
+ reason_codes,
+ true,
+ )
+ }
+
+ pub(crate) fn new_internal<A: Into<String>>(
+ name: A,
+ include_client_id: bool,
+ send_if_empty: bool,
+ precise_timestamps: bool,
+ include_info_sections: bool,
+ reason_codes: Vec<String>,
+ enabled: bool,
+ ) -> Self {
let this = Self(Arc::new(InnerPing {
name: name.into(),
include_client_id,
@@ -75,6 +100,7 @@ impl PingType {
precise_timestamps,
include_info_sections,
reason_codes,
+ enabled,
}));
// Register this ping.
@@ -140,6 +166,11 @@ impl PingType {
/// Whether the ping was succesfully assembled and queued.
#[doc(hidden)]
pub fn submit_sync(&self, glean: &Glean, reason: Option<&str>) -> bool {
+ if !self.0.enabled {
+ log::info!("Ping disabled: not submitting '{}' ping.", self.0.name);
+ return false;
+ }
+
if !glean.is_upload_enabled() {
log::info!("Glean disabled: not submitting any pings.");
return false;
diff --git a/third_party/rust/glean-core/src/metrics/string.rs b/third_party/rust/glean-core/src/metrics/string.rs
index 4aa30a8d7e..a56ffab648 100644
--- a/third_party/rust/glean-core/src/metrics/string.rs
+++ b/third_party/rust/glean-core/src/metrics/string.rs
@@ -149,10 +149,8 @@ impl StringMetric {
#[cfg(test)]
mod test {
use super::*;
- use crate::test_get_num_recorded_errors;
use crate::tests::new_glean;
use crate::util::truncate_string_at_boundary;
- use crate::ErrorType;
use crate::Lifetime;
#[test]
diff --git a/third_party/rust/glean-core/src/metrics/text.rs b/third_party/rust/glean-core/src/metrics/text.rs
index baa8e88d75..35f803c728 100644
--- a/third_party/rust/glean-core/src/metrics/text.rs
+++ b/third_party/rust/glean-core/src/metrics/text.rs
@@ -153,10 +153,8 @@ impl TextMetric {
#[cfg(test)]
mod test {
use super::*;
- use crate::test_get_num_recorded_errors;
use crate::tests::new_glean;
use crate::util::truncate_string_at_boundary;
- use crate::ErrorType;
use crate::Lifetime;
#[test]
diff --git a/third_party/rust/glean-core/src/metrics/time_unit.rs b/third_party/rust/glean-core/src/metrics/time_unit.rs
index 6d61a8a242..6c68d5dff0 100644
--- a/third_party/rust/glean-core/src/metrics/time_unit.rs
+++ b/third_party/rust/glean-core/src/metrics/time_unit.rs
@@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-use std::convert::TryFrom;
use std::time::Duration;
use serde::{Deserialize, Serialize};
diff --git a/third_party/rust/glean-core/src/metrics/timespan.rs b/third_party/rust/glean-core/src/metrics/timespan.rs
index ee63fb52f8..d72492a590 100644
--- a/third_party/rust/glean-core/src/metrics/timespan.rs
+++ b/third_party/rust/glean-core/src/metrics/timespan.rs
@@ -2,7 +2,6 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
-use std::convert::TryInto;
use std::sync::{Arc, RwLock};
use std::time::Duration;
diff --git a/third_party/rust/glean-core/src/metrics/timing_distribution.rs b/third_party/rust/glean-core/src/metrics/timing_distribution.rs
index 3293be9518..776935afea 100644
--- a/third_party/rust/glean-core/src/metrics/timing_distribution.rs
+++ b/third_party/rust/glean-core/src/metrics/timing_distribution.rs
@@ -96,7 +96,7 @@ impl TimingDistributionMetric {
Self {
meta: Arc::new(meta.into()),
time_unit,
- next_id: Arc::new(AtomicUsize::new(0)),
+ next_id: Arc::new(AtomicUsize::new(1)),
start_times: Arc::new(Mutex::new(Default::default())),
}
}
diff --git a/third_party/rust/glean-core/src/metrics/url.rs b/third_party/rust/glean-core/src/metrics/url.rs
index 48b3f9e7ae..0fd5712eeb 100644
--- a/third_party/rust/glean-core/src/metrics/url.rs
+++ b/third_party/rust/glean-core/src/metrics/url.rs
@@ -168,9 +168,7 @@ impl UrlMetric {
#[cfg(test)]
mod test {
use super::*;
- use crate::test_get_num_recorded_errors;
use crate::tests::new_glean;
- use crate::ErrorType;
use crate::Lifetime;
#[test]