bug 1367110 - Collect Telemetry for different TelemetrySend failures r=Dexter data-r=bsmedberg
Expires in 61 for now until we can show its usefulness.
MozReview-Commit-ID: IpfEnmnuKgr
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7255,16 +7255,33 @@
"alert_emails": ["telemetry-client-dev@mozilla.com"],
"bug_numbers": [1318284],
"expires_in_version": "never",
"kind": "exponential",
"high": 120000,
"n_buckets": 20,
"description": "Time needed (in ms) for a failed send of a Telemetry ping to the servers and getting a reply back."
},
+ "TELEMETRY_SEND_FAILURE_TYPE" : {
+ "record_in_processes": ["main"],
+ "alert_emails": ["telemetry-client-dev@mozilla.com"],
+ "bug_numbers": [1367110],
+ "expires_in_version": "61",
+ "kind": "categorical",
+ "labels": [
+ "eOK",
+ "eRequest",
+ "eUnreachable",
+ "eChannelOpen",
+ "eRedirect",
+ "abort",
+ "timeout"
+ ],
+ "description": "Counts of the different ways sending a Telemetry ping can fail."
+ },
"TELEMETRY_STRINGIFY" : {
"record_in_processes": ["main", "content"],
"alert_emails": ["telemetry-client-dev@mozilla.com"],
"expires_in_version": "never",
"kind": "exponential",
"high": 3000,
"n_buckets": 10,
"description": "Time to stringify telemetry object (ms)"
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -87,16 +87,26 @@ const SEND_TICK_DELAY = 1 * MS_IN_A_MINU
// for the next ping sends. We increase the delay exponentially up to a limit of
// SEND_MAXIMUM_BACKOFF_DELAY_MS.
// This exponential backoff will be reset by external ping submissions & idle-daily.
const SEND_MAXIMUM_BACKOFF_DELAY_MS = 120 * MS_IN_A_MINUTE;
// The age of a pending ping to be considered overdue (in milliseconds).
const OVERDUE_PING_FILE_AGE = 7 * 24 * 60 * MS_IN_A_MINUTE; // 1 week
+// Strings to map from XHR.errorCode to TELEMETRY_SEND_FAILURE_TYPE.
+// Echoes XMLHttpRequestMainThread's ErrorType enum.
+const XHR_ERROR_TYPE = [
+ "eOK",
+ "eRequest",
+ "eUnreachable",
+ "eChannelOpen",
+ "eRedirect",
+];
+
function monotonicNow() {
try {
return Telemetry.msSinceProcessStart();
} catch (ex) {
// If this fails fall back to the (non-monotonic) Date value.
return Date.now();
}
}
@@ -1102,17 +1112,23 @@ var TelemetrySendImpl = {
.then(() => onCompletion(),
(error) => {
this._log.error("_doPing - request success: " + success + ", error: " + error);
onCompletion();
});
};
let errorhandler = (event) => {
- this._log.error("_doPing - error making request to " + url + ": " + event.type);
+ let failure = event.type;
+ if (failure === "error") {
+ failure = XHR_ERROR_TYPE[request.errorCode];
+ }
+ Telemetry.getHistogramById("TELEMETRY_SEND_FAILURE_TYPE").add(failure);
+
+ this._log.error("_doPing - error making request to " + url + ": " + failure);
onRequestFinished(false, event);
};
request.onerror = errorhandler;
request.ontimeout = errorhandler;
request.onabort = errorhandler;
request.onload = (event) => {
let status = request.status;