Skip to content

Commit 66ccc33

Browse files
committed
Bug 1882615 - Adapt FOG and JOG to Glean v58 r=perry.mcmanis
Differential Revision: https://phabricator.services.mozilla.com/D203188
1 parent 00548e1 commit 66ccc33

File tree

11 files changed

+52
-13
lines changed

11 files changed

+52
-13
lines changed

toolkit/components/glean/api/src/private/ping.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl Ping {
3030
include_client_id: bool,
3131
send_if_empty: bool,
3232
precise_timestamps: bool,
33+
include_info_sections: bool,
3334
reason_codes: Vec<String>,
3435
) -> Self {
3536
if need_ipc() {
@@ -40,6 +41,7 @@ impl Ping {
4041
include_client_id,
4142
send_if_empty,
4243
precise_timestamps,
44+
include_info_sections,
4345
reason_codes,
4446
))
4547
}
@@ -103,7 +105,7 @@ mod test {
103105

104106
// Smoke test for what should be the generated code.
105107
static PROTOTYPE_PING: Lazy<Ping> =
106-
Lazy::new(|| Ping::new("prototype", false, true, true, vec![]));
108+
Lazy::new(|| Ping::new("prototype", false, true, true, true, vec![]));
107109

108110
#[test]
109111
fn smoke_test_custom_ping() {

toolkit/components/glean/bindings/jog/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ pub extern "C" fn jog_test_register_ping(
138138
include_client_id: bool,
139139
send_if_empty: bool,
140140
precise_timestamps: bool,
141+
include_info_sections: bool,
141142
reason_codes: &ThinVec<nsCString>,
142143
) -> u32 {
143144
let ping_name = name.to_string();
@@ -150,6 +151,7 @@ pub extern "C" fn jog_test_register_ping(
150151
include_client_id,
151152
send_if_empty,
152153
precise_timestamps,
154+
include_info_sections,
153155
reason_codes,
154156
)
155157
.expect("Creation or registration of ping failed.") // permitted to panic in test-only method.
@@ -160,6 +162,7 @@ fn create_and_register_ping(
160162
include_client_id: bool,
161163
send_if_empty: bool,
162164
precise_timestamps: bool,
165+
include_info_sections: bool,
163166
reason_codes: Vec<String>,
164167
) -> Result<u32, Box<dyn std::error::Error>> {
165168
let ns_name = nsCString::from(&ping_name);
@@ -168,6 +171,7 @@ fn create_and_register_ping(
168171
include_client_id,
169172
send_if_empty,
170173
precise_timestamps,
174+
include_info_sections,
171175
reason_codes,
172176
);
173177
extern "C" {
@@ -214,6 +218,7 @@ struct PingDefinitionData {
214218
include_client_id: bool,
215219
send_if_empty: bool,
216220
precise_timestamps: bool,
221+
include_info_sections: bool,
217222
reason_codes: Option<Vec<String>>,
218223
}
219224

@@ -260,6 +265,7 @@ pub extern "C" fn jog_load_jogfile(jogfile_path: &nsAString) -> bool {
260265
ping.include_client_id,
261266
ping.send_if_empty,
262267
ping.precise_timestamps,
268+
ping.include_info_sections,
263269
ping.reason_codes.unwrap_or_else(Vec::new),
264270
);
265271
}

toolkit/components/glean/build_scripts/glean_parser_ext/jog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"include_client_id",
5656
"send_if_empty",
5757
"precise_timestamps",
58+
"include_info_sections",
5859
"reason_codes",
5960
]
6061

toolkit/components/glean/build_scripts/glean_parser_ext/templates/jog_factory.jinja2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ pub fn create_and_register_ping(
137137
include_client_id: bool,
138138
send_if_empty: bool,
139139
precise_timestamps: bool,
140+
include_info_sections: bool,
140141
reason_codes: Vec<String>,
141142
) -> Result<u32, Box<dyn std::error::Error>> {
142143
let ping_id = NEXT_PING_ID.fetch_add(1, Ordering::SeqCst);
143-
let ping = Ping::new(ping_name, include_client_id, send_if_empty, precise_timestamps, reason_codes);
144+
let ping = Ping::new(ping_name, include_client_id, send_if_empty, precise_timestamps, include_info_sections, reason_codes);
144145
assert!(
145146
__jog_metric_maps::PING_MAP.write()?.insert(ping_id.into(), ping).is_none(),
146147
"We should never insert a runtime ping with an already-used id."

toolkit/components/glean/build_scripts/glean_parser_ext/templates/rust_pings.jinja2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub static {{ obj.name|snake_case }}: Lazy<Ping> = Lazy::new(|| {
2020
{{ obj.include_client_id|rust }},
2121
{{ obj.send_if_empty|rust }},
2222
{{ obj.precise_timestamps|rust }},
23+
{{ obj.include_info_sections|rust }},
2324
{{ obj.reason_codes|rust }},
2425
)
2526
});

toolkit/components/glean/src/init/viaduct_uploader.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use glean::net::{PingUploader, UploadResult};
5+
use glean::net::{PingUploadRequest, PingUploader, UploadResult};
66
use url::Url;
77
use viaduct::{Error::*, Request};
88

@@ -19,11 +19,11 @@ impl PingUploader for ViaductUploader {
1919
///
2020
/// # Arguments
2121
///
22-
/// * `url` - the URL path to upload the data to.
23-
/// * `body` - the serialized text data to send.
24-
/// * `headers` - a vector of tuples containing the headers to send with
25-
/// the request, i.e. (Name, Value).
26-
fn upload(&self, url: String, body: Vec<u8>, headers: Vec<(String, String)>) -> UploadResult {
22+
/// * `upload_request` - the ping and its metadata to upload.
23+
fn upload(&self, upload_request: PingUploadRequest) -> UploadResult {
24+
let PingUploadRequest {
25+
url, body, headers, ..
26+
} = upload_request;
2727
log::trace!("FOG Ping Uploader uploading to {}", url);
2828
let url_clone = url.clone();
2929
let result: std::result::Result<UploadResult, viaduct::Error> = (move || {

toolkit/components/glean/tests/pytest/jogfile_output

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@
303303
true,
304304
false,
305305
true,
306+
true,
306307
[
307308
"background",
308309
"dirty_startup",
@@ -314,13 +315,15 @@
314315
true,
315316
true,
316317
true,
318+
true,
317319
[]
318320
],
319321
[
320322
"not-events",
321323
true,
322324
false,
323325
true,
326+
true,
324327
[
325328
"background",
326329
"max_capacity",
@@ -332,6 +335,7 @@
332335
true,
333336
false,
334337
true,
338+
true,
335339
[
336340
"overdue",
337341
"reschedule",

toolkit/components/glean/tests/pytest/pings_test_output

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub static not_baseline: Lazy<Ping> = Lazy::new(|| {
2020
true,
2121
false,
2222
true,
23+
true,
2324
vec!["background".into(), "dirty_startup".into(), "foreground".into()],
2425
)
2526
});
@@ -36,6 +37,7 @@ pub static not_deletion_request: Lazy<Ping> = Lazy::new(|| {
3637
true,
3738
true,
3839
true,
40+
true,
3941
vec![],
4042
)
4143
});
@@ -50,6 +52,7 @@ pub static not_events: Lazy<Ping> = Lazy::new(|| {
5052
true,
5153
false,
5254
true,
55+
true,
5356
vec!["background".into(), "max_capacity".into(), "startup".into()],
5457
)
5558
});
@@ -68,6 +71,7 @@ pub static not_metrics: Lazy<Ping> = Lazy::new(|| {
6871
true,
6972
false,
7073
true,
74+
true,
7175
vec!["overdue".into(), "reschedule".into(), "today".into(), "tomorrow".into(), "upgrade".into()],
7276
)
7377
});

toolkit/components/glean/tests/xpcshell/test_JOG.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ add_task(async function test_jog_custom_pings() {
289289
`"ping"`,
290290
false
291291
);
292-
Services.fog.testRegisterRuntimePing("jog-ping", true, true, true, []);
292+
Services.fog.testRegisterRuntimePing("jog-ping", true, true, true, true, []);
293293
Assert.ok("jogPing" in GleanPings);
294294
let submitted = false;
295295
Glean.jogCat.jogPingBool.set(false);
@@ -642,7 +642,9 @@ add_task(function test_jog_dotted_categories_work() {
642642

643643
add_task(async function test_jog_ping_works() {
644644
const kReason = "reason-1";
645-
Services.fog.testRegisterRuntimePing("my-ping", true, true, true, [kReason]);
645+
Services.fog.testRegisterRuntimePing("my-ping", true, true, true, true, [
646+
kReason,
647+
]);
646648
let submitted = false;
647649
GleanPings.myPing.testBeforeNextSubmit(reason => {
648650
submitted = true;
@@ -652,6 +654,20 @@ add_task(async function test_jog_ping_works() {
652654
Assert.ok(submitted, "Ping must have been submitted");
653655
});
654656

657+
add_task(async function test_jog_noinfo_ping_works() {
658+
const kReason = "reason-1";
659+
Services.fog.testRegisterRuntimePing("noinfo-ping", true, true, true, false, [
660+
kReason,
661+
]);
662+
let submitted = false;
663+
GleanPings.noinfoPing.testBeforeNextSubmit(reason => {
664+
submitted = true;
665+
Assert.equal(kReason, reason);
666+
});
667+
GleanPings.noinfoPing.submit("reason-1");
668+
Assert.ok(submitted, "Ping must have been submitted");
669+
});
670+
655671
add_task(function test_jog_name_collision() {
656672
Assert.ok("aCounter" in Glean.testOnlyJog);
657673
Assert.equal(undefined, Glean.testOnlyJog.aCounter.testGetValue());

toolkit/components/glean/xpcom/FOG.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,13 @@ FOG::TestRegisterRuntimePing(const nsACString& aName,
419419
const bool aIncludeClientId,
420420
const bool aSendIfEmpty,
421421
const bool aPreciseTimestamps,
422+
const bool aIncludeInfoSections,
422423
const nsTArray<nsCString>& aReasonCodes,
423424
uint32_t* aPingIdOut) {
424425
*aPingIdOut = 0;
425-
*aPingIdOut =
426-
glean::jog::jog_test_register_ping(&aName, aIncludeClientId, aSendIfEmpty,
427-
aPreciseTimestamps, &aReasonCodes);
426+
*aPingIdOut = glean::jog::jog_test_register_ping(
427+
&aName, aIncludeClientId, aSendIfEmpty, aPreciseTimestamps,
428+
aIncludeInfoSections, &aReasonCodes);
428429
return NS_OK;
429430
}
430431

toolkit/components/glean/xpcom/nsIFOG.idl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,14 @@ interface nsIFOG : nsISupports
180180
* @param aName - The ping's name.
181181
* @param aIncludeClientId - Whether the ping should include the client_id.
182182
* @param aSendIfEmpty - Whether the ping should send even if empty.
183+
* @param aIncludeInfoSections - Whether the ping should include
184+
* {client|ping}_info sections.
183185
* @param aReasonCodes - The list of valid reasons for ping submission.
184186
*/
185187
uint32_t testRegisterRuntimePing(in ACString aName,
186188
in boolean aIncludeClientId,
187189
in boolean aSendIfEmpty,
188190
in boolean aPreciseTimestamps,
191+
in boolean aIncludeInfoSections,
189192
in Array<ACString> aReasonCodes);
190193
};

0 commit comments

Comments
 (0)