Bug 1322523 - Add telemetry to capture the length of long Safe Browsing V4 prefixes r=francois

MozReview-Commit-ID: F0oTW3Kplxk

--HG--
extra : rebase_source : 6a04d89307c678ff433a599ee50a6b3afe552ec4
This commit is contained in:
Thomas Nguyen 2017-05-08 17:50:51 +08:00
Родитель d6f7dc2900
Коммит f5bf535cd4
2 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -4817,6 +4817,14 @@
"bug_numbers": [1305581],
"description": "Whether or not a variable-length prefix set loaded from disk is corrupted (true = file corrupted)."
},
"URLCLASSIFIER_VLPS_LONG_PREFIXES": {
"alert_emails": ["safebrowsing-telemetry@mozilla.org"],
"expires_in_version": "61",
"kind": "enumerated",
"n_values": 32,
"bug_numbers": [1322523],
"description": "Length of the first 20 long prefixes (> 4 bytes) received in a Safe Browsing V4 table during an update."
},
"URLCLASSIFIER_LC_PREFIXES": {
"record_in_processes": ["main", "content"],
"alert_emails": ["safebrowsing-telemetry@mozilla.org"],

Просмотреть файл

@ -42,6 +42,7 @@
#include "zlib.h"
#include "Classifier.h"
#include "nsUrlClassifierDBService.h"
#include "mozilla/Telemetry.h"
// Main store for SafeBrowsing protocol data. We store
// known add/sub chunks, prefixes and completions in memory
@ -152,11 +153,21 @@ TableUpdateV2::NewSubComplete(uint32_t aAddChunk, const Completion& aHash, uint3
void
TableUpdateV4::NewPrefixes(int32_t aSize, std::string& aPrefixes)
{
NS_ENSURE_TRUE_VOID(aSize >= 4 && aSize <= COMPLETE_SIZE);
NS_ENSURE_TRUE_VOID(aPrefixes.size() % aSize == 0);
NS_ENSURE_TRUE_VOID(!mPrefixesMap.Get(aSize));
if (LOG_ENABLED() && 4 == aSize) {
int numOfPrefixes = aPrefixes.size() / 4;
int numOfPrefixes = aPrefixes.size() / aSize;
if (aSize > 4) {
// TODO Bug 1364043 we may have a better API to record multiple samples into
// histograms with one call
#ifdef NIGHTLY_BUILD
for (int i = 0; i < std::min(20, numOfPrefixes); i++) {
Telemetry::Accumulate(Telemetry::URLCLASSIFIER_VLPS_LONG_PREFIXES, aSize);
}
#endif
} else if (LOG_ENABLED()) {
uint32_t* p = (uint32_t*)aPrefixes.c_str();
// Dump the first/last 10 fixed-length prefixes for debugging.