Bug 983313 - Write crash events for plugin crashes and hangs (part 2: FHR). r=bsmedberg,rnewman

This commit is contained in:
Drew Willcoxon 2014-05-12 12:00:11 -07:00
Родитель f1907fd96d
Коммит 68d4a56ef9
3 изменённых файлов: 80 добавлений и 18 удалений

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

@ -1073,6 +1073,23 @@ 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
^^^^^^^^^

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

@ -1021,6 +1021,26 @@ DailyCrashesMeasurement2.prototype = Object.freeze({
},
});
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);
@ -1036,6 +1056,7 @@ CrashesProvider.prototype = Object.freeze({
measurementTypes: [
DailyCrashesMeasurement1,
DailyCrashesMeasurement2,
DailyCrashesMeasurement3,
],
pullOnly: true,
@ -1047,11 +1068,9 @@ CrashesProvider.prototype = Object.freeze({
_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);
@ -1061,7 +1080,7 @@ CrashesProvider.prototype = Object.freeze({
continue;
}
yield m.setDailyLastNumeric(fields[type], count, date);
yield m.setDailyLastNumeric(type, count, date);
}
}
},

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

@ -47,36 +47,62 @@ add_task(function* test_collect() {
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();