Bug 1785251 - Submit a Glean 'pseudo-main' ping when Telemetry submits a 'main' ping r=TravisLong

Differential Revision: https://phabricator.services.mozilla.com/D154922
This commit is contained in:
Chris H-C 2022-08-24 18:29:03 +00:00
Родитель ca2529a562
Коммит e1b70bb8ce
6 изменённых файлов: 119 добавлений и 0 удалений

Просмотреть файл

@ -89,6 +89,9 @@ wr:
- gfx-telemetry-alerts@mozilla.com
expires: never
telemetry_mirror: WR_RENDERER_TIME
send_in_pings:
- metrics
- pseudo-main
renderer_time_no_sc:
type: timing_distribution
description: >

Просмотреть файл

@ -39,6 +39,7 @@ pings_yamls = [
"browser/components/newtab/pings.yaml",
"toolkit/components/glean/pings.yaml",
"toolkit/components/glean/tests/test_pings.yaml",
"toolkit/components/telemetry/pings.yaml",
"toolkit/mozapps/update/pings.yaml",
]

Просмотреть файл

@ -483,6 +483,20 @@ var Impl = {
let pingData = this.assemblePing(aType, aPayload, aOptions);
this._log.trace("submitExternalPing - ping assembled, id: " + pingData.id);
if (aType == PING_TYPE_MAIN) {
try {
Glean.legacyTelemetry.profileSubsessionCounter.set(
aPayload?.info?.profileSubsessionCounter
);
GleanPings.pseudoMain.submit(
aPayload?.info?.reason?.replaceAll("-", "_")
);
} catch (e) {
this._log.warn("submitExternalPing - Failed to send 'pseudo-main'", e);
// Definitely continue, even if things explode.
}
}
if (aOptions.useEncryption === true) {
try {
if (!aOptions.publicKey) {

Просмотреть файл

@ -41,3 +41,25 @@ legacy.telemetry:
- 'events'
- 'newtab'
- 'baseline'
- 'pseudo-main'
profile_subsession_counter:
type: quantity
unit: subsessions
description: |
The `profileSubsessionCounter` from the Legacy Telemetry "main" ping.
This is a value that monotonically increases once for every "main" ping
that has been submitted.
It is a sequence number by a longer name.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1785251
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1785251
data_sensitivity:
- technical
notification_emails:
- chutten@mozilla.com
- glean-team@mozilla.com
expires: 113
send_in_pings:
- 'pseudo-main'

Просмотреть файл

@ -0,0 +1,35 @@
# 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 http://mozilla.org/MPL/2.0/.
---
$schema: moz://mozilla.org/schemas/glean/pings/2-0-0
pseudo-main:
description: |
A ping designed to be submitted on the same schedule as the Legacy
Telemetry "main" ping.
See "main" ping documentation for details.
include_client_id: true
send_if_empty: true
reasons:
shutdown: |
Submitted at shutdown. Likely not uploaded until the following app
session. See "main" ping documentation for details.
environment_change: |
Submitted when something in the "main" ping's Environment changed.
See "main" ping documentation for details.
aborted_session: |
Submitted when the previous session failed to submit a "shutdown"-reason
"main" ping.
See "main" ping documentation for details.
daily: |
Submitted around local midnight.
See "main" ping documentation for details.
bugs:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1785251
data_reviews:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1785251
notification_emails:
- chutten@mozilla.com
- glean-team@mozilla.com

Просмотреть файл

@ -152,6 +152,11 @@ add_task(async function test_setup() {
await new Promise(resolve =>
Telemetry.asyncFetchTelemetryData(wrapWithExceptionHandler(resolve))
);
// On Android FOG is set up through head.js.
if (AppConstants.platform != "android") {
Services.fog.initializeFOG();
}
});
add_task(async function asyncSetup() {
@ -1217,6 +1222,45 @@ add_task(function test_scalar_filtering() {
);
});
add_task(
/* After bug 1752139 we should be able to re-enable this. */
{ skip_if: () => AppConstants.platform == "android" },
function test_pseudo_main() {
const PING_REASON = "test-reason";
const PROFILE_SUBSESSION_COUNTER = 42;
// Step 0: Clear values.
TelemetryController.testReset();
Services.fog.testResetFOG();
// Step 1: Assert no value.
Assert.ok(!Glean.legacyTelemetry.profileSubsessionCounter.testGetValue());
// Step 3: Assert correct value.
let pingSubmitted = false;
GleanPings.pseudoMain.testBeforeNextSubmit(reason => {
pingSubmitted = true;
Assert.equal(reason, PING_REASON.replaceAll("-", "_"));
Assert.equal(
Glean.legacyTelemetry.profileSubsessionCounter.testGetValue(),
PROFILE_SUBSESSION_COUNTER
);
});
// Step 2: Express behaviour.
const payload = {
info: {
reason: PING_REASON,
profileSubsessionCounter: PROFILE_SUBSESSION_COUNTER,
},
};
TelemetryController.submitExternalPing("main", payload, {});
// Step 3a: Assert we actually ran Step 3.
Assert.ok(pingSubmitted, "'pseudo-main' ping was actually submitted");
}
);
add_task(async function stopServer() {
await PingServer.stop();
});