From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- third_party/rust/glean-core/src/metrics/ping.rs | 28 ++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (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 dc37d76a45..e60284b1e2 100644 --- a/third_party/rust/glean-core/src/metrics/ping.rs +++ b/third_party/rust/glean-core/src/metrics/ping.rs @@ -6,6 +6,7 @@ use std::fmt; use std::sync::Arc; use crate::ping::PingMaker; +use crate::upload::PingPayload; use crate::Glean; use uuid::Uuid; @@ -26,6 +27,8 @@ struct InnerPing { pub send_if_empty: bool, /// Whether to use millisecond-precise start/end times. pub precise_timestamps: bool, + /// Whether to include the {client|ping}_info sections on assembly. + pub include_info_sections: bool, /// The "reason" codes that this ping can send pub reason_codes: Vec, } @@ -37,6 +40,7 @@ impl fmt::Debug for PingType { .field("include_client_id", &self.0.include_client_id) .field("send_if_empty", &self.0.send_if_empty) .field("precise_timestamps", &self.0.precise_timestamps) + .field("include_info_sections", &self.0.include_info_sections) .field("reason_codes", &self.0.reason_codes) .finish() } @@ -61,6 +65,7 @@ impl PingType { include_client_id: bool, send_if_empty: bool, precise_timestamps: bool, + include_info_sections: bool, reason_codes: Vec, ) -> Self { let this = Self(Arc::new(InnerPing { @@ -68,6 +73,7 @@ impl PingType { include_client_id, send_if_empty, precise_timestamps, + include_info_sections, reason_codes, })); @@ -94,6 +100,10 @@ impl PingType { self.0.precise_timestamps } + pub(crate) fn include_info_sections(&self) -> bool { + self.0.include_info_sections + } + /// Submits the ping for eventual uploading. /// /// The ping content is assembled as soon as possible, but upload is not @@ -186,13 +196,17 @@ impl PingType { // so both scenarios should be impossible. let content = ::serde_json::to_string(&ping.content).expect("ping serialization failed"); - glean.upload_manager.enqueue_ping( - glean, - ping.doc_id, - ping.url_path, - &content, - Some(ping.headers), - ); + // TODO: Shouldn't we consolidate on a single collected Ping representation? + let ping = PingPayload { + document_id: ping.doc_id.to_string(), + upload_path: ping.url_path.to_string(), + json_body: content, + headers: Some(ping.headers), + body_has_info_sections: self.0.include_info_sections, + ping_name: self.0.name.to_string(), + }; + + glean.upload_manager.enqueue_ping(glean, ping); return true; } -- cgit v1.2.3