Bug 1422671 - Add telemetry for login reputation service. r?francois datareview?francois
MozReview-Commit-ID: LaWcGww6hJx
--- a/toolkit/components/reputationservice/LoginReputation.cpp
+++ b/toolkit/components/reputationservice/LoginReputation.cpp
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "LoginReputation.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsThreadUtils.h"
#include "mozilla/ErrorNames.h"
#include "mozilla/Logging.h"
#include "mozilla/Preferences.h"
+#include "mozilla/Telemetry.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/ipc/URIUtils.h"
using namespace mozilla;
using namespace mozilla::dom;
#define PREF_PP_ENABLED "browser.safebrowsing.passwords.enabled"
#define PREF_PASSWORD_ALLOW_TABLE "urlclassifier.passwordAllowTable"
@@ -401,43 +402,62 @@ LoginReputationService::QueryLoginWhitel
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_ARG_POINTER(aRequest);
if (gShuttingDown) {
return NS_ERROR_ABORT;
}
+ using namespace mozilla::Telemetry;
+ TimeStamp startTimeMs = TimeStamp::Now();
+
RefPtr<LoginReputationService> self = this;
mLoginWhitelist->QueryLoginWhitelist(aRequest->mParam)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
- [self, aRequest](VerdictType aResolveValue) -> void {
+ [self, aRequest, startTimeMs](VerdictType aResolveValue) -> void {
// Promise is resolved if url is found in google-provided whitelist.
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aResolveValue == nsILoginReputationVerdictType::SAFE);
LR_LOG(("Query login whitelist [request = %p, result = SAFE]",
aRequest));
+ AccumulateDelta_impl<Millisecond>::compute(
+ LOGIN_REPUTATION_LOGIN_WHITELIST_LOOKUP_TIME, startTimeMs);
+
+ Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT,
+ nsILoginReputationVerdictType::SAFE);
+
self->Finish(aRequest, NS_OK, nsILoginReputationVerdictType::SAFE);
},
- [self, aRequest](nsresult rv) -> void {
+ [self, aRequest, startTimeMs](nsresult rv) -> void {
// Promise is rejected if url cannot be found in google-provided whitelist.
// or there is an error.
- if (LR_LOG_ENABLED()) {
- if (NS_FAILED(rv)) {
+ if (NS_FAILED(rv)) {
+ if (LR_LOG_ENABLED()) {
nsAutoCString errorName;
mozilla::GetErrorName(rv, errorName);
LR_LOG(("Error in QueryLoginWhitelist() [request = %p, rv = %s]",
aRequest, errorName.get()));
- } else {
- LR_LOG(("Query login whitelist cannot find the URL [request = %p]",
- aRequest));
}
+
+ // Don't record the lookup time when there is an error, only record the
+ // result here.
+ Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT, 2); // 2 is error
+ } else {
+ AccumulateDelta_impl<Millisecond>::compute(
+ LOGIN_REPUTATION_LOGIN_WHITELIST_LOOKUP_TIME, startTimeMs);
+
+ Accumulate(LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT,
+ nsILoginReputationVerdictType::UNSPECIFIED);
+
+ LR_LOG(("Query login whitelist cannot find the URL [request = %p]",
+ aRequest));
}
// Check trust-based whitelisting if we can't find the url in login whitelist
self->Finish(aRequest, rv, nsILoginReputationVerdictType::UNSPECIFIED);
});
return NS_OK;
}
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7046,16 +7046,37 @@
"LOCALDOMSTORAGE_SESSIONONLY_PRELOAD_BLOCKING_MS": {
"record_in_processes": ["main", "content"],
"expires_in_version": "40",
"kind": "exponential",
"high": 3000,
"n_buckets": 10,
"description": "Time to fetch LocalStorage data before we can expose them as session only data (ms)"
},
+ "LOGIN_REPUTATION_LOGIN_WHITELIST_RESULT": {
+ "record_in_processes": ["main", "content"],
+ "alert_emails": ["dlee@mozilla.com", "safebrowsing-telemetry@mozilla.org"],
+ "expires_in_version": "never",
+ "releaseChannelCollection": "opt-out",
+ "kind": "enumerated",
+ "bug_numbers": [1422671],
+ "n_values": 3,
+ "description": "Login reputation login whitelist result (0=UNSPECIFIED, 1=SAFE, 2=ERROR)"
+ },
+ "LOGIN_REPUTATION_LOGIN_WHITELIST_LOOKUP_TIME": {
+ "record_in_processes": ["main", "content"],
+ "alert_emails": ["dlee@mozilla.com", "safebrowsing-telemetry@mozilla.org"],
+ "expires_in_version": "never",
+ "releaseChannelCollection": "opt-out",
+ "kind": "exponential",
+ "bug_numbers": [1422671],
+ "high": 5000,
+ "n_buckets": 30,
+ "description": "Time spent per login reputation service lookup local whitelist (ms)"
+ },
"RANGE_CHECKSUM_ERRORS": {
"record_in_processes": ["main", "content"],
"alert_emails": ["perf-telemetry-alerts@mozilla.com"],
"expires_in_version": "never",
"kind": "exponential",
"high": 3000,
"n_buckets": 10,
"description": "Number of histograms with range checksum errors"