[storage] Add out of space events

Add per-device histogram tracking the amount of times we run out of
space on device, indicated by failures to extend the underlying volume.

Add histogram to track the effectiveness of the mitigation added in
fxbug.dev/88364 to attempt to recover more space before failing.

Bug: 89583
Bug: 89874
Test: Tested locally to ensure events were logged & recorded by Cobalt.
Change-Id: I4118470462cced1d53c67a93d4f06c39f08d73a1
diff --git a/fuchsia/local_storage/metrics.yaml b/fuchsia/local_storage/metrics.yaml
index ef46c09..489f935 100644
--- a/fuchsia/local_storage/metrics.yaml
+++ b/fuchsia/local_storage/metrics.yaml
@@ -2458,7 +2458,41 @@
     max_release_stage: GA
     expiration_date: "2022/09/21"
 
-# Next ID: 4008
+
+################################################################################
+# Out-Of-Space Events
+#
+# Per-filesystem count of times a device fails to extend the underlying volume
+# after running out of space.
+#
+# Can only increase at most 1 every 5 minutes, so the daily max is 288.
+################################################################################
+- id: 4008
+  metric_name: out_of_space_events
+  metric_type: OCCURRENCE
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions:
+    - *source_dimension
+  reports:
+    - report_name: per_device_daily_counts
+      id: 1
+      report_type: UNIQUE_DEVICE_HISTOGRAMS
+      system_profile_selection: SELECT_LAST
+      local_aggregation_period: WINDOW_1_DAY
+      int_buckets:
+        exponential:
+          # 0, 1, 2, 4, 8... 64, 128, 256
+          floor: 0
+          num_buckets: 10
+          initial_step: 1
+          step_multiplier: 2
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/12/01"
+
+# Next ID: 4009
 
 ################################################################################
 
@@ -2512,4 +2546,38 @@
     max_release_stage: GA
     expiration_date: "2022/09/20"
 
-# Next ID: 9004
+################################################################################
+# Recovered Out-Of-Space Events
+#
+# Indicates a successful volume extension after performing a corrective action.
+# Used to track how many times a filesystem was successfully able to recover
+# from a volume extension failure (e.g. by force-flushing the journal).
+#
+# Can only increase at most 1 every 5 minutes, so the daily max is 288.
+################################################################################
+- id: 9004
+  metric_name: recovered_space_from_sync_events
+  metric_type: OCCURRENCE
+  metric_semantics: [USAGE_COUNTING]
+  metric_dimensions:
+    - *source_dimension
+  reports:
+    - report_name: per_device_daily_counts
+      id: 1
+      report_type: UNIQUE_DEVICE_HISTOGRAMS
+      system_profile_selection: SELECT_LAST
+      local_aggregation_period: WINDOW_1_DAY
+      int_buckets:
+        exponential:
+          # 0, 1, 2, 4, 8... 64, 128, 256
+          floor: 0
+          num_buckets: 10
+          initial_step: 1
+          step_multiplier: 2
+      privacy_level: NO_ADDED_PRIVACY
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, SYSTEM_VERSION, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/12/01"
+
+# Next ID: 9005