Commit 4a72cea3 authored by Julia Tuttle's avatar Julia Tuttle Committed by Commit Bot

Reporting: Add upload histograms.

Change-Id: I8cfdb966b329d62aed531e0d22be98424e1928c4
Reviewed-on: https://chromium-review.googlesource.com/957165
Commit-Queue: Julia Tuttle <juliatuttle@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544068}
parent a4864c3d
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <vector> #include <vector>
#include "base/callback_helpers.h" #include "base/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "net/base/elements_upload_data_stream.h" #include "net/base/elements_upload_data_stream.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
...@@ -40,6 +41,26 @@ ReportingUploader::Outcome ResponseCodeToOutcome(int response_code) { ...@@ -40,6 +41,26 @@ ReportingUploader::Outcome ResponseCodeToOutcome(int response_code) {
return ReportingUploader::Outcome::FAILURE; return ReportingUploader::Outcome::FAILURE;
} }
enum class UploadOutcome {
CANCELED_REDIRECT_TO_INSECURE_URL = 0,
CANCELED_AUTH_REQUIRED = 1,
CANCELED_CERTIFICATE_REQUESTED = 2,
CANCELED_SSL_CERTIFICATE_ERROR = 3,
CANCELED_REPORTING_SHUTDOWN = 4,
FAILED = 5, // See Net.Reporting.UploadError for breakdown.
SUCCEEDED_SUCCESS = 6,
SUCCEEDED_REMOVE_ENDPOINT = 7,
MAX
};
void RecordUploadOutcome(UploadOutcome outcome) {
UMA_HISTOGRAM_ENUMERATION("Net.Reporting.UploadOutcome", outcome,
UploadOutcome::MAX);
}
// TODO: Record net and HTTP error.
class ReportingUploaderImpl : public ReportingUploader, URLRequest::Delegate { class ReportingUploaderImpl : public ReportingUploader, URLRequest::Delegate {
public: public:
ReportingUploaderImpl(const URLRequestContext* context) : context_(context) { ReportingUploaderImpl(const URLRequestContext* context) : context_(context) {
...@@ -157,6 +178,18 @@ class ReportingUploaderImpl : public ReportingUploader, URLRequest::Delegate { ...@@ -157,6 +178,18 @@ class ReportingUploaderImpl : public ReportingUploader, URLRequest::Delegate {
int response_code = headers ? headers->response_code() : 0; int response_code = headers ? headers->response_code() : 0;
Outcome outcome = ResponseCodeToOutcome(response_code); Outcome outcome = ResponseCodeToOutcome(response_code);
if (net_error != OK) {
RecordUploadOutcome(UploadOutcome::FAILED);
base::UmaHistogramSparse("Net.Reporting.UploadError", net_error);
} else if (response_code >= 200 && response_code <= 299) {
RecordUploadOutcome(UploadOutcome::SUCCEEDED_SUCCESS);
} else if (response_code == 410) {
RecordUploadOutcome(UploadOutcome::SUCCEEDED_REMOVE_ENDPOINT);
} else {
RecordUploadOutcome(UploadOutcome::FAILED);
base::UmaHistogramSparse("Net.Reporting.UploadError", response_code);
}
std::move(upload->second).Run(outcome); std::move(upload->second).Run(outcome);
request->Cancel(); request->Cancel();
......
...@@ -30341,6 +30341,17 @@ Called by update_net_error_codes.py.--> ...@@ -30341,6 +30341,17 @@ Called by update_net_error_codes.py.-->
<int value="9" label="Delivered"/> <int value="9" label="Delivered"/>
</enum> </enum>
<enum name="NetReportingUploadOutcome">
<int value="0" label="Canceled: redirect to insecure URL"/>
<int value="1" label="Canceled: auth required"/>
<int value="2" label="Canceled: certificate requested"/>
<int value="3" label="Canceled: SSL certificate error"/>
<int value="4" label="Canceled: Reporting shut down"/>
<int value="5" label="Failed: network error"/>
<int value="6" label="Succeeded: success"/>
<int value="7" label="Succeeded: remove endpoint"/>
</enum>
<enum name="NetTrustAnchors"> <enum name="NetTrustAnchors">
<!-- Generated from net/data/ssl/root_stores/root_stores.json. <!-- Generated from net/data/ssl/root_stores/root_stores.json.
Called by update_net_trust_anchors.py.--> Called by update_net_trust_anchors.py.-->
...@@ -48386,6 +48386,26 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -48386,6 +48386,26 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Net.Reporting.UploadError"
enum="CombinedHttpResponseAndNetErrorCode">
<owner>juliatuttle@chromium.org</owner>
<summary>
The error (net or HTTP) encountered by Reporting trying to upload one or
more reports to a single endpoint in a single request, recorded when the
upload attempt completes, if and only if the attempt failed with a net error
or an HTTP error other than 410 (which is specified to mean &quot;remove
endpoint&quot;).
</summary>
</histogram>
<histogram name="Net.Reporting.UploadOutcome" enum="NetReportingUploadOutcome">
<owner>juliatuttle@chromium.org</owner>
<summary>
The outcome of Reporting trying to upload one or more reports to a single
endpoint in a single request, recorded when the upload attempt completes.
</summary>
</histogram>
<histogram name="Net.RequestTime"> <histogram name="Net.RequestTime">
<obsolete> <obsolete>
Replaced by Net.RequestTime2 due to bug in original implementation. Replaced by Net.RequestTime2 due to bug in original implementation.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment