Log bucket drop reasons for ValueMetric and GaugeMetric

- For all cases where ValueMetric and GaugeMetric drop buckets, we will
log the reason for the drop and the timestamp of the drop event. All the
cases where ValueMetric drops buckets is documented in
go/valuemetric-bucketdropping. GaugeMetric only drops buckets when the
size of the bucket is less than the specified minimum bucket size.
- Dropped/skipped bucket data structures have been moved to
MetricProducer so all metrics can potentially log bucket drop cases.
- Added unit tests for ValueMetricProducer and GaugeMetricProducer to
check that all bucket drop cases can be logged and the number of drop
events is capped at 10 for one skipped bucket.
- ***Could not test drops due to a pull delay because pull delays are
measured by real elapsed time in #accumulateEvents.

Test: bit statsd_test:*
Bug: 145836670
Bug: 140421050
Bug: 146082150
Bug: 146082276
Change-Id: I0197660bf89837162330aeaafb5397c7328e3993
diff --git a/cmds/statsd/src/stats_log.proto b/cmds/statsd/src/stats_log.proto
index e45e24fe..8b4d781 100644
--- a/cmds/statsd/src/stats_log.proto
+++ b/cmds/statsd/src/stats_log.proto
@@ -191,11 +191,40 @@
 
   // Fields 2 and 3 are reserved.
 
+  // Keep this in sync with BucketDropReason enum in MetricProducer.h.
+  enum BucketDropReason {
+      // For ValueMetric, a bucket is dropped during a dump report request iff
+      // current bucket should be included, a pull is needed (pulled metric and
+      // condition is true), and we are under fast time constraints.
+      DUMP_REPORT_REQUESTED = 1;
+      EVENT_IN_WRONG_BUCKET = 2;
+      CONDITION_UNKNOWN = 3;
+      PULL_FAILED = 4;
+      PULL_DELAYED = 5;
+      DIMENSION_GUARDRAIL_REACHED = 6;
+      MULTIPLE_BUCKETS_SKIPPED = 7;
+      // Not an invalid bucket case, but the bucket is dropped.
+      BUCKET_TOO_SMALL = 8;
+  };
+
+  message DropEvent {
+      optional BucketDropReason drop_reason = 1;
+
+      optional int64 drop_time_millis = 2;
+  }
+
   message SkippedBuckets {
       optional int64 start_bucket_elapsed_nanos = 1;
+
       optional int64 end_bucket_elapsed_nanos = 2;
+
       optional int64 start_bucket_elapsed_millis = 3;
+
       optional int64 end_bucket_elapsed_millis = 4;
+
+      // The number of drop events is capped by StatsdStats::kMaxLoggedBucketDropEvents.
+      // The current maximum is 10 drop events.
+      repeated DropEvent drop_event = 5;
   }
 
   message EventMetricDataWrapper {