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/src/common_test.rs | 1 + third_party/rust/glean/src/configuration.rs | 2 +- third_party/rust/glean/src/lib.rs | 2 +- third_party/rust/glean/src/net/http_uploader.rs | 11 +- third_party/rust/glean/src/net/mod.rs | 25 ++- third_party/rust/glean/src/private/mod.rs | 2 + third_party/rust/glean/src/private/object.rs | 192 +++++++++++++++++++++ third_party/rust/glean/src/private/ping.rs | 2 + third_party/rust/glean/src/test.rs | 215 ++++++++++-------------- 9 files changed, 313 insertions(+), 139 deletions(-) create mode 100644 third_party/rust/glean/src/private/object.rs (limited to 'third_party/rust/glean/src') diff --git a/third_party/rust/glean/src/common_test.rs b/third_party/rust/glean/src/common_test.rs index fdb7cfadbf..e3c80da5f2 100644 --- a/third_party/rust/glean/src/common_test.rs +++ b/third_party/rust/glean/src/common_test.rs @@ -42,6 +42,7 @@ pub(crate) fn new_glean( Some(c) => c, None => ConfigurationBuilder::new(true, tmpname, GLOBAL_APPLICATION_ID) .with_server_endpoint("invalid-test-host") + .with_event_timestamps(false) .build(), }; diff --git a/third_party/rust/glean/src/configuration.rs b/third_party/rust/glean/src/configuration.rs index 42360e96e0..ca0a39c3f1 100644 --- a/third_party/rust/glean/src/configuration.rs +++ b/third_party/rust/glean/src/configuration.rs @@ -113,7 +113,7 @@ impl Builder { trim_data_to_registered_pings: false, log_level: None, rate_limit: None, - enable_event_timestamps: false, + enable_event_timestamps: true, experimentation_id: None, } } diff --git a/third_party/rust/glean/src/lib.rs b/third_party/rust/glean/src/lib.rs index 538b8c590d..5c5b945a95 100644 --- a/third_party/rust/glean/src/lib.rs +++ b/third_party/rust/glean/src/lib.rs @@ -23,7 +23,7 @@ //! let cfg = ConfigurationBuilder::new(true, "/tmp/data", "org.mozilla.glean_core.example").build(); //! glean::initialize(cfg, ClientInfoMetrics::unknown()); //! -//! let prototype_ping = PingType::new("prototype", true, true, true, vec!()); +//! let prototype_ping = PingType::new("prototype", true, true, true, true, vec!()); //! //! prototype_ping.submit(None); //! ``` diff --git a/third_party/rust/glean/src/net/http_uploader.rs b/third_party/rust/glean/src/net/http_uploader.rs index 4646fe61b4..4ca1687acf 100644 --- a/third_party/rust/glean/src/net/http_uploader.rs +++ b/third_party/rust/glean/src/net/http_uploader.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 crate::net::{PingUploader, UploadResult}; +use crate::net::{PingUploadRequest, PingUploader, UploadResult}; /// A simple mechanism to upload pings over HTTPS. #[derive(Debug)] @@ -13,12 +13,9 @@ impl PingUploader for HttpUploader { /// /// # Arguments /// - /// * `url` - the URL path to upload the data to. - /// * `body` - the serialized text data to send. - /// * `headers` - a vector of tuples containing the headers to send with - /// the request, i.e. (Name, Value). - fn upload(&self, url: String, _body: Vec, _headers: Vec<(String, String)>) -> UploadResult { - log::debug!("TODO bug 1675468: submitting to {:?}", url); + /// * `upload_request` - the requested upload. + fn upload(&self, upload_request: PingUploadRequest) -> UploadResult { + log::debug!("TODO bug 1675468: submitting to {:?}", upload_request.url); UploadResult::http_status(200) } } diff --git a/third_party/rust/glean/src/net/mod.rs b/third_party/rust/glean/src/net/mod.rs index 5571d30e67..5546078e63 100644 --- a/third_party/rust/glean/src/net/mod.rs +++ b/third_party/rust/glean/src/net/mod.rs @@ -19,6 +19,20 @@ use thread_state::{AtomicState, State}; mod http_uploader; +/// Everything you need to request a ping to be uploaded. +pub struct PingUploadRequest { + /// The URL the Glean SDK expects you to use to upload the ping. + pub url: String, + /// The body, already content-encoded, for upload. + pub body: Vec, + /// The HTTP headers, including any Content-Encoding. + pub headers: Vec<(String, String)>, + /// Whether the body has {client|ping}_info sections in it. + pub body_has_info_sections: bool, + /// The name (aka doctype) of the ping. + pub ping_name: String, +} + /// A description of a component used to upload pings. pub trait PingUploader: std::fmt::Debug + Send + Sync { /// Uploads a ping to a server. @@ -29,7 +43,7 @@ pub trait PingUploader: std::fmt::Debug + Send + Sync { /// * `body` - the serialized text data to send. /// * `headers` - a vector of tuples containing the headers to send with /// the request, i.e. (Name, Value). - fn upload(&self, url: String, body: Vec, headers: Vec<(String, String)>) -> UploadResult; + fn upload(&self, upload_request: PingUploadRequest) -> UploadResult; } /// The logic for uploading pings: this leaves the actual upload mechanism as @@ -105,7 +119,14 @@ impl UploadManager { let upload_url = format!("{}{}", inner.server_endpoint, request.path); let headers: Vec<(String, String)> = request.headers.into_iter().collect(); - let result = inner.uploader.upload(upload_url, request.body, headers); + let upload_request = PingUploadRequest { + url: upload_url, + body: request.body, + headers, + body_has_info_sections: request.body_has_info_sections, + ping_name: request.ping_name, + }; + let result = inner.uploader.upload(upload_request); // Process the upload response. match glean_core::glean_process_ping_upload_response(doc_id, result) { UploadTaskAction::Next => (), diff --git a/third_party/rust/glean/src/private/mod.rs b/third_party/rust/glean/src/private/mod.rs index 8a5c304193..575707cf59 100644 --- a/third_party/rust/glean/src/private/mod.rs +++ b/third_party/rust/glean/src/private/mod.rs @@ -5,6 +5,7 @@ //! The different metric types supported by the Glean SDK to handle data. mod event; +mod object; mod ping; pub use event::EventMetric; @@ -26,6 +27,7 @@ pub use glean_core::UrlMetric; pub use glean_core::UuidMetric; pub use glean_core::{AllowLabeled, LabeledMetric}; pub use glean_core::{Datetime, DatetimeMetric}; +pub use object::ObjectMetric; pub use ping::PingType; // Re-export types that are used by the glean_parser-generated code. diff --git a/third_party/rust/glean/src/private/object.rs b/third_party/rust/glean/src/private/object.rs new file mode 100644 index 0000000000..f7403ec889 --- /dev/null +++ b/third_party/rust/glean/src/private/object.rs @@ -0,0 +1,192 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// 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::marker::PhantomData; + +use glean_core::metrics::JsonValue; +use glean_core::traits; + +use crate::ErrorType; + +// We need to wrap the glean-core type: otherwise if we try to implement +// the trait for the metric in `glean_core::metrics` we hit error[E0117]: +// only traits defined in the current crate can be implemented for arbitrary +// types. + +/// Developer-facing API for recording object metrics. +/// +/// Instances of this class type are automatically generated by the parsers +/// at build time, allowing developers to record values that were previously +/// registered in the metrics.yaml file. +#[derive(Clone)] +pub struct ObjectMetric { + pub(crate) inner: glean_core::metrics::ObjectMetric, + object_type: PhantomData, +} + +impl ObjectMetric { + /// The public constructor used by automatically generated metrics. + pub fn new(meta: glean_core::CommonMetricData) -> Self { + let inner = glean_core::metrics::ObjectMetric::new(meta); + Self { + inner, + object_type: PhantomData, + } + } + + /// Sets to the specified structure. + /// + /// # Arguments + /// + /// * `object` - the object to set. + pub fn set(&self, object: K) { + let obj = object + .into_serialized_object() + .expect("failed to serialize object. This should be impossible."); + self.inner.set(obj); + } + + /// Sets to the specified structure. + /// + /// Parses the passed JSON string. + /// If it can't be parsed into a valid object it records an invalid value error. + /// + /// # Arguments + /// + /// * `object` - JSON representation of the object to set. + pub fn set_string(&self, object: String) { + let data = match K::from_str(&object) { + Ok(data) => data, + Err(_) => { + self.inner.record_schema_error(); + return; + } + }; + self.set(data) + } + + /// **Test-only API (exported for FFI purposes).** + /// + /// Gets the currently stored value as JSON-encoded string. + /// + /// This doesn't clear the stored value. + pub fn test_get_value<'a, S: Into>>(&self, ping_name: S) -> Option { + let ping_name = ping_name.into().map(|s| s.to_string()); + self.inner.test_get_value(ping_name) + } + + /// **Exported for test purposes.** + /// + /// Gets the number of recorded errors for the given metric and error type. + /// + /// # Arguments + /// + /// * `error` - The type of error + /// + /// # Returns + /// + /// The number of errors reported. + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + self.inner.test_get_num_recorded_errors(error) + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::common_test::{lock_test, new_glean}; + use crate::CommonMetricData; + + use serde_json::json; + + #[test] + fn simple_array() { + let _lock = lock_test(); + let _t = new_glean(None, true); + + type SimpleArray = Vec; + + let metric: ObjectMetric = ObjectMetric::new(CommonMetricData { + name: "object".into(), + category: "test".into(), + send_in_pings: vec!["test1".into()], + ..Default::default() + }); + + let arr = SimpleArray::from([1, 2, 3]); + metric.set(arr); + + let data = metric.test_get_value(None).expect("no object recorded"); + let expected = json!([1, 2, 3]); + assert_eq!(expected, data); + } + + #[test] + fn complex_nested_object() { + let _lock = lock_test(); + let _t = new_glean(None, true); + + type BalloonsObject = Vec; + + #[derive( + Debug, Hash, Eq, PartialEq, traits::__serde::Deserialize, traits::__serde::Serialize, + )] + #[serde(crate = "traits::__serde")] + #[serde(deny_unknown_fields)] + struct BalloonsObjectItem { + #[serde(skip_serializing_if = "Option::is_none")] + colour: Option, + #[serde(skip_serializing_if = "Option::is_none")] + diameter: Option, + } + + let metric: ObjectMetric = ObjectMetric::new(CommonMetricData { + name: "object".into(), + category: "test".into(), + send_in_pings: vec!["test1".into()], + ..Default::default() + }); + + let balloons = BalloonsObject::from([ + BalloonsObjectItem { + colour: Some("red".to_string()), + diameter: Some(5), + }, + BalloonsObjectItem { + colour: Some("green".to_string()), + diameter: None, + }, + ]); + metric.set(balloons); + + let data = metric.test_get_value(None).expect("no object recorded"); + let expected = json!([ + { "colour": "red", "diameter": 5 }, + { "colour": "green" }, + ]); + assert_eq!(expected, data); + } + + #[test] + fn set_string_api() { + let _lock = lock_test(); + let _t = new_glean(None, true); + + type SimpleArray = Vec; + + let metric: ObjectMetric = ObjectMetric::new(CommonMetricData { + name: "object".into(), + category: "test".into(), + send_in_pings: vec!["test1".into()], + ..Default::default() + }); + + let arr_str = String::from("[1, 2, 3]"); + metric.set_string(arr_str); + + let data = metric.test_get_value(None).expect("no object recorded"); + let expected = json!([1, 2, 3]); + assert_eq!(expected, data); + } +} diff --git a/third_party/rust/glean/src/private/ping.rs b/third_party/rust/glean/src/private/ping.rs index c9c68a10a2..6c126992bc 100644 --- a/third_party/rust/glean/src/private/ping.rs +++ b/third_party/rust/glean/src/private/ping.rs @@ -33,6 +33,7 @@ impl PingType { include_client_id: bool, send_if_empty: bool, precise_timestamps: bool, + include_info_sections: bool, reason_codes: Vec, ) -> Self { let inner = glean_core::metrics::PingType::new( @@ -40,6 +41,7 @@ impl PingType { include_client_id, send_if_empty, precise_timestamps, + include_info_sections, reason_codes, ); diff --git a/third_party/rust/glean/src/test.rs b/third_party/rust/glean/src/test.rs index cb41b49b66..16d6d05447 100644 --- a/third_party/rust/glean/src/test.rs +++ b/third_party/rust/glean/src/test.rs @@ -22,22 +22,16 @@ use crate::common_test::{lock_test, new_glean, GLOBAL_APPLICATION_ID}; fn send_a_ping() { let _lock = lock_test(); - let (s, r) = crossbeam_channel::bounded::(1); + let (s, r) = crossbeam_channel::bounded::(1); - // Define a fake uploader that reports back the submission URL - // using a crossbeam channel. + // Define a fake uploader that reports back the ping upload request. #[derive(Debug)] pub struct FakeUploader { - sender: crossbeam_channel::Sender, + sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request).unwrap(); net::UploadResult::http_status(200) } } @@ -55,12 +49,54 @@ fn send_a_ping() { // Define a new ping and submit it. const PING_NAME: &str = "test-ping"; - let custom_ping = private::PingType::new(PING_NAME, true, true, true, vec![]); + let custom_ping = private::PingType::new(PING_NAME, true, true, true, true, vec![]); custom_ping.submit(None); // Wait for the ping to arrive. - let url = r.recv().unwrap(); - assert!(url.contains(PING_NAME)); + let upload_request = r.recv().unwrap(); + assert!(upload_request.body_has_info_sections); + assert_eq!(upload_request.ping_name, PING_NAME); + assert!(upload_request.url.contains(PING_NAME)); +} + +#[test] +fn send_a_ping_without_info_sections() { + let _lock = lock_test(); + + let (s, r) = crossbeam_channel::bounded::(1); + + // Define a fake uploader that reports back the ping upload request. + #[derive(Debug)] + pub struct FakeUploader { + sender: crossbeam_channel::Sender, + } + impl net::PingUploader for FakeUploader { + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request).unwrap(); + net::UploadResult::http_status(200) + } + } + + // Create a custom configuration to use a fake uploader. + let dir = tempfile::tempdir().unwrap(); + let tmpname = dir.path().to_path_buf(); + + let cfg = ConfigurationBuilder::new(true, tmpname, GLOBAL_APPLICATION_ID) + .with_server_endpoint("invalid-test-host") + .with_uploader(FakeUploader { sender: s }) + .build(); + + let _t = new_glean(Some(cfg), true); + + // Define a new ping and submit it. + const PING_NAME: &str = "noinfo-ping"; + let custom_ping = private::PingType::new(PING_NAME, true, true, true, false, vec![]); + custom_ping.submit(None); + + // Wait for the ping to arrive. + let upload_request = r.recv().unwrap(); + assert!(!upload_request.body_has_info_sections); + assert_eq!(upload_request.ping_name, PING_NAME); } #[test] @@ -190,13 +226,8 @@ fn sending_of_foreground_background_pings() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -263,13 +294,8 @@ fn sending_of_startup_baseline_ping() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -315,13 +341,8 @@ fn no_dirty_baseline_on_clean_shutdowns() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -543,12 +564,8 @@ fn ping_collection_must_happen_after_concurrently_scheduled_metrics_recordings() sender: crossbeam_channel::Sender<(String, JsonValue)>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + let net::PingUploadRequest { body, url, .. } = upload_request; // Decode the gzipped body. let mut gzip_decoder = GzDecoder::new(&body[..]); let mut s = String::with_capacity(body.len()); @@ -577,7 +594,7 @@ fn ping_collection_must_happen_after_concurrently_scheduled_metrics_recordings() ); let ping_name = "custom_ping_1"; - let ping = private::PingType::new(ping_name, true, false, true, vec![]); + let ping = private::PingType::new(ping_name, true, false, true, true, vec![]); let metric = private::StringMetric::new(CommonMetricData { name: "string_metric".into(), category: "telemetry".into(), @@ -681,13 +698,8 @@ fn sending_deletion_ping_if_disabled_outside_of_run() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -731,13 +743,8 @@ fn no_sending_of_deletion_ping_if_unchanged_outside_of_run() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -779,12 +786,8 @@ fn deletion_request_ping_contains_experimentation_id() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - _url: String, - body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + let body = upload_request.body; let mut gzip_decoder = GzDecoder::new(&body[..]); let mut body_str = String::with_capacity(body.len()); let data: JsonValue = gzip_decoder @@ -847,12 +850,8 @@ fn test_sending_of_startup_baseline_ping_with_application_lifetime_metric() { sender: crossbeam_channel::Sender<(String, JsonValue)>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + let net::PingUploadRequest { url, body, .. } = upload_request; // Decode the gzipped body. let mut gzip_decoder = GzDecoder::new(&body[..]); let mut s = String::with_capacity(body.len()); @@ -932,13 +931,8 @@ fn setting_debug_view_tag_before_initialization_should_not_crash() { sender: crossbeam_channel::Sender>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - _url: String, - _body: Vec, - headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(headers).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.headers).unwrap(); net::UploadResult::http_status(200) } } @@ -983,13 +977,8 @@ fn setting_source_tags_before_initialization_should_not_crash() { sender: crossbeam_channel::Sender>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - _url: String, - _body: Vec, - headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(headers).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.headers).unwrap(); net::UploadResult::http_status(200) } } @@ -1033,13 +1022,8 @@ fn setting_source_tags_after_initialization_should_not_crash() { sender: crossbeam_channel::Sender>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - _url: String, - _body: Vec, - headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(headers).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.headers).unwrap(); net::UploadResult::http_status(200) } } @@ -1097,13 +1081,8 @@ fn flipping_upload_enabled_respects_order_of_events() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -1118,7 +1097,7 @@ fn flipping_upload_enabled_respects_order_of_events() { .build(); // We create a ping and a metric before we initialize Glean - let sample_ping = PingType::new("sample-ping-1", true, false, true, vec![]); + let sample_ping = PingType::new("sample-ping-1", true, false, true, true, vec![]); let metric = private::StringMetric::new(CommonMetricData { name: "string_metric".into(), category: "telemetry".into(), @@ -1155,19 +1134,14 @@ fn registering_pings_before_init_must_work() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } // Create a custom ping and attempt its registration. - let sample_ping = PingType::new("pre-register", true, true, true, vec![]); + let sample_ping = PingType::new("pre-register", true, true, true, true, vec![]); // Create a custom configuration to use a fake uploader. let dir = tempfile::tempdir().unwrap(); @@ -1201,13 +1175,8 @@ fn test_a_ping_before_submission() { sender: crossbeam_channel::Sender, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { - self.sender.send(url).unwrap(); + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -1224,7 +1193,7 @@ fn test_a_ping_before_submission() { let _t = new_glean(Some(cfg), true); // Create a custom ping and register it. - let sample_ping = PingType::new("custom1", true, true, true, vec![]); + let sample_ping = PingType::new("custom1", true, true, true, true, vec![]); let metric = CounterMetric::new(CommonMetricData { name: "counter_metric".into(), @@ -1308,12 +1277,7 @@ fn signaling_done() { counter: Arc>>, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - _url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { + fn upload(&self, _upload_request: net::PingUploadRequest) -> net::UploadResult { let mut map = self.counter.lock().unwrap(); *map.entry(thread::current().id()).or_insert(0) += 1; @@ -1346,7 +1310,7 @@ fn signaling_done() { // Define a new ping and submit it. const PING_NAME: &str = "test-ping"; - let custom_ping = private::PingType::new(PING_NAME, true, true, true, vec![]); + let custom_ping = private::PingType::new(PING_NAME, true, true, true, true, vec![]); custom_ping.submit(None); custom_ping.submit(None); @@ -1385,17 +1349,12 @@ fn configure_ping_throttling() { done: Arc, } impl net::PingUploader for FakeUploader { - fn upload( - &self, - url: String, - _body: Vec, - _headers: Vec<(String, String)>, - ) -> net::UploadResult { + fn upload(&self, upload_request: net::PingUploadRequest) -> net::UploadResult { if self.done.load(std::sync::atomic::Ordering::SeqCst) { // If we've outlived the test, just lie. return net::UploadResult::http_status(200); } - self.sender.send(url).unwrap(); + self.sender.send(upload_request.url).unwrap(); net::UploadResult::http_status(200) } } @@ -1422,7 +1381,7 @@ fn configure_ping_throttling() { // Define a new ping. const PING_NAME: &str = "test-ping"; - let custom_ping = private::PingType::new(PING_NAME, true, true, true, vec![]); + let custom_ping = private::PingType::new(PING_NAME, true, true, true, true, vec![]); // Submit and receive it `pings_per_interval` times. for _ in 0..pings_per_interval { -- cgit v1.2.3