Bug 1233298 - Remove query params from the `FXA_HAWK_ERRORS` probe. r?markh draft
authorKit Cambridge <kcambridge@mozilla.com>
Thu, 14 Jan 2016 14:32:46 -0700
changeset 324112 b6d95f606cd6a15e1ed95a55449ad964b3312aaa
parent 323987 66e07ef46853709e3fa91e7c9ad9fe6abf0d5f06
child 513330 80b6838b5e5bf1a8a8a93de50ce230dfb48046a3
push id9851
push userkcambridge@mozilla.com
push dateFri, 22 Jan 2016 00:11:04 +0000
reviewersmarkh
bugs1233298
milestone46.0a1
Bug 1233298 - Remove query params from the `FXA_HAWK_ERRORS` probe. r?markh
services/fxaccounts/FxAccountsClient.jsm
services/fxaccounts/tests/xpcshell/test_client.js
--- a/services/fxaccounts/FxAccountsClient.jsm
+++ b/services/fxaccounts/FxAccountsClient.jsm
@@ -515,18 +515,20 @@ this.FxAccountsClient.prototype = {
           CommonUtils.namedTimer(
             this._clearBackoff,
             error.retryAfter * 1000,
             this,
             "fxaBackoffTimer"
            );
         }
         if (isInvalidTokenError(error)) {
+          // Use the endpoint path as the key, ignoring query params and
+          // fragments.
           Services.telemetry.getKeyedHistogramById(
-            "FXA_HAWK_ERRORS").add(path);
+            "FXA_HAWK_ERRORS").add(path.replace(/[?#].*/, ''));
         }
         deferred.reject(error);
       }
     );
 
     return deferred.promise;
   },
 };
--- a/services/fxaccounts/tests/xpcshell/test_client.js
+++ b/services/fxaccounts/tests/xpcshell/test_client.js
@@ -813,17 +813,19 @@ add_task(function* test_client_metrics()
           errno: 111,
         });
       },
     }
   );
 
   let client = new FxAccountsClient(server.baseURI);
 
-  yield rejects(client.signOut(FAKE_SESSION_TOKEN), function(err) {
+  yield rejects(client.signOut(FAKE_SESSION_TOKEN, {
+    service: "sync",
+  }), function(err) {
     return err.errno == 111;
   });
 
   let histogram = Services.telemetry.getKeyedHistogramById("FXA_HAWK_ERRORS");
   let snapshot = histogram.snapshot("/session/destroy");
   do_check_eq(snapshot.sum, 1, "Should report Hawk authentication errors");
   histogram.clear();