diff --git a/components/metrics/histogram_encoder.cc b/components/metrics/histogram_encoder.cc index f816807db92ee..595fb5398674c 100644 --- a/components/metrics/histogram_encoder.cc +++ b/components/metrics/histogram_encoder.cc @@ -25,7 +25,8 @@ void EncodeHistogramDelta(const std::string& histogram_name, HistogramEventProto* histogram_proto = uma_proto->add_histogram_event(); histogram_proto->set_name_hash(base::HashMetricName(histogram_name)); - histogram_proto->set_sum(snapshot.sum()); + if (snapshot.sum() != 0) + histogram_proto->set_sum(snapshot.sum()); for (scoped_ptr it = snapshot.Iterator(); !it->Done(); it->Next()) { @@ -36,7 +37,9 @@ void EncodeHistogramDelta(const std::string& histogram_name, HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket(); bucket->set_min(min); bucket->set_max(max); - bucket->set_count(count); + // Note: The default for count is 1 in the proto, so omit it in that case. + if (count != 1) + bucket->set_count(count); } // Omit fields to save space (see rules in histogram_event.proto comments). diff --git a/components/metrics/proto/histogram_event.proto b/components/metrics/proto/histogram_event.proto index 4b68094ff6dfa..8b054172eae91 100644 --- a/components/metrics/proto/histogram_event.proto +++ b/components/metrics/proto/histogram_event.proto @@ -20,7 +20,8 @@ message HistogramEventProto { // The sum of all the sample values. // Together with the total count of the sample values, this allows us to // compute the average value. The count of all sample values is just the sum - // of the counts of all the buckets. + // of the counts of all the buckets. As of M51, when the value of this field + // would be 0, the field will be omitted instead. optional int64 sum = 2; // The per-bucket data. @@ -40,8 +41,9 @@ message HistogramEventProto { // clients to reduce the UMA upload size. optional int32 bucket_index = 3 [deprecated = true]; - // The number of entries in this bucket. - optional int64 count = 4; + // The number of entries in this bucket. As of M51, when the value of this + // field would be 1, the field will be omitted instead. + optional int64 count = 4 [default = 1]; } repeated Bucket bucket = 3; }