bug 1367110 - Collect Telemetry for different TelemetrySend failures r=bsmedberg,Dexter data-r=bsmedberg
authorChris H-C <chutten@mozilla.com>
Wed, 24 May 2017 10:14:41 -0400
changeset 412102 91a308b8cbbe6487ae10b980bd8d4ccca2dd003f
parent 412101 35d360dce251045e0a9b719fca742772641bbd1b
child 412103 4b82f58570e4b0763de9cdf088344fdf5d24e8fd
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, Dexter
bugs1367110
milestone55.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 1367110 - Collect Telemetry for different TelemetrySend failures r=bsmedberg,Dexter data-r=bsmedberg Expires in 61 for now until we can show its usefulness. MozReview-Commit-ID: IpfEnmnuKgr
toolkit/components/telemetry/Histograms.json
toolkit/components/telemetry/TelemetrySend.jsm
--- 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;