[media] Add histograms for Fuchsia audio metrics

Add histograms for Fuchsia audio metrics. Also remove
audio_output_underflow_duration, which has been deprecated.
This metric has not be produced for months.

Fixed: 58121
Change-Id: Iafe11c0150e4b66ff05619ef2bffe841d0699483
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/437254
Reviewed-by: Alexandre Zani <azani@google.com>
Commit-Queue: Tom Bergan <tombergan@google.com>
Privacy-Approval: Alexandre Zani <azani@google.com>
diff --git a/fuchsia/media/metrics.yaml b/fuchsia/media/metrics.yaml
index d490abc..0367da5 100644
--- a/fuchsia/media/metrics.yaml
+++ b/fuchsia/media/metrics.yaml
@@ -8,45 +8,11 @@
 
 metric_definitions:
 
-################################################################################
-# audio_output_underflow_duration
-# TODO(fxbug.dev/58121): this is being deprecated
+#####################################################################
+# Next Metric ID: 9
 #
-# When an output underflow occurs during audio playback, we log its duration in
-# nanoseconds, together with an event_code representing the time since boot.
-################################################################################
-- id: 2
-  metric_name: audio_output_underflow_duration
-  metric_type: ELAPSED_TIME
-
-  metric_dimensions:
-    - dimension: time_since_boot
-      event_codes:
-        0: UpLessThan15s
-        1: UpLessThan30s
-        2: UpLessThan1m
-        3: UpLessThan2m
-        4: UpLessThan4m
-        5: UpLessThan8m
-        6: UpLessThan16m
-        7: UpLessThan32m
-        8: UpLessThan64m
-
-        # 'Overflow' bucket.  Make sure to rename if adding buckets
-        99: UpMoreThan64m
-
-  reports:
-    #####################################################################
-    # audio_output_underflow_duration_stats
-    #####################################################################
-    - report_name: audio_output_underflow_duration_stats
-      id: 4271602451 # legacy long report_id
-      report_type: NUMERIC_AGGREGATION
-      system_profile_field: [BOARD_NAME, PRODUCT_NAME, ARCH, SYSTEM_VERSION, OS, CHANNEL]
-
-  meta_data:
-    max_release_stage: GA
-    expiration_date: "2020/05/07"
+# Reserved: Metric ID 2 (deleted in fxrev.dev/437254)
+#####################################################################
 
 ################################################################################
 # audio_session_duration
@@ -73,6 +39,19 @@
       id: 1
       report_type: NUMERIC_AGGREGATION
       system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+    - report_name: audio_session_duration_histograms
+      id: 2
+      report_type: INT_RANGE_HISTOGRAM
+      system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+      int_buckets: &nanosecond_duration_buckets_one_day
+        exponential:
+          # The effective range is 1ms to 18hr, which allows us to represent sessions
+          # up to about 1 day long. The floor of the largest bucket is 1ms*2^26, or
+          # 67108s, or about 18h.
+          floor: 0
+          num_buckets: 27
+          initial_step: 1000000
+          step_multiplier: 2
 
   meta_data:
     max_release_stage: GA
@@ -96,6 +75,19 @@
       id: 1
       report_type: NUMERIC_AGGREGATION
       system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+    - report_name: audio_overflow_duration_histograms
+      id: 2
+      report_type: INT_RANGE_HISTOGRAM
+      system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+      int_buckets: &nanosecond_duration_buckets_ten_minutes
+        exponential:
+          # The effective range is 1ms to 10min. We expect that overflows and underflows
+          # are typically at most a few seconds long, so this is plenty of precision.
+          # The floor of the largest bucket is 1ms*2^19, or 524s, or about 8min.
+          floor: 0
+          num_buckets: 20
+          initial_step: 1000000
+          step_multiplier: 2
 
   meta_data:
     max_release_stage: GA
@@ -119,6 +111,11 @@
       id: 1
       report_type: NUMERIC_AGGREGATION
       system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+    - report_name: audio_underflow_duration_histograms
+      id: 2
+      report_type: INT_RANGE_HISTOGRAM
+      system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+      int_buckets: *nanosecond_duration_buckets_ten_minutes
 
   meta_data:
     max_release_stage: GA
@@ -145,10 +142,12 @@
         1: Overflow
 
   reports:
-    - report_name: audio_time_since_last_overflow_or_session_start_stats
-      id: 1
-      report_type: NUMERIC_AGGREGATION
+    # Reserved: id 1 (deleted in fxrev.dev/437254)
+    - report_name: audio_time_since_last_overflow_or_session_start_histograms
+      id: 2
+      report_type: INT_RANGE_HISTOGRAM
       system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+      int_buckets: *nanosecond_duration_buckets_one_day
 
   meta_data:
     max_release_stage: GA
@@ -175,10 +174,12 @@
         1: Underflow
 
   reports:
-    - report_name: audio_time_since_last_underflow_or_session_start_stats
-      id: 1
-      report_type: NUMERIC_AGGREGATION
+    # Reserved: id 1 (deleted in fxrev.dev/437254)
+    - report_name: audio_time_since_last_overflow_or_session_start_histograms
+      id: 2
+      report_type: INT_RANGE_HISTOGRAM
       system_profile_field: [ARCH, BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+      int_buckets: *nanosecond_duration_buckets_one_day
 
   meta_data:
     max_release_stage: GA