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

Side by Side 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: Addressed comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta ts.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/metrics/sparse_histogram.h" 11 #include "base/metrics/sparse_histogram.h"
12 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" 12 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/http/http_response_headers.h"
15 #include "net/http/http_status_code.h"
16 #include "net/http/http_util.h"
14 #include "net/proxy/proxy_retry_info.h" 17 #include "net/proxy/proxy_retry_info.h"
15 #include "net/proxy/proxy_server.h" 18 #include "net/proxy/proxy_server.h"
16 #include "net/proxy/proxy_service.h" 19 #include "net/proxy/proxy_service.h"
17 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_context.h" 21 #include "net/url_request/url_request_context.h"
19 22
20 using base::MessageLoopProxy; 23 using base::MessageLoopProxy;
21 using net::HostPortPair; 24 using net::HostPortPair;
22 using net::ProxyServer; 25 using net::ProxyServer;
23 using net::ProxyService; 26 using net::ProxyService;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (is_primary) { 68 if (is_primary) {
66 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypePrimary", 69 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypePrimary",
67 bypass_type, BYPASS_EVENT_TYPE_MAX); 70 bypass_type, BYPASS_EVENT_TYPE_MAX);
68 } else { 71 } else {
69 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypeFallback", 72 UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.BypassTypeFallback",
70 bypass_type, BYPASS_EVENT_TYPE_MAX); 73 bypass_type, BYPASS_EVENT_TYPE_MAX);
71 } 74 }
72 } 75 }
73 } 76 }
74 77
78 // static
79 void DataReductionProxyUsageStats::DetectAndRecordMissingViaHeaderResponseCode(
80 bool is_primary, const net::HttpResponseHeaders* headers) {
81 if (HasDataReductionProxyViaHeader(headers, NULL)) {
82 // The data reduction proxy via header is present, so don't record anything.
bengr 2014/09/19 21:42:56 Would it be useful to count these so we know the f
sclittle 2014/09/19 22:38:11 That's what the other UMA added in this CL is for:
83 return;
84 }
85
86 // Record the response code in the same way that net::HttpResponseHeaders
87 // records the response code for the histogram Net.HttpResponseCode.
88 if (is_primary) {
89 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
90 "DataReductionProxy.MissingViaHeaderResponseCodePrimary",
91 net::HttpUtil::MapStatusCodeForHistogram(headers->response_code()),
92 net::HttpUtil::GetStatusCodesForHistogram());
93 } else {
94 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
95 "DataReductionProxy.MissingViaHeaderResponseCodeFallback",
96 net::HttpUtil::MapStatusCodeForHistogram(headers->response_code()),
97 net::HttpUtil::GetStatusCodesForHistogram());
98 }
99 }
100
75 DataReductionProxyUsageStats::DataReductionProxyUsageStats( 101 DataReductionProxyUsageStats::DataReductionProxyUsageStats(
76 DataReductionProxyParams* params, 102 DataReductionProxyParams* params,
77 MessageLoopProxy* ui_thread_proxy) 103 MessageLoopProxy* ui_thread_proxy)
78 : data_reduction_proxy_params_(params), 104 : data_reduction_proxy_params_(params),
79 last_bypass_type_(BYPASS_EVENT_TYPE_MAX), 105 last_bypass_type_(BYPASS_EVENT_TYPE_MAX),
80 triggering_request_(true), 106 triggering_request_(true),
81 ui_thread_proxy_(ui_thread_proxy), 107 ui_thread_proxy_(ui_thread_proxy),
82 eligible_num_requests_through_proxy_(0), 108 eligible_num_requests_through_proxy_(0),
83 actual_num_requests_through_proxy_(0), 109 actual_num_requests_through_proxy_(0),
84 unavailable_(false) { 110 unavailable_(false) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (!unavailable_callback_.is_null()) 178 if (!unavailable_callback_.is_null())
153 unavailable_callback_.Run(unavailable); 179 unavailable_callback_.Run(unavailable);
154 } 180 }
155 181
156 void DataReductionProxyUsageStats::SetBypassType( 182 void DataReductionProxyUsageStats::SetBypassType(
157 DataReductionProxyBypassType type) { 183 DataReductionProxyBypassType type) {
158 last_bypass_type_ = type; 184 last_bypass_type_ = type;
159 triggering_request_ = true; 185 triggering_request_ = true;
160 } 186 }
161 187
188 void DataReductionProxyUsageStats::RecordBytesHistograms(
189 net::URLRequest& request,
190 const BooleanPrefMember& data_reduction_proxy_enabled,
191 const net::ProxyConfig& data_reduction_proxy_config) {
192 RecordBypassedBytesHistograms(request, data_reduction_proxy_enabled,
193 data_reduction_proxy_config);
194 RecordMissingViaHeaderBytes(request);
195 }
196
162 void DataReductionProxyUsageStats::RecordBypassedBytesHistograms( 197 void DataReductionProxyUsageStats::RecordBypassedBytesHistograms(
163 net::URLRequest& request, 198 net::URLRequest& request,
164 const BooleanPrefMember& data_reduction_proxy_enabled, 199 const BooleanPrefMember& data_reduction_proxy_enabled,
165 const net::ProxyConfig& data_reduction_proxy_config) { 200 const net::ProxyConfig& data_reduction_proxy_config) {
166 int64 content_length = request.received_response_content_length(); 201 int64 content_length = request.received_response_content_length();
167 202
168 if (data_reduction_proxy_enabled.GetValue() && 203 if (data_reduction_proxy_enabled.GetValue() &&
169 !data_reduction_proxy_config.Equals( 204 !data_reduction_proxy_config.Equals(
170 request.context()->proxy_service()->config())) { 205 request.context()->proxy_service()->config())) {
171 RecordBypassedBytes(last_bypass_type_, 206 RecordBypassedBytes(last_bypass_type_,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 "Status503HttpServiceUnavailable", 401 "Status503HttpServiceUnavailable",
367 content_length); 402 content_length);
368 break; 403 break;
369 default: 404 default:
370 break; 405 break;
371 } 406 }
372 break; 407 break;
373 } 408 }
374 } 409 }
375 410
411 void DataReductionProxyUsageStats::RecordMissingViaHeaderBytes(
412 URLRequest& request) {
413 // Responses that were served from cache should have been filtered out
414 // already.
415 DCHECK(!request.was_cached());
416
417 if (!data_reduction_proxy_params_->WasDataReductionProxyUsed(&request,
418 NULL) ||
419 HasDataReductionProxyViaHeader(request.response_headers(), NULL)) {
420 // Only track requests that used the data reduction proxy and had responses
421 // that were missing the data reduction proxy via header.
422 return;
423 }
424
425 if (request.GetResponseCode() >= net::HTTP_BAD_REQUEST &&
426 request.GetResponseCode() < net::HTTP_INTERNAL_SERVER_ERROR) {
427 // Track 4xx responses that are missing via headers separately.
428 // separately.
429 UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader4xxResponseBytes",
430 request.received_response_content_length());
431 } else {
432 UMA_HISTOGRAM_COUNTS(
433 "DataReductionProxy.MissingViaHeaderOtherResponseBytes",
434 request.received_response_content_length());
435 }
436 }
437
376 } // namespace data_reduction_proxy 438 } // namespace data_reduction_proxy
377 439
378 440
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698