From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- third_party/rust/glean-core/src/metrics/ping.rs | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'third_party/rust/glean-core/src/metrics/ping.rs') 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, + + /// 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 { @@ -67,6 +72,26 @@ impl PingType { precise_timestamps: bool, include_info_sections: bool, reason_codes: Vec, + ) -> Self { + Self::new_internal( + name, + include_client_id, + send_if_empty, + precise_timestamps, + include_info_sections, + reason_codes, + true, + ) + } + + pub(crate) fn new_internal>( + name: A, + include_client_id: bool, + send_if_empty: bool, + precise_timestamps: bool, + include_info_sections: bool, + reason_codes: Vec, + enabled: bool, ) -> Self { let this = Self(Arc::new(InnerPing { name: name.into(), @@ -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; -- cgit v1.2.3