Commit dec05b72 authored by Akira Baruah's avatar Akira Baruah Committed by Commit Bot

[metrics] Record size of dropped logs

Unsent metrics logs get trimmed if they're larger than a preset size.
This change implements a new UMA metrics histogram called
"UMA.UnsentLogs.DroppedSize" to record the size of each of these trimmed
logs.

Also adds a unit test case for a similar existing histogram that
measures dropped log counts.

Bug: None
Test: metrics_unittests
Change-Id: If6ed17a2a1327c2bd3d3a9da16926b91e72a6f43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2482322
Commit-Queue: Akira Baruah <akirabaruah@google.com>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819434}
parent f8bce0fa
......@@ -15,14 +15,16 @@ void UnsentLogStoreMetricsImpl::RecordLogReadStatus(
UnsentLogStoreMetrics::END_RECALL_STATUS);
}
void UnsentLogStoreMetricsImpl::RecordCompressionRatio(
size_t compressed_size, size_t original_size) {
void UnsentLogStoreMetricsImpl::RecordCompressionRatio(size_t compressed_size,
size_t original_size) {
base::UmaHistogramPercentageObsoleteDoNotUse(
"UMA.ProtoCompressionRatio",
static_cast<int>(100 * compressed_size / original_size));
}
void UnsentLogStoreMetricsImpl::RecordDroppedLogSize(size_t size) {
base::UmaHistogramCounts1M("UMA.UnsentLogs.DroppedSize",
static_cast<int>(size));
}
void UnsentLogStoreMetricsImpl::RecordDroppedLogsNum(int dropped_logs_num) {
......
......@@ -10,6 +10,22 @@
namespace metrics {
TEST(UnsentLogStoreMetricsImplTest, RecordDroppedLogSize) {
UnsentLogStoreMetricsImpl impl;
base::HistogramTester histogram_tester;
impl.RecordDroppedLogSize(99999);
histogram_tester.ExpectBucketCount("UMA.UnsentLogs.DroppedSize", 99999, 1);
}
TEST(UnsentLogStoreMetricsImplTest, RecordDroppedLogsNum) {
UnsentLogStoreMetricsImpl impl;
base::HistogramTester histogram_tester;
impl.RecordDroppedLogsNum(17);
histogram_tester.ExpectBucketCount("UMA.UnsentLogs.Dropped", 17, 1);
}
TEST(UnsentLogStoreMetricsImplTest, RecordLastUnsentLogMetadataMetrics) {
base::test::ScopedFeatureList feature_override;
feature_override.InitAndEnableFeature(
......
......@@ -590,6 +590,20 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="UMA.UnsentLogs.DroppedSize" units="bytes"
expires_after="2021-08-30">
<owner>akirabaruah@chromium.org</owner>
<owner>rkaplow@chromium.org</owner>
<owner>asvitkine@chromium.org</owner>
<owner>src/base/metrics/OWNERS</owner>
<summary>
Size of unsent logs removed from persistent storage due to exceeding the
individual log size limit. Unsent log trimming occurs immediately after
initial logs creation, upon successful log upload, or whenever
MetricsService stops recording.
</summary>
</histogram>
<histogram name="UMA.UnsentLogs.PersistedSizeInKB" units="KB"
expires_after="2021-05-30">
<owner>michaelbai@chromium.org</owner>
......
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