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

Unified Diff: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc

Issue 577343002: Adds UMA to measure when the data reduction proxy via header is missing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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: components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
index b24094763c503b3a30ef59cf9ebad7ba84a9127a..4f77f1a7d05f7adf460aa35f19d14318c1792b82 100644
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_usage_stats.cc
@@ -11,6 +11,9 @@
#include "base/metrics/sparse_histogram.h"
#include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
#include "net/base/net_errors.h"
+#include "net/http/http_response_headers.h"
+#include "net/http/http_status_code.h"
+#include "net/http/http_util.h"
#include "net/proxy/proxy_retry_info.h"
#include "net/proxy/proxy_server.h"
#include "net/proxy/proxy_service.h"
@@ -72,6 +75,29 @@ void DataReductionProxyUsageStats::RecordDataReductionProxyBypassInfo(
}
}
+// static
+void DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode(
+ bool is_primary, const net::HttpResponseHeaders* headers) {
+ if (HasDataReductionProxyViaHeader(headers, NULL)) {
+ // The data reduction proxy via header is present, so don't record anything.
+ return;
+ }
+
+ // Record the response code in the same way that net::HttpResponseHeaders
+ // records the response code for the histogram Net.HttpResponseCode.
+ if (is_primary) {
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION(
+ "DataReductionProxy.MissingViaHeaderResponseCodePrimary",
+ net::HttpUtil::MapStatusCodeForHistogram(headers->response_code()),
+ net::HttpUtil::GetStatusCodesForHistogram());
+ } else {
+ UMA_HISTOGRAM_CUSTOM_ENUMERATION(
+ "DataReductionProxy.MissingViaHeaderResponseCodeFallback",
+ net::HttpUtil::MapStatusCodeForHistogram(headers->response_code()),
+ net::HttpUtil::GetStatusCodesForHistogram());
+ }
+}
+
DataReductionProxyUsageStats::DataReductionProxyUsageStats(
DataReductionProxyParams* params,
MessageLoopProxy* ui_thread_proxy)
@@ -373,6 +399,32 @@ void DataReductionProxyUsageStats::RecordBypassedBytes(
}
}
+void DataReductionProxyUsageStats::RecordMissingViaHeaderBytes(
+ URLRequest* request) {
+ // Responses that were served from cache should have been filtered out
+ // already.
+ DCHECK(!request->was_cached());
+
+ if (!data_reduction_proxy_params_->WasDataReductionProxyUsed(request, NULL)
+ || HasDataReductionProxyViaHeader(request->response_headers(), NULL)) {
mmenke 2014/09/18 18:39:30 Searching through the header every time we get a k
sclittle 2014/09/19 01:05:01 Aren't there a lot of things that search through a
mmenke 2014/09/19 01:39:03 Oh, sorry - was thinking this was being called on
+ // Only track requests that used the data reduction proxy and had responses
+ // that were missing the data reduction proxy via header.
+ return;
+ }
+
+ if (request->GetResponseCode() >= net::HTTP_BAD_REQUEST
+ && request->GetResponseCode() < net::HTTP_INTERNAL_SERVER_ERROR) {
mmenke 2014/09/18 18:39:30 nit: Not sure if the DRP code uses another style,
sclittle 2014/09/19 01:05:01 Done.
+ // Track 4xx responses that are missing via headers separately.
+ // separately.
+ UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader4xxResponseBytes",
+ request->received_response_content_length());
+ } else {
+ UMA_HISTOGRAM_COUNTS(
+ "DataReductionProxy.MissingViaHeaderOtherResponseBytes",
+ request->received_response_content_length());
+ }
+}
+
} // namespace data_reduction_proxy

Powered by Google App Engine
This is Rietveld 408576698