[connectivity_wlan] add roaming metrics

Add basic metrics to analyze roaming. The included metrics will give
information on how often roaming happens, and information about signal
strength of connections which is the primary factor in roaming decisions
initially.

Bug: 87916
Change-Id: I96e7095a179b4ac4ee55fcd10e28c75a3ccab383
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/602222
Reviewed-by: Kiet Tran <kiettran@google.com>
Reviewed-by: Steve Fung <stevefung@google.com>
Privacy-Approval: Steve Fung <stevefung@google.com>
Commit-Queue: Naomi Mccracken <nmccracken@google.com>
diff --git a/fuchsia/connectivity_wlan/metrics.yaml b/fuchsia/connectivity_wlan/metrics.yaml
index fff82a0..d1a9605 100644
--- a/fuchsia/connectivity_wlan/metrics.yaml
+++ b/fuchsia/connectivity_wlan/metrics.yaml
@@ -4107,6 +4107,186 @@
         4: LessThan30Seconds
         5: AtLeast30Seconds
 
+################################################################################
+# Roaming scans per day
+#
+# Log when policy decides to perform a scan to look for networks to roam to.
+# Report how many of these scans devices do each day.
+################################################################################
+- id: 4026
+  metric_name: policy_proactive_roaming_scan_counts
+  metric_type: OCCURRENCE
+  metric_semantics: [NETWORK_COMMUNICATION, USAGE_COUNTING]
+  reports:
+    - id: 1
+      # Use this name if there is only one such report for the metric.
+      <<: &default_device_daily_occurrence_histograms_report_name
+        report_name: device_daily_occurrence_histograms
+      <<: &device_daily_histograms_report
+        report_type: UNIQUE_DEVICE_HISTOGRAMS
+        system_profile_selection: SELECT_LAST
+        local_aggregation_period: WINDOW_1_DAY
+        privacy_level: NO_ADDED_PRIVACY
+        system_profile_field: [BOARD_NAME, CHANNEL, SYSTEM_VERSION]
+      int_buckets:
+        linear:
+          floor: 0
+          num_buckets: 150
+          step_size: 1
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/08/01"
+
+################################################################################
+# Roaming proactive network switches per day
+#
+# Log when a device decides to leave the current AP and attempt to connect to
+# another one. Report how many times each device does this each day.
+################################################################################
+- id: 4027
+  metric_name: network_roaming_disconnect_counts
+  <<: &disconnect_counts_metric
+    metric_type: OCCURRENCE
+    metric_semantics: [NETWORK_COMMUNICATION, USAGE_COUNTING]
+    reports:
+      - id: 1
+        <<: *default_device_daily_occurrence_histograms_report_name
+        <<: *device_daily_histograms_report
+        int_buckets:
+          linear:
+            floor: 0
+            num_buckets: 24
+            step_size: 1
+    meta_data:
+      max_release_stage: GA
+      expiration_date: "2022/08/01"
+
+################################################################################
+# Non-roaming disconnects per day
+#
+# Log when a device disconnects, but not because of roaming. This does not
+# include disconnects from a user forgetting a network or manually connecting
+# to a new one.
+################################################################################
+- id: 4028
+  metric_name: network_non_roaming_disconnect_counts
+  <<: *disconnect_counts_metric
+
+################################################################################
+# All disconnects per day
+#
+# Log when a device disconnects for any reason. The histogram buckets match
+# roaming disconnect counts so that the numbers can be compared.
+################################################################################
+- id: 4029
+  metric_name: network_disconnect_counts
+  <<: *disconnect_counts_metric
+
+################################################################################
+# Connection uptime before roam
+#
+# When a decision to roam happens, log how long the current connection has been
+# up. The unit for the metric is in minutes. The range of recorded time is
+# 0 - 6 hours.
+################################################################################
+- id: 4030
+  metric_name: connected_duration_before_roaming_disconnect
+  <<: &connected_duration_before_disconnect_metric
+    metric_type: INTEGER
+    metric_units: MINUTES
+    metric_semantics: [NETWORK_COMMUNICATION]
+    reports:
+      - id: 1
+        <<: &default_fleetwide_histograms_report_name
+          report_name: fleetwide_histograms
+        <<: &fleetwide_histograms_report
+          report_type: FLEETWIDE_HISTOGRAMS
+          privacy_level: NO_ADDED_PRIVACY
+          system_profile_field: [BOARD_NAME, CHANNEL, SYSTEM_VERSION]
+        int_buckets:
+          linear:
+            floor: 0
+            num_buckets: 360
+            step_size: 1
+    meta_data:
+      max_release_stage: GA
+      expiration_date: "2022/08/01"
+
+################################################################################
+# Connection uptime before non-roam disconnect
+#
+# When a disconnect happens, log how long the current connection has been up.
+# The unit for the metric is in minutes. The recorded duration buckets match
+# the ones used for roam connected durations in order to compare the two.
+################################################################################
+- id: 4031
+  metric_name: connected_duration_before_non_roaming_disconnect
+  <<: *connected_duration_before_disconnect_metric
+
+################################################################################
+# Connection uptime before disconnect
+#
+# When any disconnect happens, log how long the current connection has been up.
+################################################################################
+- id: 4032
+  metric_name: connected_duration_before_disconnect
+  <<: *connected_duration_before_disconnect_metric
+
+################################################################################
+# Connection RSSI values
+#
+# The RSSI values of the AP that the device is connected to. This RSSI value is
+# collected every second and all collected values are aggregated as a histogram
+# and periodically sent to cobalt. The values are reported for the entire fleet
+# in order to get an idea of the signal strength of the fleet's connections and
+# see whether changes cause general improvements or worsening of signal
+# strength of the networks chosen by devices.
+################################################################################
+- id: 4033
+  metric_name: connection_rssi
+  metric_type: INTEGER_HISTOGRAM
+  metric_units_other: "dBm"
+  metric_semantics: [NETWORK_COMMUNICATION]
+  int_buckets:
+    linear:
+      floor: -128
+      num_buckets: 129
+      step_size: 1
+  reports:
+    - id: 1
+      <<: *default_fleetwide_histograms_report_name
+      <<: *fleetwide_histograms_report
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/08/01"
+
+################################################################################
+# RSSI velocity
+#
+# RSSI velocity, or change in RSSI per second, is estimated for the current
+# connection based on regular RSSI readings. The unit of RSSI velocity is dBm/s
+# and will be converted to dBm/s even if the interval used to calculate RSSI
+# velocity isn't 1 second.
+################################################################################
+- id: 4034
+  metric_name: rssi_velocity
+  metric_type: INTEGER_HISTOGRAM
+  metric_units_other: "dBm/s"
+  metric_semantics: [NETWORK_COMMUNICATION]
+  int_buckets:
+    linear:
+      floor: -10
+      num_buckets: 21
+      step_size: 1
+  reports:
+    - id: 1
+      <<: *default_fleetwide_histograms_report_name
+      <<: *fleetwide_histograms_report
+
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/08/01"
+
 ##################################################
 ### 5XXX - Statistics metrics (Usage distribution)
 ##################################################
@@ -4238,4 +4418,4 @@
         system_profile_field: [BOARD_NAME, CHANNEL, SYSTEM_VERSION]
     meta_data:
       max_release_stage: GA
-      expiration_date: "2022/08/01"
+      expiration_date: "2022/08/01"
\ No newline at end of file