Commit 6fef54c5 authored by sclittle's avatar sclittle Committed by Commit bot

Added new BypassedBytes.Current histograms.

Added new histograms to break down Current bypasses (i.e. "Chrome-Proxy: block-once") by audio/video content types, as well as "content-type: application/octet-stream".

BUG=473763

Review URL: https://codereview.chromium.org/1048303004

Cr-Commit-Position: refs/heads/master@{#324075}
parent 3e301cc2
......@@ -289,26 +289,37 @@ void DataReductionProxyBypassStats::RecordBypassedBytesHistograms(
return;
}
// Only record separate triggering request UMA for short, medium, and long
// bypass events.
if (triggering_request_ &&
(last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT ||
last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM ||
last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) {
std::string mime_type;
request.GetMimeType(&mime_type);
// MIME types are named by <media-type>/<subtype>. Check to see if the
// media type is audio or video. Only record when triggered by short bypass,
// there isn't an audio or video bucket for medium or long bypasses.
if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT &&
// MIME types are named by <media-type>/<subtype>. Check to see if the media
// type is audio or video in order to record audio/video bypasses separately
// for current bypasses and for the triggering requests of short bypasses.
if ((last_bypass_type_ == BYPASS_EVENT_TYPE_CURRENT ||
(triggering_request_ && last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT)) &&
(mime_type.compare(0, 6, "audio/") == 0 ||
mime_type.compare(0, 6, "video/") == 0)) {
RecordBypassedBytes(last_bypass_type_,
DataReductionProxyBypassStats::AUDIO_VIDEO,
content_length);
triggering_request_ = false;
return;
}
// Report current bypasses of MIME type "application/octet-stream" separately.
if (last_bypass_type_ == BYPASS_EVENT_TYPE_CURRENT &&
mime_type.find("application/octet-stream") != std::string::npos) {
RecordBypassedBytes(last_bypass_type_,
DataReductionProxyBypassStats::APPLICATION_OCTET_STREAM,
content_length);
return;
}
// Only record separate triggering request UMA for short, medium, and long
// bypass events.
if (triggering_request_ &&
(last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT ||
last_bypass_type_ == BYPASS_EVENT_TYPE_MEDIUM ||
last_bypass_type_ == BYPASS_EVENT_TYPE_LONG)) {
RecordBypassedBytes(last_bypass_type_,
DataReductionProxyBypassStats::TRIGGERING_REQUEST,
content_length);
......@@ -415,10 +426,30 @@ void DataReductionProxyBypassStats::RecordBypassedBytes(
content_length);
break;
case DataReductionProxyBypassStats::AUDIO_VIDEO:
if (last_bypass_type_ == BYPASS_EVENT_TYPE_SHORT) {
switch (bypass_type) {
case BYPASS_EVENT_TYPE_CURRENT:
UMA_HISTOGRAM_COUNTS(
"DataReductionProxy.BypassedBytes.CurrentAudioVideo",
content_length);
break;
case BYPASS_EVENT_TYPE_SHORT:
UMA_HISTOGRAM_COUNTS(
"DataReductionProxy.BypassedBytes.ShortAudioVideo",
content_length);
break;
default:
NOTREACHED();
}
break;
case DataReductionProxyBypassStats::APPLICATION_OCTET_STREAM:
switch (bypass_type) {
case BYPASS_EVENT_TYPE_CURRENT:
UMA_HISTOGRAM_COUNTS(
"DataReductionProxy.BypassedBytes.CurrentApplicationOctetStream",
content_length);
break;
default:
NOTREACHED();
}
break;
case DataReductionProxyBypassStats::TRIGGERING_REQUEST:
......
......@@ -96,6 +96,7 @@ class DataReductionProxyBypassStats
LOCAL_BYPASS_RULES, /* Bypass due to client-side bypass rules. */
PROXY_OVERRIDDEN, /* Bypass due to a proxy taking precedence. */
AUDIO_VIDEO, /* Audio/Video bypass. */
APPLICATION_OCTET_STREAM, /* "application/octet-stream" content bypass. */
TRIGGERING_REQUEST, /* Triggering request bypass. */
NETWORK_ERROR, /* Network error. */
BYPASSED_BYTES_TYPE_MAX /* This must always be last.*/
......
......@@ -658,6 +658,8 @@ class DataReductionProxyBypassStatsEndToEndTest : public testing::Test {
"DataReductionProxy.BypassedBytes.LocalBypassRules",
"DataReductionProxy.BypassedBytes.ProxyOverridden",
"DataReductionProxy.BypassedBytes.Current",
"DataReductionProxy.BypassedBytes.CurrentAudioVideo",
"DataReductionProxy.BypassedBytes.CurrentApplicationOctetStream",
"DataReductionProxy.BypassedBytes.ShortAll",
"DataReductionProxy.BypassedBytes.ShortTriggeringRequest",
"DataReductionProxy.BypassedBytes.ShortAudioVideo",
......@@ -765,18 +767,34 @@ TEST_F(DataReductionProxyBypassStatsEndToEndTest,
TEST_F(DataReductionProxyBypassStatsEndToEndTest, BypassedBytesCurrent) {
InitializeContext();
struct TestCase {
const char* histogram_name;
const char* retry_response_headers;
};
const TestCase test_cases[] = {
{"DataReductionProxy.BypassedBytes.Current", "HTTP/1.1 200 OK\r\n\r\n"},
{"DataReductionProxy.BypassedBytes.CurrentAudioVideo",
"HTTP/1.1 200 OK\r\n"
"Content-Type: video/mp4\r\n\r\n"},
{"DataReductionProxy.BypassedBytes.CurrentApplicationOctetStream",
"HTTP/1.1 200 OK\r\n"
"Content-Type: application/octet-stream\r\n\r\n"},
};
for (const TestCase& test_case : test_cases) {
ClearBadProxies();
base::HistogramTester histogram_tester;
CreateAndExecuteRequest(GURL("http://foo.com"),
"HTTP/1.1 502 Bad Gateway\r\n"
"Via: 1.1 Chrome-Compression-Proxy\r\n"
"Chrome-Proxy: block-once\r\n\r\n",
kErrorBody.c_str(), "HTTP/1.1 200 OK\r\n\r\n",
kBody.c_str());
kErrorBody.c_str(),
test_case.retry_response_headers, kBody.c_str());
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.BypassedBytes.Current", kBody.size(), 1);
ExpectOtherBypassedBytesHistogramsEmpty(
histogram_tester, "DataReductionProxy.BypassedBytes.Current");
histogram_tester.ExpectUniqueSample(test_case.histogram_name, kBody.size(),
1);
ExpectOtherBypassedBytesHistogramsEmpty(histogram_tester,
test_case.histogram_name);
}
}
TEST_F(DataReductionProxyBypassStatsEndToEndTest,
......
......@@ -63554,6 +63554,11 @@ To add a new entry, add it with any value and run test to compute valid value.
<suffix name="ProxyOverridden"
label="Bypass due to another proxy taking precedence"/>
<suffix name="Current" label="Bypass due to explicit instruction"/>
<suffix name="CurrentAudioVideo"
label="Bypass due to explicit instruction for audio/video"/>
<suffix name="CurrentApplicationOctetStream"
label="Bypass due to explicit instruction for
'application/octet-stream' content type"/>
<suffix name="ShortAll" label="Short bypass"/>
<suffix name="ShortTriggeringRequest"
label="Triggering request short bypass"/>
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