Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Unified Diff: components/domain_reliability/context.cc

Issue 1497803004: Domain Reliability: Add sample_rate field to Beacon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ...actually make sample_rate a double :P Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/domain_reliability/context.cc
diff --git a/components/domain_reliability/context.cc b/components/domain_reliability/context.cc
index f0ce6c54c624cb15f1273495d72d5b9c84cc1a83..bcd0d7fc8907845f2c0d99f98b4b811ba39505df 100644
--- a/components/domain_reliability/context.cc
+++ b/components/domain_reliability/context.cc
@@ -11,6 +11,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h"
+#include "base/rand_util.h"
#include "base/values.h"
#include "components/domain_reliability/dispatcher.h"
#include "components/domain_reliability/uploader.h"
@@ -69,16 +70,17 @@ DomainReliabilityContext::~DomainReliabilityContext() {
void DomainReliabilityContext::OnBeacon(
scoped_ptr<DomainReliabilityBeacon> beacon) {
bool success = (beacon->status == "ok");
-
- bool reported = config().DecideIfShouldReportRequest(success);
- UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", reported);
- if (!reported) {
+ double sample_rate = config().GetSampleRate(success);
+ bool report = base::RandDouble() < sample_rate;
jkarlin 2015/12/09 11:46:22 nit: s/report/should_report/ report sounds like a
Deprecated (see juliatuttle) 2015/12/10 17:04:23 Done, and same for evicted => should_evict.
+ UMA_HISTOGRAM_BOOLEAN("DomainReliability.BeaconReported", report);
+ if (!report) {
// If the beacon isn't queued to be reported, it definitely cannot evict
// an older beacon. (This histogram is also logged below based on whether
// an older beacon was actually evicted.)
LogOnBeaconDidEvictHistogram(false);
return;
}
+ beacon->sample_rate = sample_rate;
UMA_HISTOGRAM_SPARSE_SLOWLY("DomainReliability.ReportedBeaconError",
-beacon->chrome_error);

Powered by Google App Engine
This is Rietveld 408576698