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

Unified Diff: net/reporting/reporting_report.cc

Issue 2900553004: Reporting: Add histograms. (Closed)
Patch Set: oops, forgot about dependency Created 3 years, 7 months 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: net/reporting/reporting_report.cc
diff --git a/net/reporting/reporting_report.cc b/net/reporting/reporting_report.cc
index b039bc1cd415e21387b2f07add7395643f75ab77..4ac0998f17cd902252f6f8178d4bf3398bd0b880 100644
--- a/net/reporting/reporting_report.cc
+++ b/net/reporting/reporting_report.cc
@@ -8,12 +8,22 @@
#include <string>
#include <utility>
+#include "base/metrics/histogram_macros.h"
#include "base/time/time.h"
#include "base/values.h"
#include "url/gurl.h"
namespace net {
+namespace {
+
+void RecordReportOutcome(ReportingReport::Outcome outcome) {
+ UMA_HISTOGRAM_ENUMERATION("Net.Reporting.ReportOutcome", outcome,
+ ReportingReport::Outcome::MAX);
+}
+
+} // namespace
+
ReportingReport::ReportingReport(const GURL& url,
const std::string& group,
const std::string& type,
@@ -25,8 +35,41 @@ ReportingReport::ReportingReport(const GURL& url,
type(type),
body(std::move(body)),
queued(queued),
- attempts(attempts) {}
+ attempts(attempts),
+ outcome(Outcome::UNKNOWN),
+ recorded_outcome(false) {}
+
+ReportingReport::~ReportingReport() {
+ DCHECK(recorded_outcome);
+}
+
+// static
+void ReportingReport::RecordReportDiscardedForInvalidTypeFromRenderer() {
+ RecordReportOutcome(Outcome::DISCARDED_INVALID_TYPE_FROM_RENDERER);
+}
+
+// static
+void ReportingReport::RecordReportDiscardedForNoURLRequestContext() {
+ RecordReportOutcome(Outcome::DISCARDED_NO_URL_REQUEST_CONTEXT);
+}
+
+// static
+void ReportingReport::RecordReportDiscardedForNoReportingService() {
+ RecordReportOutcome(Outcome::DISCARDED_NO_REPORTING_SERVICE);
+}
+
+void ReportingReport::RecordOutcome(base::TimeTicks now) {
+ DCHECK(!recorded_outcome);
+
+ RecordReportOutcome(outcome);
+
+ if (outcome == Outcome::DELIVERED) {
+ UMA_HISTOGRAM_LONG_TIMES_100("Net.Reporting.ReportDeliveredLatency",
+ now - queued);
+ UMA_HISTOGRAM_COUNTS_100("Net.Reporting.ReportDeliveredAttempts", attempts);
+ }
-ReportingReport::~ReportingReport() {}
+ recorded_outcome = true;
+}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698