Bug 1438896 - Add a probe to count Telemetry failures by ping type. r=chutten
authorClément ALLAIN <clement.allain@ymail.com>
Wed, 27 Mar 2019 19:59:06 +0000
changeset 467642 0f5833c5f5f7dd895a8b57d0be645825fa75aba1
parent 467641 d13bf5b0872ca507b911ce85dfe6aac071bb4cde
child 467643 10f14d91c8249c211f301b35cfff85907f8580dc
push id35806
push userrgurzau@mozilla.com
push dateWed, 03 Apr 2019 04:07:39 +0000
treeherdermozilla-central@45808ab18609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1438896
milestone68.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 1438896 - Add a probe to count Telemetry failures by ping type. r=chutten Add a new categorical keyed histogram to count failures type by ping type Differential Revision: https://phabricator.services.mozilla.com/D24945
toolkit/components/telemetry/Histograms.json
toolkit/components/telemetry/app/TelemetrySend.jsm
toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7312,16 +7312,36 @@
       "eRedirect",
       "abort",
       "timeout",
       "eTooLate",
       "eTerminated"
     ],
     "description": "Counts of the different ways sending a Telemetry ping can fail."
   },
+  "TELEMETRY_SEND_FAILURE_TYPE_PER_PING" : {
+    "record_in_processes": ["main"],
+    "alert_emails": ["telemetry-client-dev@mozilla.com", "chutten@mozilla.com"],
+    "bug_numbers": [1438896],
+    "expires_in_version": "never",
+    "kind": "categorical",
+    "keyed": true,
+    "labels": [
+        "eOK",
+        "eRequest",
+        "eUnreachable",
+        "eChannelOpen",
+        "eRedirect",
+        "abort",
+        "timeout",
+        "eTooLate",
+        "eTerminated"
+    ],
+    "description": "Counts of the different ways sending a Telemetry ping can fail per ping type."
+  },
   "TELEMETRY_STRINGIFY" : {
     "record_in_processes": ["main"],
     "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/app/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/app/TelemetrySend.jsm
@@ -78,17 +78,17 @@ 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;
 
 // Strings to map from XHR.errorCode to TELEMETRY_SEND_FAILURE_TYPE.
 // Echoes XMLHttpRequestMainThread's ErrorType enum.
 // Make sure that any additions done to XHR_ERROR_TYPE enum are also mirrored in
-// TELEMETRY_SEND_FAILURE_TYPE's labels.
+// TELEMETRY_SEND_FAILURE_TYPE and TELEMETRY_SEND_FAILURE_TYPE_PER_PING's labels.
 const XHR_ERROR_TYPE = [
   "eOK",
   "eRequest",
   "eUnreachable",
   "eChannelOpen",
   "eRedirect",
   "eTerminated",
 ];
@@ -776,16 +776,22 @@ var TelemetrySendImpl = {
       "TELEMETRY_SUCCESS",
       "TELEMETRY_SEND_SUCCESS",
       "TELEMETRY_SEND_FAILURE",
       "TELEMETRY_SEND_FAILURE_TYPE",
     ];
 
     histograms.forEach(h => Telemetry.getHistogramById(h).clear());
 
+    const keyedHistograms = [
+      "TELEMETRY_SEND_FAILURE_TYPE_PER_PING",
+    ];
+
+    keyedHistograms.forEach(h => Telemetry.getKeyedHistogramById(h).clear());
+
     return SendScheduler.reset();
   },
 
   /**
    * Notify that we can start submitting data to the servers.
    */
   notifyCanUpload() {
     if (!this._sendingEnabled) {
@@ -1087,16 +1093,17 @@ var TelemetrySendImpl = {
       this._log.trace("_doPing - Can't send ping " + ping.id);
       return Promise.resolve();
     }
 
     if (this._tooLateToSend) {
       // Too late to send now. Reject so we pend the ping to send it next time.
       this._log.trace("_doPing - Too late to send ping " + ping.id);
       Telemetry.getHistogramById("TELEMETRY_SEND_FAILURE_TYPE").add("eTooLate");
+      Telemetry.getKeyedHistogramById("TELEMETRY_SEND_FAILURE_TYPE_PER_PING").add(ping.type, "eTooLate");
       return Promise.reject();
     }
 
     this._log.trace("_doPing - server: " + this._server + ", persisted: " + isPersisted +
                     ", id: " + id);
 
     const url = this._buildSubmissionURL(ping);
 
@@ -1153,16 +1160,17 @@ var TelemetrySendImpl = {
           fallbackUrl.protocol = "http:";
           // TODO encrypt payload
           request.open("POST", fallbackUrl, true);
           request.sendInputStream(this.payloadStream);
         }
       }
 
       Telemetry.getHistogramById("TELEMETRY_SEND_FAILURE_TYPE").add(failure);
+      Telemetry.getKeyedHistogramById("TELEMETRY_SEND_FAILURE_TYPE_PER_PING").add(ping.type, failure);
 
       this._log.error("_doPing - error making request to " + url + ": " + failure);
       onRequestFinished(false, event);
     };
     request.onerror = errorhandler;
     request.ontimeout = errorhandler;
     request.onabort = errorhandler;
 
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySend.js
@@ -476,17 +476,18 @@ add_task(async function test_tooLateToSe
   // Triggering a shutdown should persist the pings
   await TelemetrySend.shutdown();
   const pendingPings = TelemetryStorage.getPendingPingList();
   Assert.equal(pendingPings.length, 1, "Should have a pending ping in storage");
   Assert.equal(pendingPings[0].id, id, "Should have pended our test's ping");
 
   Assert.equal(Telemetry.getHistogramById("TELEMETRY_SEND_FAILURE_TYPE").snapshot().values[7], 1,
     "Should have registered the failed attempt to send");
-
+  Assert.equal(Telemetry.getKeyedHistogramById("TELEMETRY_SEND_FAILURE_TYPE_PER_PING").snapshot()[TEST_TYPE].values[7],
+    1, "Should have registered the failed attempt to send TEST_TYPE ping");
   await TelemetryStorage.reset();
   Assert.equal(TelemetrySend.pendingPingCount, 0, "Should clean up after yourself");
 });
 
 // Test that the current, non-persisted pending pings are properly saved on shutdown.
 add_task(async function test_persistCurrentPingsOnShutdown() {
   const TEST_TYPE = "test-persistCurrentPingsOnShutdown";
   const PING_COUNT = 5;