[component_metrics] Define escrow started/stopped durations metrics

Bug: b/333078100
Change-Id: Ia23838dc495d6dfab11daf5588e964fb8f95b549
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/1033870
Reviewed-by: Alex Pankhurst <pankhurst@google.com>
Commit-Queue: Yifei Teng <yifeit@google.com>
Reviewed-by: Miguel Flores <miguelfrde@google.com>
Privacy-Approval: Alex Pankhurst <pankhurst@google.com>
diff --git a/fuchsia/component_metrics/metrics.yaml b/fuchsia/component_metrics/metrics.yaml
index a232eb3..d7edb78 100644
--- a/fuchsia/component_metrics/metrics.yaml
+++ b/fuchsia/component_metrics/metrics.yaml
@@ -3,6 +3,11 @@
 # found in the LICENSE file.
 
 metric_definitions:
+
+################################################################################
+# Next Metric ID: 7
+################################################################################
+
 #####################################################################
 # Per-component CPU % each minute
 #
@@ -15,7 +20,7 @@
 # The percentage number [0..100] increments the appropriate bucket of an
 # Inspect occurence-count histogram for each component.
 #
-# Every 5 minutes, Sampler sends a delta of the component CPU % occurrence
+# Every 20 minutes, Sampler sends a delta of the component CPU % occurrence
 # histograms to Cobalt for hourly summation and reporting. This data is
 # currently being reported for most 1p components (after a privacy review).
 # New components may be added in the future, after a privacy review.
@@ -53,7 +58,7 @@
 # When a component crashes, the "exceptions" program records that the
 # crash has happened. Each occurrence of a crash is reported.
 #
-# Every 5 minutes, Sampler sends a delta of the crash counts
+# Every 20 minutes, Sampler sends a delta of the crash counts
 # to Cobalt for components with non-zero crashes. This data will be
 # reported only for components that opt into component_metrics collection.
 #####################################################################
@@ -76,4 +81,80 @@
     max_release_stage: GA
     expiration_date: "2024/11/01"
 
+#####################################################################
+# Per-component started duration under escrow
+#
+# If a component voluntarily stops itself after sending an escrow request
+# to component_manager, component_manager will compute the execution durations
+# each time this component stops, and publish them as an exponential histogram.
+#
+# Every 20 minutes, Sampler sends a delta of this histogram to Cobalt
+# for hourly summation and reporting. This data is currently being
+# reported for most 1p components (after a privacy review).
+# New components may be added in the future, after a privacy review.
+#####################################################################
+- id: 5
+  metric_name: per_component_escrow_started_durations
+  metric_type: INTEGER_HISTOGRAM
+  metric_semantics: [LATENCY]
+  metric_dimensions:
+    - dimension: component
+      max_event_code: 100000 # Supports 100 config files, each with up to 1000 components
+  metric_units: SECONDS
+  int_buckets:
+    exponential:
+      floor: 4
+      num_buckets: 12
+      initial_step: 3
+      step_multiplier: 2
+  reports:
+    - id: 1
+      report_name: fleetwide_histogram
+      report_type: FLEETWIDE_HISTOGRAMS
+      event_vector_buffer_max: 500
+      privacy_level: NO_ADDED_PRIVACY
+      privacy_mechanism: DE_IDENTIFICATION
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, ARCH, SYSTEM_VERSION, OS, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2024/11/01"
+
+#####################################################################
+# Per-component stopped duration under escrow
+#
+# If a component voluntarily stops itself after sending an escrow request
+# to component_manager, component_manager will compute the durations that
+# component remained stopped each time this component is started again,
+# and publish them as a linear histogram.
+#
+# Every 20 minutes, Sampler sends a delta of this histogram to Cobalt
+# for hourly summation and reporting. This data is currently being
+# reported for most 1p components (after a privacy review).
+# New components may be added in the future, after a privacy review.
+#####################################################################
+- id: 6
+  metric_name: per_component_escrow_stopped_durations
+  metric_type: INTEGER_HISTOGRAM
+  metric_semantics: [LATENCY]
+  metric_dimensions:
+    - dimension: component
+      max_event_code: 100000 # Supports 100 config files, each with up to 1000 components
+  metric_units: SECONDS
+  int_buckets:
+    linear:
+      floor: 10
+      num_buckets: 24
+      step_size: 10
+  reports:
+    - id: 1
+      report_name: fleetwide_histogram
+      report_type: FLEETWIDE_HISTOGRAMS
+      event_vector_buffer_max: 500
+      privacy_level: NO_ADDED_PRIVACY
+      privacy_mechanism: DE_IDENTIFICATION
+      system_profile_field: [BOARD_NAME, PRODUCT_NAME, ARCH, SYSTEM_VERSION, OS, CHANNEL]
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2024/11/01"
+
 deleted_metric_ids: [3,4]