Bug 1480826 - Reenable telemetry.os_shutting_down probe. r=chutten, a=RyanVM
authorAdam Gashlin <agashlin@mozilla.com>
Fri, 03 Aug 2018 10:48:01 -0700
changeset 473822 e6b8ec3c45a4
parent 473821 dad476171a76
child 473823 1b3c76905dab
push id1751
push userryanvm@gmail.com
push date2018-08-07 17:02 +0000
treeherdermozilla-release@975058795980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten, RyanVM
bugs1480826
milestone61.0.2
Bug 1480826 - Reenable telemetry.os_shutting_down probe. r=chutten, a=RyanVM This records whether the shutdown ping was generated during an OS shutdown.
toolkit/components/telemetry/Scalars.yaml
toolkit/components/telemetry/TelemetrySend.jsm
toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -1189,16 +1189,31 @@ telemetry:
     keyed: true
     notification_emails:
       - telemetry-client-dev@mozilla.com
       - chutten@mozilla.com
     release_channel_collection: opt-out
     record_in_processes:
       - 'all'
 
+  os_shutting_down:
+    bug_numbers:
+      - 1480826
+    description: >
+      Records true if there is a signal that Firefox was quitting because
+      the OS was shutting down. Only available on Windows.
+    expires: "64"
+    kind: boolean
+    notification_emails:
+      - telemetry-client-dev@mozilla.com
+      - agashlin@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
 telemetry.discarded:
   accumulations:
     bug_numbers:
       - 1369041
     description: >
       Number of discarded accumulations to histograms in child processes
     expires: "never"
     kind: uint
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -814,16 +814,17 @@ var TelemetrySendImpl = {
 
     return this.promisePendingPingActivity();
   },
 
   observe(subject, topic, data) {
     let setOSShutdown = () => {
       this._log.trace("setOSShutdown - in OS shutdown");
       this._isOSShutdown = true;
+      Telemetry.scalarSet("telemetry.os_shutting_down", true);
     };
 
     switch (topic) {
     case TOPIC_IDLE_DAILY:
       SendScheduler.triggerSendingPings(true);
       break;
     case TOPIC_QUIT_APPLICATION_FORCED:
       setOSShutdown();
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySession.js
@@ -1375,25 +1375,29 @@ add_task(async function test_sendShutdow
       (AppConstants.platform == "linux" && OS.Constants.Sys.bits == 32)) {
     // We don't support the pingsender on Android, yet, see bug 1335917.
     // We also don't suppor the pingsender testing on Treeherder for
     // Linux 32 bit (due to missing libraries). So skip it there too.
     // See bug 1310703 comment 78.
     return;
   }
 
+  const OSSHUTDOWN_SCALAR = "telemetry.os_shutting_down";
+
   let checkPendingShutdownPing = async function() {
     let pendingPings = await TelemetryStorage.loadPendingPingList();
     Assert.equal(pendingPings.length, 1,
                  "We expect 1 pending ping: shutdown.");
     // Load the pings off the disk.
     const shutdownPing = await TelemetryStorage.loadPendingPing(pendingPings[0].id);
     Assert.ok(shutdownPing, "The 'shutdown' ping must be saved to disk.");
     Assert.equal("shutdown", shutdownPing.payload.info.reason,
                  "The 'shutdown' ping must be saved to disk.");
+    Assert.ok(shutdownPing.payload.processes.parent.scalars[OSSHUTDOWN_SCALAR],
+              "The OS shutdown scalar must be set to true.");
   };
 
   Preferences.set(TelemetryUtils.Preferences.ShutdownPingSender, true);
   Preferences.set(TelemetryUtils.Preferences.FirstRun, false);
   // Make sure the reporting policy picks up the updated pref.
   TelemetryReportingPolicy.testUpdateFirstRun();
   PingServer.clearRequests();
   Telemetry.clearScalars();
@@ -1402,16 +1406,18 @@ add_task(async function test_sendShutdow
   let nextPing = PingServer.promiseNextPing();
   await TelemetryController.testShutdown();
   let ping = await nextPing;
 
   // Check that we received a shutdown ping.
   checkPingFormat(ping, ping.type, true, true);
   Assert.equal(ping.payload.info.reason, REASON_SHUTDOWN);
   Assert.equal(ping.clientId, gClientID);
+  Assert.ok(!(OSSHUTDOWN_SCALAR in ping.payload.processes.parent.scalars),
+            "The OS shutdown scalar must not be set.");
   // Try again, this time disable ping upload. The PingSender
   // should not be sending any ping!
   PingServer.registerPingHandler(() => Assert.ok(false, "Telemetry must not send pings if not allowed to."));
   Preferences.set(TelemetryUtils.Preferences.FhrUploadEnabled, false);
   await TelemetryController.testReset();
   await TelemetryController.testShutdown();
 
   // Make sure we have no pending pings between the runs.