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

Unified Diff: net/reporting/reporting_report.cc

Issue 2900553004: Reporting: Add histograms. (Closed)
Patch Set: rebase Created 3 years, 5 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
« no previous file with comments | « net/reporting/reporting_report.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/reporting/reporting_report.cc
diff --git a/net/reporting/reporting_report.cc b/net/reporting/reporting_report.cc
index b039bc1cd415e21387b2f07add7395643f75ab77..37c4a22bd3decfa37d2af0a5f93502426407a7cd 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("Reporting.ReportOutcome", outcome,
+ ReportingReport::Outcome::MAX);
+}
+
+} // namespace
+
ReportingReport::ReportingReport(const GURL& url,
const std::string& group,
const std::string& type,
@@ -25,8 +35,36 @@ 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::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("Reporting.ReportDeliveredLatency",
+ now - queued);
+ UMA_HISTOGRAM_COUNTS_100("Reporting.ReportDeliveredAttempts", attempts);
+ }
-ReportingReport::~ReportingReport() {}
+ recorded_outcome = true;
+}
} // namespace net
« no previous file with comments | « net/reporting/reporting_report.h ('k') | net/url_request/url_request_http_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698