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

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: 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.
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 "Status503HttpServiceUnavailable", 392 "Status503HttpServiceUnavailable",
367 content_length); 393 content_length);
368 break; 394 break;
369 default: 395 default:
370 break; 396 break;
371 } 397 }
372 break; 398 break;
373 } 399 }
374 } 400 }
375 401
402 void DataReductionProxyUsageStats::RecordMissingViaHeaderBytes(
403 URLRequest* request) {
404 // Responses that were served from cache should have been filtered out
405 // already.
406 DCHECK(!request->was_cached());
407
408 if (!data_reduction_proxy_params_->WasDataReductionProxyUsed(request, NULL)
409 || 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
410 // Only track requests that used the data reduction proxy and had responses
411 // that were missing the data reduction proxy via header.
412 return;
413 }
414
415 if (request->GetResponseCode() >= net::HTTP_BAD_REQUEST
416 && 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.
417 // Track 4xx responses that are missing via headers separately.
418 // separately.
419 UMA_HISTOGRAM_COUNTS("DataReductionProxy.MissingViaHeader4xxResponseBytes",
420 request->received_response_content_length());
421 } else {
422 UMA_HISTOGRAM_COUNTS(
423 "DataReductionProxy.MissingViaHeaderOtherResponseBytes",
424 request->received_response_content_length());
425 }
426 }
427
376 } // namespace data_reduction_proxy 428 } // namespace data_reduction_proxy
377 429
378 430
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698