Bug 983313 - Write crash events for plugin crashes and hangs (part 2: FHR). r=bsmedberg,rnewman
authorDrew Willcoxon <adw@mozilla.com>
Mon, 12 May 2014 12:00:11 -0700
changeset 182594 576f07f4690b21e4a192777f915c47081d8aa4ff
parent 182593 a6718c6dcdc919edbb8529a60bf77c9ba704bb22
child 182595 32acf0cd2a166635f070e6f5abaf7ddb1620d0d4
push id6751
push userdwillcoxon@mozilla.com
push dateMon, 12 May 2014 19:01:01 +0000
treeherderfx-team@576f07f4690b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, rnewman
bugs983313
milestone32.0a1
Bug 983313 - Write crash events for plugin crashes and hangs (part 2: FHR). r=bsmedberg,rnewman
services/healthreport/docs/dataformat.rst
services/healthreport/providers.jsm
services/healthreport/tests/xpcshell/test_provider_crashes.js
--- a/services/healthreport/docs/dataformat.rst
+++ b/services/healthreport/docs/dataformat.rst
@@ -1068,16 +1068,33 @@ Example
       ]
     }
 
 org.mozilla.crashes.crashes
 ---------------------------
 
 This measurement contains a historical record of application crashes.
 
+Version 3
+^^^^^^^^^
+
+This version follows up from version 2, building on improvements to
+the :ref:`crashes_crashmanager`.
+
+This measurement will be reported on each day there was a
+crash. Records may contain the following fields, whose values indicate
+the number of crashes or hangs that occurred on the given day:
+
+* main-crash
+* main-hang
+* content-crash
+* content-hang
+* plugin-crash
+* plugin-hang
+
 Version 2
 ^^^^^^^^^
 
 The switch to version 2 coincides with the introduction of the
 :ref:`crashes_crashmanager`, which provides a more robust source of
 crash data.
 
 This measurement will be reported on each day there was a crash. The
--- a/services/healthreport/providers.jsm
+++ b/services/healthreport/providers.jsm
@@ -1016,57 +1016,76 @@ DailyCrashesMeasurement2.prototype = Obj
   name: "crashes",
   version: 2,
 
   fields: {
     mainCrash: DAILY_LAST_NUMERIC_FIELD,
   },
 });
 
+function DailyCrashesMeasurement3() {
+  Metrics.Measurement.call(this);
+}
+
+DailyCrashesMeasurement3.prototype = Object.freeze({
+  __proto__: Metrics.Measurement.prototype,
+
+  name: "crashes",
+  version: 3,
+
+  fields: {
+    "main-crash": DAILY_LAST_NUMERIC_FIELD,
+    "main-hang": DAILY_LAST_NUMERIC_FIELD,
+    "content-crash": DAILY_LAST_NUMERIC_FIELD,
+    "content-hang": DAILY_LAST_NUMERIC_FIELD,
+    "plugin-crash": DAILY_LAST_NUMERIC_FIELD,
+    "plugin-hang": DAILY_LAST_NUMERIC_FIELD,
+  },
+});
+
 this.CrashesProvider = function () {
   Metrics.Provider.call(this);
 
   // So we can unit test.
   this._manager = Services.crashmanager;
 };
 
 CrashesProvider.prototype = Object.freeze({
   __proto__: Metrics.Provider.prototype,
 
   name: "org.mozilla.crashes",
 
   measurementTypes: [
     DailyCrashesMeasurement1,
     DailyCrashesMeasurement2,
+    DailyCrashesMeasurement3,
   ],
 
   pullOnly: true,
 
   collectDailyData: function () {
     return this.storage.enqueueTransaction(this._populateCrashCounts.bind(this));
   },
 
   _populateCrashCounts: function () {
     this._log.info("Grabbing crash counts from crash manager.");
     let crashCounts = yield this._manager.getCrashCountsByDay();
-    let fields = {
-      "main-crash": "mainCrash",
-    };
 
-    let m = this.getMeasurement("crashes", 2);
+    let m = this.getMeasurement("crashes", 3);
+    let fields = DailyCrashesMeasurement3.prototype.fields;
 
     for (let [day, types] of crashCounts) {
       let date = Metrics.daysToDate(day);
       for (let [type, count] of types) {
         if (!(type in fields)) {
           this._log.warn("Unknown crash type encountered: " + type);
           continue;
         }
 
-        yield m.setDailyLastNumeric(fields[type], count, date);
+        yield m.setDailyLastNumeric(type, count, date);
       }
     }
   },
 });
 
 #endif
 
 
--- a/services/healthreport/tests/xpcshell/test_provider_crashes.js
+++ b/services/healthreport/tests/xpcshell/test_provider_crashes.js
@@ -42,43 +42,69 @@ add_task(function* test_collect() {
 
   // Install custom manager so we don't interfere with other tests.
   let manager = yield getManager();
   provider._manager = manager;
 
   let day1 = new Date(2014, 0, 1, 0, 0, 0);
   let day2 = new Date(2014, 0, 3, 0, 0, 0);
 
-  yield manager.addCrash(manager.PROCESS_TYPE_MAIN, manager.CRASH_TYPE_CRASH,
-                         "id1", day1);
-  yield manager.addCrash(manager.PROCESS_TYPE_MAIN, manager.CRASH_TYPE_CRASH,
-                         "id2", day1);
-  yield manager.addCrash(manager.PROCESS_TYPE_MAIN, manager.CRASH_TYPE_CRASH,
-                         "id3", day2);
+  yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
+                         manager.CRASH_TYPE_CRASH,
+                         "mc1", day1);
+  yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
+                         manager.CRASH_TYPE_CRASH,
+                         "mc2", day1);
+  yield manager.addCrash(manager.PROCESS_TYPE_CONTENT,
+                         manager.CRASH_TYPE_HANG,
+                         "ch", day1);
+  yield manager.addCrash(manager.PROCESS_TYPE_PLUGIN,
+                         manager.CRASH_TYPE_CRASH,
+                         "pc", day1);
+
+  yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
+                         manager.CRASH_TYPE_HANG,
+                         "mh", day2);
+  yield manager.addCrash(manager.PROCESS_TYPE_CONTENT,
+                         manager.CRASH_TYPE_CRASH,
+                         "cc", day2);
+  yield manager.addCrash(manager.PROCESS_TYPE_PLUGIN,
+                         manager.CRASH_TYPE_HANG,
+                         "ph", day2);
 
   yield provider.collectDailyData();
 
-  let m = provider.getMeasurement("crashes", 2);
+  let m = provider.getMeasurement("crashes", 3);
   let values = yield m.getValues();
   do_check_eq(values.days.size, 2);
   do_check_true(values.days.hasDay(day1));
   do_check_true(values.days.hasDay(day2));
 
   let value = values.days.getDay(day1);
-  do_check_true(value.has("mainCrash"));
-  do_check_eq(value.get("mainCrash"), 2);
+  do_check_true(value.has("main-crash"));
+  do_check_eq(value.get("main-crash"), 2);
+  do_check_true(value.has("content-hang"));
+  do_check_eq(value.get("content-hang"), 1);
+  do_check_true(value.has("plugin-crash"));
+  do_check_eq(value.get("plugin-crash"), 1);
 
   value = values.days.getDay(day2);
-  do_check_eq(value.get("mainCrash"), 1);
+  do_check_true(value.has("main-hang"));
+  do_check_eq(value.get("main-hang"), 1);
+  do_check_true(value.has("content-crash"));
+  do_check_eq(value.get("content-crash"), 1);
+  do_check_true(value.has("plugin-hang"));
+  do_check_eq(value.get("plugin-hang"), 1);
 
   // Check that adding a new crash increments counter on next collect.
-  yield manager.addCrash(manager.PROCESS_TYPE_MAIN, manager.CRASH_TYPE_CRASH,
-                         "id4", day2);
+  yield manager.addCrash(manager.PROCESS_TYPE_MAIN,
+                         manager.CRASH_TYPE_HANG,
+                         "mc3", day2);
 
   yield provider.collectDailyData();
   values = yield m.getValues();
   value = values.days.getDay(day2);
-  do_check_eq(value.get("mainCrash"), 2);
+  do_check_eq(value.get("main-hang"), 2);
 
   yield provider.shutdown();
   yield storage.close();
 });