Bug 1172688 - Add telemetry for when gethash calls timeout. r=francois, bsmedberg
MozReview-Commit-ID: 8GZmlhgWhmy
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -3351,16 +3351,23 @@
"URLCLASSIFIER_COMPLETE_REMOTE_STATUS": {
"alert_emails": ["gcp@mozilla.com", "francois@mozilla.com"],
"expires_in_version": "never",
"kind": "enumerated",
"n_values": 16,
"bug_numbers": [1150921],
"description": "Server HTTP status code from remote SafeBrowsing gethash lookups. (0=1xx, 1=200, 2=2xx, 3=204, 4=3xx, 5=400, 6=4xx, 7=403, 8=404, 9=408, 10=413, 11=5xx, 12=502|504|511, 13=503, 14=505, 15=Other)"
},
+ "URLCLASSIFIER_COMPLETE_TIMEOUT": {
+ "alert_emails": ["gcp@mozilla.com", "francois@mozilla.com"],
+ "expires_in_version": "52",
+ "kind": "boolean",
+ "bug_numbers": [1172688],
+ "description": "This metric is recorded every time a gethash lookup is performed, `true` is recorded if the lookup times out."
+ },
"CSP_DOCUMENTS_COUNT": {
"alert_emails": ["seceng@mozilla.com"],
"bug_numbers": [1252829],
"expires_in_version": "55",
"kind": "count",
"description": "Number of unique pages that contain a CSP"
},
"CSP_UNSAFE_INLINE_DOCUMENTS_COUNT": {
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -333,16 +333,17 @@ HashCompleterRequest.prototype = {
},
notify: function HCR_notify() {
// If we haven't gotten onStopRequest, just cancel. This will call us
// with onStopRequest since we implement nsIStreamListener on the
// channel.
if (this._channel && this._channel.isPending()) {
dump("hashcompleter: cancelling request to " + this.gethashUrl + "\n");
+ Services.telemetry.getHistogramById("URLCLASSIFIER_COMPLETE_TIMEOUT").add(1);
this._channel.cancel(Cr.NS_BINDING_ABORTED);
}
},
// Creates an nsIChannel for the request and fills the body.
openChannel: function HCR_openChannel() {
let loadFlags = Ci.nsIChannel.INHIBIT_CACHING |
Ci.nsIChannel.LOAD_BYPASS_CACHE;
@@ -543,16 +544,17 @@ HashCompleterRequest.prototype = {
}
}
let success = Components.isSuccessCode(aStatusCode);
log('Received a ' + httpStatus + ' status code from the gethash server (success=' + success + ').');
let histogram =
Services.telemetry.getHistogramById("URLCLASSIFIER_COMPLETE_REMOTE_STATUS");
histogram.add(httpStatusToBucket(httpStatus));
+ Services.telemetry.getHistogramById("URLCLASSIFIER_COMPLETE_TIMEOUT").add(0);
// Notify the RequestBackoff once a response is received.
this._completer.finishRequest(this.gethashUrl, httpStatus);
if (success) {
try {
this.handleResponse();
}