Bug 1338082 - Add telemetry probes to track the positive and negative cache durations in V4. r?francois
MozReview-Commit-ID: 43Nf5bS2Uo
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -4122,16 +4122,34 @@
"URLCLASSIFIER_PREFIX_MATCH": {
"alert_emails": ["safebrowsing-telemetry@mozilla.org"],
"expires_in_version": "58",
"kind": "enumerated",
"n_values": 4,
"bug_numbers": [1298257],
"description": "Classifier prefix matching result (0 = no match, 1 = match only V2, 2 = match only V4, 3 = match both V2 and V4)"
},
+ "URLCLASSIFIER_POSITIVE_CACHE_DURATION": {
+ "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
+ "expires_in_version": "60",
+ "kind": "exponential",
+ "high": 86400000,
+ "n_buckets": 50,
+ "bug_numbers": [1338082],
+ "description": "Positive cache duration (ms) received in fullhash response from any v4 provider"
+ },
+ "URLCLASSIFIER_NEGATIVE_CACHE_DURATION": {
+ "alert_emails": ["safebrowsing-telemetry@mozilla.org"],
+ "expires_in_version": "60",
+ "kind": "exponential",
+ "high": 86400000,
+ "n_buckets": 50,
+ "bug_numbers": [1338082],
+ "description": "Negative cache duration (ms) received in fullhash response from any v4 provider"
+ },
"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/nsUrlClassifierUtils.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierUtils.cpp
@@ -450,29 +450,35 @@ nsUrlClassifierUtils::ParseFindFullHashR
for (auto& m : r.matches()) {
nsCString tableNames;
nsresult rv = ConvertThreatTypeToListNames(m.threat_type(), tableNames);
if (NS_FAILED(rv)) {
hasUnknownThreatType = true;
continue; // Ignore un-convertable threat type.
}
auto& hash = m.threat().hash();
+ auto cacheDuration = DurationToMs(m.cache_duration());
aCallback->OnCompleteHashFound(nsCString(hash.c_str(), hash.length()),
- tableNames,
- DurationToMs(m.cache_duration()));
+ tableNames, cacheDuration);
+
+ Telemetry::Accumulate(Telemetry::URLCLASSIFIER_POSITIVE_CACHE_DURATION,
+ cacheDuration);
}
auto minWaitDuration = DurationToMs(r.minimum_wait_duration());
auto negCacheDuration = DurationToMs(r.negative_cache_duration());
aCallback->OnResponseParsed(minWaitDuration, negCacheDuration);
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_COMPLETION_ERROR,
hasUnknownThreatType ? UNKNOWN_THREAT_TYPE : SUCCESS);
+ Telemetry::Accumulate(Telemetry::URLCLASSIFIER_NEGATIVE_CACHE_DURATION,
+ negCacheDuration);
+
return NS_OK;
}
//////////////////////////////////////////////////////////
// nsIObserver
NS_IMETHODIMP
nsUrlClassifierUtils::Observe(nsISupports *aSubject, const char *aTopic,