mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1150921 - Add telemetry for response codes to SafeBrowsing requests. r=francois f=bsmedberg
This commit is contained in:
parent
9e123c0366
commit
538efc0f46
@ -3231,6 +3231,22 @@
|
||||
"kind": "boolean",
|
||||
"description": "Did UrlClassifier fail to construct the PrefixSet?"
|
||||
},
|
||||
"URLCLASSIFIER_UPDATE_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 SafeBrowsing database updates. (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_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)"
|
||||
},
|
||||
"PLACES_PAGES_COUNT": {
|
||||
"expires_in_version": "never",
|
||||
"kind": "exponential",
|
||||
|
@ -47,6 +47,115 @@ function log(...stuff) {
|
||||
dump(msg + "\n");
|
||||
}
|
||||
|
||||
// Map the HTTP response code to a Telemetry bucket
|
||||
// https://developers.google.com/safe-browsing/developers_guide_v2?hl=en
|
||||
function httpStatusToBucket(httpStatus) {
|
||||
var statusBucket;
|
||||
switch (httpStatus) {
|
||||
case 100:
|
||||
case 101:
|
||||
// Unexpected 1xx return code
|
||||
statusBucket = 0;
|
||||
break;
|
||||
case 200:
|
||||
// OK - Data is available in the HTTP response body.
|
||||
statusBucket = 1;
|
||||
break;
|
||||
case 201:
|
||||
case 202:
|
||||
case 203:
|
||||
case 205:
|
||||
case 206:
|
||||
// Unexpected 2xx return code
|
||||
statusBucket = 2;
|
||||
break;
|
||||
case 204:
|
||||
// No Content - There are no full-length hashes with the requested prefix.
|
||||
statusBucket = 3;
|
||||
break;
|
||||
case 300:
|
||||
case 301:
|
||||
case 302:
|
||||
case 303:
|
||||
case 304:
|
||||
case 305:
|
||||
case 307:
|
||||
case 308:
|
||||
// Unexpected 3xx return code
|
||||
statusBucket = 4;
|
||||
break;
|
||||
case 400:
|
||||
// Bad Request - The HTTP request was not correctly formed.
|
||||
// The client did not provide all required CGI parameters.
|
||||
statusBucket = 5;
|
||||
break;
|
||||
case 401:
|
||||
case 402:
|
||||
case 405:
|
||||
case 406:
|
||||
case 407:
|
||||
case 409:
|
||||
case 410:
|
||||
case 411:
|
||||
case 412:
|
||||
case 414:
|
||||
case 415:
|
||||
case 416:
|
||||
case 417:
|
||||
case 421:
|
||||
case 426:
|
||||
case 428:
|
||||
case 429:
|
||||
case 431:
|
||||
case 451:
|
||||
// Unexpected 4xx return code
|
||||
statusBucket = 6;
|
||||
break;
|
||||
case 403:
|
||||
// Forbidden - The client id is invalid.
|
||||
statusBucket = 7;
|
||||
break;
|
||||
case 404:
|
||||
// Not Found
|
||||
statusBucket = 8;
|
||||
break;
|
||||
case 408:
|
||||
// Request Timeout
|
||||
statusBucket = 9;
|
||||
break;
|
||||
case 413:
|
||||
// Request Entity Too Large - Bug 1150334
|
||||
statusBucket = 10;
|
||||
break;
|
||||
case 500:
|
||||
case 501:
|
||||
case 510:
|
||||
// Unexpected 5xx return code
|
||||
statusBucket = 11;
|
||||
break;
|
||||
case 502:
|
||||
case 504:
|
||||
case 511:
|
||||
// Local network errors, we'll ignore these.
|
||||
statusBucket = 12;
|
||||
break;
|
||||
case 503:
|
||||
// Service Unavailable - The server cannot handle the request.
|
||||
// Clients MUST follow the backoff behavior specified in the
|
||||
// Request Frequency section.
|
||||
statusBucket = 13;
|
||||
break;
|
||||
case 505:
|
||||
// HTTP Version Not Supported - The server CANNOT handle the requested
|
||||
// protocol major version.
|
||||
statusBucket = 14;
|
||||
break;
|
||||
default:
|
||||
statusBucket = 15;
|
||||
};
|
||||
return statusBucket;
|
||||
}
|
||||
|
||||
function HashCompleter() {
|
||||
// The current HashCompleterRequest in flight. Once it is started, it is set
|
||||
// to null. It may be used by multiple calls to |complete| in succession to
|
||||
@ -435,6 +544,10 @@ HashCompleterRequest.prototype = {
|
||||
}
|
||||
log('Received a ' + httpStatus + ' status code from the gethash server.');
|
||||
|
||||
let histogram =
|
||||
Services.telemetry.getHistogramById("URLCLASSIFIER_COMPLETE_REMOTE_STATUS");
|
||||
histogram.add(httpStatusToBucket(httpStatus));
|
||||
|
||||
let success = Components.isSuccessCode(aStatusCode);
|
||||
// Notify the RequestBackoff once a response is received.
|
||||
this._completer.finishRequest(this.gethashUrl, httpStatus);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "mozilla/Logging.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "mozilla/LoadContext.h"
|
||||
#include "mozilla/Telemetry.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
static const char* gQuitApplicationMessage = "quit-application";
|
||||
@ -444,6 +445,114 @@ nsUrlClassifierStreamUpdater::AddRequestBody(const nsACString &aRequestBody)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Map the HTTP response code to a Telemetry bucket
|
||||
static uint32_t HTTPStatusToBucket(uint32_t status)
|
||||
{
|
||||
uint32_t statusBucket;
|
||||
switch (status) {
|
||||
case 100:
|
||||
case 101:
|
||||
// Unexpected 1xx return code
|
||||
statusBucket = 0;
|
||||
break;
|
||||
case 200:
|
||||
// OK - Data is available in the HTTP response body.
|
||||
statusBucket = 1;
|
||||
break;
|
||||
case 201:
|
||||
case 202:
|
||||
case 203:
|
||||
case 205:
|
||||
case 206:
|
||||
// Unexpected 2xx return code
|
||||
statusBucket = 2;
|
||||
break;
|
||||
case 204:
|
||||
// No Content
|
||||
statusBucket = 3;
|
||||
break;
|
||||
case 300:
|
||||
case 301:
|
||||
case 302:
|
||||
case 303:
|
||||
case 304:
|
||||
case 305:
|
||||
case 307:
|
||||
case 308:
|
||||
// Unexpected 3xx return code
|
||||
statusBucket = 4;
|
||||
break;
|
||||
case 400:
|
||||
// Bad Request - The HTTP request was not correctly formed.
|
||||
// The client did not provide all required CGI parameters.
|
||||
statusBucket = 5;
|
||||
break;
|
||||
case 401:
|
||||
case 402:
|
||||
case 405:
|
||||
case 406:
|
||||
case 407:
|
||||
case 409:
|
||||
case 410:
|
||||
case 411:
|
||||
case 412:
|
||||
case 414:
|
||||
case 415:
|
||||
case 416:
|
||||
case 417:
|
||||
case 421:
|
||||
case 426:
|
||||
case 428:
|
||||
case 429:
|
||||
case 431:
|
||||
case 451:
|
||||
// Unexpected 4xx return code
|
||||
statusBucket = 6;
|
||||
break;
|
||||
case 403:
|
||||
// Forbidden - The client id is invalid.
|
||||
statusBucket = 7;
|
||||
break;
|
||||
case 404:
|
||||
// Not Found
|
||||
statusBucket = 8;
|
||||
break;
|
||||
case 408:
|
||||
// Request Timeout
|
||||
statusBucket = 9;
|
||||
break;
|
||||
case 413:
|
||||
// Request Entity Too Large - Bug 1150334
|
||||
statusBucket = 10;
|
||||
break;
|
||||
case 500:
|
||||
case 501:
|
||||
case 510:
|
||||
// Unexpected 5xx return code
|
||||
statusBucket = 11;
|
||||
break;
|
||||
case 502:
|
||||
case 504:
|
||||
case 511:
|
||||
// Local network errors, we'll ignore these.
|
||||
statusBucket = 12;
|
||||
break;
|
||||
case 503:
|
||||
// Service Unavailable - The server cannot handle the request.
|
||||
// Clients MUST follow the backoff behavior specified in the
|
||||
// Request Frequency section.
|
||||
statusBucket = 13;
|
||||
break;
|
||||
case 505:
|
||||
// HTTP Version Not Supported - The server CANNOT handle the requested
|
||||
// protocol major version.
|
||||
statusBucket = 14;
|
||||
break;
|
||||
default:
|
||||
statusBucket = 15;
|
||||
};
|
||||
return statusBucket;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListenerObserver implementation
|
||||
@ -479,6 +588,9 @@ nsUrlClassifierStreamUpdater::OnStartRequest(nsIRequest *request,
|
||||
if (NS_FAILED(status)) {
|
||||
// Assume we're overloading the server and trigger backoff.
|
||||
downloadError = true;
|
||||
mozilla::Telemetry::Accumulate(mozilla::Telemetry::URLCLASSIFIER_UPDATE_REMOTE_STATUS,
|
||||
15 /* unknown response code */);
|
||||
|
||||
} else {
|
||||
bool succeeded = false;
|
||||
rv = httpChannel->GetRequestSucceeded(&succeeded);
|
||||
@ -487,6 +599,8 @@ nsUrlClassifierStreamUpdater::OnStartRequest(nsIRequest *request,
|
||||
uint32_t requestStatus;
|
||||
rv = httpChannel->GetResponseStatus(&requestStatus);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mozilla::Telemetry::Accumulate(mozilla::Telemetry::URLCLASSIFIER_UPDATE_REMOTE_STATUS,
|
||||
HTTPStatusToBucket(requestStatus));
|
||||
LOG(("nsUrlClassifierStreamUpdater::OnStartRequest %s (%d)", succeeded ?
|
||||
"succeeded" : "failed", requestStatus));
|
||||
if (!succeeded) {
|
||||
|
Loading…
Reference in New Issue
Block a user