Bug 1366808: Add telemetry probe for about:restartrequired page. r=jimm,chutten
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Tue, 08 May 2018 10:31:59 -0400
changeset 474090 65f5cd4ca5d8776c9d958a44af388c8c1f2ece88
parent 474089 bf0dad1ea2c4891fd0f47f3a20c066259ea08bb7
child 474091 eb036f55167d9369d12c131ae019a1a633986009
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, chutten
bugs1366808
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1366808: Add telemetry probe for about:restartrequired page. r=jimm,chutten
browser/modules/ContentCrashHandlers.jsm
browser/modules/test/browser/browser.ini
browser/modules/test/browser/browser_UsageTelemetry_content_aboutRestartRequired.js
toolkit/components/telemetry/Scalars.yaml
--- a/browser/modules/ContentCrashHandlers.jsm
+++ b/browser/modules/ContentCrashHandlers.jsm
@@ -317,16 +317,22 @@ var TabCrashHandler = {
     let uri = browser.currentURI;
     let gBrowser = browser.ownerGlobal.gBrowser;
     let tab = gBrowser.getTabForBrowser(browser);
     // The restart required page is non-remote by default.
     gBrowser.updateBrowserRemoteness(browser, false);
 
     browser.docShell.displayLoadError(Cr.NS_ERROR_BUILDID_MISMATCH, uri, null);
     tab.setAttribute("crashed", true);
+
+    // Make sure to only count once even if there are multiple windows
+    // that will all show about:restartrequired.
+    if (this._crashedTabCount == 1) {
+      Services.telemetry.scalarAdd("dom.contentprocess.buildID_mismatch", 1);
+    }
   },
 
   /**
    * We show a special page to users when a normal browser tab has crashed.
    * This method should be called to send a browser to that page once the
    * process has completely closed.
    *
    * @param browser (<xul:browser>)
--- a/browser/modules/test/browser/browser.ini
+++ b/browser/modules/test/browser/browser.ini
@@ -45,8 +45,9 @@ support-files =
   usageTelemetrySearchSuggestions.sjs
   usageTelemetrySearchSuggestions.xml
 [browser_UsageTelemetry_searchbar.js]
 support-files =
   usageTelemetrySearchSuggestions.sjs
   usageTelemetrySearchSuggestions.xml
 [browser_UsageTelemetry_content.js]
 [browser_UsageTelemetry_content_aboutHome.js]
+[browser_UsageTelemetry_content_aboutRestartRequired.js]
new file mode 100644
--- /dev/null
+++ b/browser/modules/test/browser/browser_UsageTelemetry_content_aboutRestartRequired.js
@@ -0,0 +1,30 @@
+"use strict";
+
+const SCALAR_BUILDID_MISMATCH = "dom.contentprocess.buildID_mismatch";
+
+add_task(async function test_aboutRestartRequired() {
+  let CrashHandlers = {};
+  ChromeUtils.import("resource:///modules/ContentCrashHandlers.jsm",
+                     CrashHandlers);
+
+  // Let's reset the counts.
+  Services.telemetry.clearScalars();
+
+  let scalars =
+    getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT);
+
+  // Check preconditions
+  is(scalars[SCALAR_BUILDID_MISMATCH], undefined,
+     "Build ID mismatch count should be undefined");
+
+  // Simulate buildID mismatch
+  CrashHandlers.TabCrashHandler._crashedTabCount = 1;
+  CrashHandlers.TabCrashHandler.sendToRestartRequiredPage(
+    gBrowser.selectedTab.linkedBrowser);
+
+  scalars =
+    getParentProcessScalars(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT);
+
+  is(scalars[SCALAR_BUILDID_MISMATCH], 1,
+     "Build ID mismatch count should be 1.");
+});
--- a/toolkit/components/telemetry/Scalars.yaml
+++ b/toolkit/components/telemetry/Scalars.yaml
@@ -771,16 +771,30 @@ dom.contentprocess:
     kind: uint
     notification_emails:
       - benjamin@smedbergs.us
       - mconley@mozilla.com
     release_channel_collection: opt-in
     record_in_processes:
       - 'main'
 
+  buildID_mismatch:
+    bug_numbers:
+      - 1366808
+    description: >
+      The number of times the about:restartrequired page appeared due to a
+      buildID mismatch between the parent and the content processes.
+    expires: never
+    kind: uint
+    notification_emails:
+      - spohl@mozilla.com
+    release_channel_collection: opt-out
+    record_in_processes:
+      - 'main'
+
 devtools.toolbar.eyedropper:
   opened:
     bug_numbers:
       - 1247985
       - 1352115
     description: Number of times the DevTools Eyedropper has been opened via the inspector toolbar.
     expires: never
     kind: uint