diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /third_party/rust/glean-core/src/metrics/ping.rs | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-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/ping.rs')
-rw-r--r-- | third_party/rust/glean-core/src/metrics/ping.rs | 31 |
1 files changed, 31 insertions, 0 deletions
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; |