Bug 1617133 - Report error names to Telemetry on Nightly r=glasserc

Differential Revision: https://phabricator.services.mozilla.com/D64560

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mathieu Leplatre 2020-03-02 15:04:33 +00:00
Родитель acd66bc75c
Коммит 9448fcafc5
3 изменённых файлов: 65 добавлений и 2 удалений

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

@ -6,6 +6,9 @@
var EXPORTED_SYMBOLS = ["RemoteSettingsClient"];
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
@ -429,6 +432,7 @@ class RemoteSettingsClient extends EventEmitter {
let importedFromDump = [];
const startedAt = new Date();
let reportStatus = null;
let thrownError = null;
try {
// If network is offline, we can't synchronize.
if (Utils.isOffline) {
@ -626,6 +630,7 @@ class RemoteSettingsClient extends EventEmitter {
);
}
} catch (e) {
thrownError = e;
// If no Telemetry status was determined yet (ie. outside sync step),
// then introspect error, default status at this step is UNKNOWN.
if (reportStatus == null) {
@ -641,11 +646,34 @@ class RemoteSettingsClient extends EventEmitter {
reportStatus = UptakeTelemetry.STATUS.SUCCESS;
}
// Report success/error status to Telemetry.
await UptakeTelemetry.report(TELEMETRY_COMPONENT, reportStatus, {
let reportArgs = {
source: this.identifier,
trigger,
duration: durationMilliseconds,
});
};
// In Bug 1617133, we will try to break down specific errors into
// more precise statuses by reporting the JavaScript error name
// ("TypeError", etc.) to Telemetry on Nightly.
if (
thrownError !== null &&
AppConstants.NIGHTLY_BUILD &&
[
UptakeTelemetry.STATUS.SYNC_ERROR,
UptakeTelemetry.STATUS.CUSTOM_1_ERROR, // IndexedDB.
UptakeTelemetry.STATUS.UNKNOWN_ERROR,
].includes(reportStatus)
) {
// List of possible error names for IndexedDB:
// https://searchfox.org/mozilla-central/rev/49ed791/dom/base/DOMException.cpp#28-53
reportArgs = { ...reportArgs, errorName: thrownError.name };
}
await UptakeTelemetry.report(
TELEMETRY_COMPONENT,
reportStatus,
reportArgs
);
console.debug(`${this.identifier} sync status is ${reportStatus}`);
this._syncRunning = false;
}

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

@ -729,6 +729,39 @@ add_task(async function test_telemetry_reports_indexeddb_as_custom_1() {
});
add_task(clear_state);
add_task(async function test_telemetry_reports_error_name_as_event_nightly() {
const backup = client.openCollection;
client.openCollection = () => {
const e = new Error("Some unknown error");
e.name = "ThrownError";
throw e;
};
await withFakeChannel("nightly", async () => {
try {
await client.maybeSync(2000);
} catch (e) {}
TelemetryTestUtils.assertEvents([
[
"uptake.remotecontent.result",
"uptake",
"remotesettings",
UptakeTelemetry.STATUS.UNKNOWN_ERROR,
{
source: client.identifier,
trigger: "manual",
duration: v => v >= 0,
errorName: "ThrownError",
},
],
]);
});
client.openCollection = backup;
});
add_task(clear_state);
add_task(async function test_bucketname_changes_when_bucket_pref_changes() {
equal(client.bucketName, "main");

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

@ -1692,6 +1692,8 @@ uptake.remotecontent.result:
The duration of the synchronization process in milliseconds.
timestamp: >
The current timestamp, received during synchronization.
errorName: >
An optional string with the error name attribute in case of failure.
bug_numbers:
- 1517469
products: