Commit 71f5a416 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Create generic UMA for why data savings were cleared

This new UMA will replace
DataReductionProxy.SavingsCleared.NegativeSystemClock and add on more
enum values for all the possible reasons the data savings could have
been cleared. This will be done in a follow up CL.

Bug: 812922
Change-Id: Ibc82d187045444b6ca7812e2fc2097549501c0aa
Reviewed-on: https://chromium-review.googlesource.com/1024880
Commit-Queue: Robert Ogden <robertogden@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553725}
parent 31369423
......@@ -202,11 +202,15 @@ void RecordDailyContentLengthHistograms(
percent_savings_via_data_reduction_proxy);
}
void RecordSavingsClearedNegativeClockMetric(int days_since_last_update) {
// Data savings are cleared if the system clock moved back by more than
// one day.
UMA_HISTOGRAM_BOOLEAN("DataReductionProxy.SavingsCleared.NegativeSystemClock",
days_since_last_update < -1);
void RecordSavingsClearedMetric(
DataReductionProxyCompressionStats::DataReductionProxySavingsClearedReason
reason) {
DCHECK_GT(DataReductionProxyCompressionStats::
DataReductionProxySavingsClearedReason::kCount,
reason);
UMA_HISTOGRAM_ENUMERATION("DataReductionProxy.SavingsCleared.Reason", reason,
DataReductionProxyCompressionStats::
DataReductionProxySavingsClearedReason::kCount);
}
} // namespace
......@@ -963,7 +967,10 @@ void DataReductionProxyCompressionStats::RecordRequestSizePrefs(
"Net.DailyContentLength_ViaDataReductionProxy_UnknownMime");
}
RecordSavingsClearedNegativeClockMetric(days_since_last_update);
if (days_since_last_update < -1) {
RecordSavingsClearedMetric(
DataReductionProxySavingsClearedReason::kSystemClockMovedBack);
}
// The system may go backwards in time by up to a day for legitimate
// reasons, such as with changes to the time zone. In such cases, we
......
......@@ -46,6 +46,15 @@ class DataReductionProxyCompressionStats {
typedef std::unordered_map<std::string, std::unique_ptr<PerSiteDataUsage>>
SiteUsageMap;
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class DataReductionProxySavingsClearedReason {
kSystemClockMovedBack = 0,
// TODO(robertogden): Use this. Temp added to appease the DCHECK gods.
kPrefsParseError = 1,
kCount
};
// Collects and store data usage and compression statistics. Basic data usage
// stats are stored in browser preferences. More detailed stats broken down
// by site and internet type are stored in |DataReductionProxyStore|.
......
......@@ -852,73 +852,6 @@ TEST_F(DataReductionProxyCompressionStatsTest, PartialDayTimeChange) {
received2, 2, kNumDaysInHistory);
}
TEST_F(DataReductionProxyCompressionStatsTest, ForwardMultipleDays) {
base::HistogramTester histogram_tester;
const int64_t kOriginalLength = 200;
const int64_t kReceivedLength = 100;
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 1);
// Forward three days.
SetFakeTimeDeltaInHours(3 * 24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 2);
int64_t original[] = {kOriginalLength, 0, 0, kOriginalLength};
int64_t received[] = {kReceivedLength, 0, 0, kReceivedLength};
VerifyDailyDataSavingContentLengthPrefLists(
original, 4, received, 4, original, 4, received, 4, original, 4, received,
4, kNumDaysInHistory);
// Forward four more days.
AddFakeTimeDeltaInHours(4 * 24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
int64_t original2[] = {
kOriginalLength, 0, 0, kOriginalLength, 0, 0, 0, kOriginalLength,
};
int64_t received2[] = {
kReceivedLength, 0, 0, kReceivedLength, 0, 0, 0, kReceivedLength,
};
VerifyDailyDataSavingContentLengthPrefLists(
original2, 8, received2, 8, original2, 8, received2, 8, original2, 8,
received2, 8, kNumDaysInHistory);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 3);
// Forward |kNumDaysInHistory| more days.
AddFakeTimeDeltaInHours(kNumDaysInHistory * 24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
int64_t original3[] = {kOriginalLength};
int64_t received3[] = {kReceivedLength};
VerifyDailyDataSavingContentLengthPrefLists(
original3, 1, received3, 1, original3, 1, received3, 1, original3, 1,
received3, 1, kNumDaysInHistory);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 4);
// Forward |kNumDaysInHistory| + 1 more days.
AddFakeTimeDeltaInHours((kNumDaysInHistory + 1)* 24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
VerifyDailyDataSavingContentLengthPrefLists(
original3, 1, received3, 1, original3, 1, received3, 1, original3, 1,
received3, 1, kNumDaysInHistory);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 5);
}
TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
base::HistogramTester histogram_tester;
const int64_t kOriginalLength = 200;
......@@ -929,10 +862,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 1);
// Backward one day.
// Backward one day, expect no count.
SetFakeTimeDeltaInHours(-24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
......@@ -942,10 +873,10 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1, original, 1, received, 1, original, 1, received,
1, kNumDaysInHistory);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 2);
histogram_tester.ExpectTotalCount("DataReductionProxy.SavingsCleared.Reason",
0);
// Then, Forward one day
// Then forward one day, expect no count.
AddFakeTimeDeltaInHours(24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
......@@ -955,8 +886,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardAndForwardOneDay) {
VerifyDailyDataSavingContentLengthPrefLists(
original2, 2, received2, 2, original2, 2, received2, 2, original2, 2,
received2, 2, kNumDaysInHistory);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 3);
histogram_tester.ExpectTotalCount("DataReductionProxy.SavingsCleared.Reason",
0);
}
TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) {
......@@ -969,10 +900,8 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) {
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
FakeNow());
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 1);
// Backward two days.
// Backward two days, expect kSystemClockMovedBack.
SetFakeTimeDeltaInHours(-2 * 24);
RecordContentLengthPrefs(
kReceivedLength, kOriginalLength, true, VIA_DATA_REDUCTION_PROXY,
......@@ -980,30 +909,33 @@ TEST_F(DataReductionProxyCompressionStatsTest, BackwardTwoDays) {
VerifyDailyDataSavingContentLengthPrefLists(
original, 1, received, 1, original, 1, received, 1, original, 1, received,
1, kNumDaysInHistory);
histogram_tester.ExpectTotalCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", 2);
histogram_tester.ExpectBucketCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", true, 1);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.Reason",
DataReductionProxyCompressionStats::
DataReductionProxySavingsClearedReason::kSystemClockMovedBack,
1);
VerifyPrefInt64(prefs::kDataReductionProxySavingsClearedNegativeSystemClock,
FakeNow().ToInternalValue());
// Backward two days.
// Backward another two days, expect kSystemClockMovedBack.
SetFakeTimeDeltaInHours(-4 * 24);
RecordContentLengthPrefs(kReceivedLength, kOriginalLength, true,
VIA_DATA_REDUCTION_PROXY, FakeNow());
histogram_tester.ExpectTotalCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", 3);
histogram_tester.ExpectBucketCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", true, 2);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.Reason",
DataReductionProxyCompressionStats::
DataReductionProxySavingsClearedReason::kSystemClockMovedBack,
2);
// Forward 10 days.
AddFakeTimeDeltaInHours(10 * 24);
// Forward 2 days, expect no change.
AddFakeTimeDeltaInHours(2 * 24);
RecordContentLengthPrefs(kReceivedLength, kOriginalLength, true,
VIA_DATA_REDUCTION_PROXY, FakeNow());
histogram_tester.ExpectTotalCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", 4);
histogram_tester.ExpectBucketCount(
"DataReductionProxy.SavingsCleared.NegativeSystemClock", false, 2);
histogram_tester.ExpectUniqueSample(
"DataReductionProxy.SavingsCleared.Reason",
DataReductionProxyCompressionStats::
DataReductionProxySavingsClearedReason::kSystemClockMovedBack,
2);
}
TEST_F(DataReductionProxyCompressionStatsTest, NormalizeHostname) {
......
......@@ -8725,6 +8725,11 @@ Called by update_net_error_codes.py.-->
<int value="3" label="Non-DRP proxy server with DRP via header"/>
</enum>
<enum name="DataReductionProxySavingsClearedReason">
<int value="0" label="System clock moved back &gt; 24 hours"/>
<int value="1" label="Parsing error loading prefs from disk"/>
</enum>
<enum name="DataReductionProxySettingsConversion">
<int value="0" label="OFF to OFF"/>
<int value="1" label="OFF to ON"/>
......@@ -14858,6 +14858,9 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<histogram name="DataReductionProxy.SavingsCleared.NegativeSystemClock"
enum="BooleanCleared">
<obsolete>
Replaced by DataReductionProxy.SavingsCleared.Reason in M68.
</obsolete>
<owner>tbansal@chromium.org</owner>
<owner>bengr@chromium.org</owner>
<summary>
......@@ -14867,6 +14870,13 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="DataReductionProxy.SavingsCleared.Reason"
enum="DataReductionProxySavingsClearedReason">
<owner>robertogden@chromium.org</owner>
<owner>bengr@chromium.org</owner>
<summary>Records why the data reduction savings were cleared.</summary>
</histogram>
<histogram name="DataReductionProxy.SecureProxyCheck.Latency" units="ms">
<owner>bengr@chromium.org</owner>
<summary>
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