[connectivity_wlan] reconnect, DPDC roam metrics

This adds metrics for comparing the time it takes to reconnect after
disconnecting for roaming vs. non-roaming disconnects. It also adds
metrics for the disconnects per day connected for roaming disconnects
and non-roaming disconnects.

Change-Id: Ic5ebd171e95394ff7e4947c5bb123550827ffd00
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/621841
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 d1a9605..69f1a07 100644
--- a/fuchsia/connectivity_wlan/metrics.yaml
+++ b/fuchsia/connectivity_wlan/metrics.yaml
@@ -3286,19 +3286,20 @@
 # Whenever a client has disconnected from an AP, log the occurrence.
 ################################################################################
 - id: 1002
-  metric_type: OCCURRENCE
-  metric_semantics: [NETWORK_COMMUNICATION, USAGE_COUNTING]
   metric_name: total_disconnect_count
-  reports:
-    - id: 1
-      <<: &fleetwide_occurrence_counts_report
-        report_name: fleetwide_occurrence_counts
-        report_type: FLEETWIDE_OCCURRENCE_COUNTS
-        privacy_level: NO_ADDED_PRIVACY
-        system_profile_field: [BOARD_NAME, CHANNEL, SYSTEM_VERSION]
-  meta_data:
-    max_release_stage: GA
-    expiration_date: "2022/08/01"
+  <<: &total_occurrence_counts_template
+    metric_type: OCCURRENCE
+    metric_semantics: [NETWORK_COMMUNICATION, USAGE_COUNTING]
+    reports:
+      - id: 1
+        <<: &fleetwide_occurrence_counts_report
+          report_name: fleetwide_occurrence_counts
+          report_type: FLEETWIDE_OCCURRENCE_COUNTS
+          privacy_level: NO_ADDED_PRIVACY
+          system_profile_field: [BOARD_NAME, CHANNEL, SYSTEM_VERSION]
+    meta_data:
+      max_release_stage: GA
+      expiration_date: "2022/08/01"
 
 ################################################################################
 # Time with high RX packet drop
@@ -3350,6 +3351,26 @@
   id: 1007
   metric_name: total_time_with_very_high_tx_packet_drop
 
+################################################################################
+# Total number of roaming disconnects
+#
+# Whenever a client has disconnected from an AP to roam, log the occurrence.
+################################################################################
+- id: 1008
+  metric_name: total_roaming_disconnect_count
+  <<: *total_occurrence_counts_template
+
+################################################################################
+# Total number of non-roaming disconnects
+#
+# Whenever a client has disconnected from an AP because of a lost connection,
+# log the occurrence. These are the disconnects that don't happen for roaming
+# and exclude manual user interactions.
+################################################################################
+- id: 1009
+  metric_name: total_non_roaming_disconnect_count
+  <<: *total_occurrence_counts_template
+
 #############################
 ### 2XXX - Monitoring metrics
 #############################
@@ -3461,6 +3482,32 @@
   id: 2007
   metric_name: time_ratio_with_very_high_tx_packet_drop
 
+
+################################################################################
+# Roaming disconnect per day connected
+#
+# Every day, before the end of the day UTC time, log the roaming disconnect per
+# day connected ratio for that day (# of roaming disconnects / time connected
+# in day). Roaming disconnects happen when the device decides to proactively
+# leave to join another network.
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 2008
+  metric_name: roaming_disconnect_per_day_connected
+
+################################################################################
+# Non roaming disconnect per day connected
+#
+# Every day, before the end of the day UTC time, log the non-roaming disconnect
+# per day connected ratio for that day (# of non-roaming disconnects / time
+# connected in day). Non roaming disconnects do not include disconnects from
+# manual user actions, since they are not useful for comparing to the number of
+# roaming disconnects.
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 2009
+  metric_name: non_roaming_disconnect_per_day_connected
+
 #############################################
 ### 3XXX - Monitoring metrics (device counts)
 #############################################
@@ -3595,6 +3642,26 @@
   id: 3008
   metric_name: device_with_frequent_very_high_tx_packet_drop
 
+################################################################################
+# Count of devices with high roaming disconnect rate
+#
+# Every day, log a count if a device has high roam disconnect rate on that day.
+################################################################################
+- <<: *device_counts_metric_template
+  id: 3009
+  metric_name: device_with_high_roaming_disconnect_rate
+
+################################################################################
+# Count of devices with high disconnect rate
+#
+# Every day, log a count if a device has high disconnect rate from non-roaming
+# disconnects on that day. This does not include disconnects that happen from
+# manual user interactions such as stopping all client connections.
+################################################################################
+- <<: *device_counts_metric_template
+  id: 3010
+  metric_name: device_with_high_non_roaming_disconnect_rate
+
 #############################################
 ### 4XXX - Statistics metrics (WLAN area)
 #############################################
@@ -4287,6 +4354,58 @@
     max_release_stage: GA
     expiration_date: "2022/08/01"
 
+################################################################################
+# Roaming reconnect time
+#
+# Log how long it takes to reconnect to the new network after disconnecting
+# from the previous network when roaming. The time is logged in microseconds,
+# up to 60 seconds with .1 second histogram buckets.
+################################################################################
+- id: 4035
+  metric_name: roaming_reconnect_duration
+  metric_type: INTEGER
+  metric_units: MICROSECONDS
+  metric_semantics: [NETWORK_COMMUNICATION]
+  reports:
+    - id: 1
+      <<: *default_fleetwide_histograms_report_name
+      <<: *fleetwide_histograms_report
+      int_buckets:
+        linear:
+          floor: 0
+          num_buckets: 600
+          step_size: 100000
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/08/01"
+
+################################################################################
+# Non roaming reconnect time
+#
+# Log how long it takes to connect after a disconnect that didn't happen for
+# roaming. This metric matches roaming reconnect time so that the two can
+# be compared. Non roaming disconnects include loss of signal or the AP ending
+# the connection. The time is logged in microseconds, up to 60 seconds with .1
+# second histogram buckets.
+################################################################################
+- id: 4036
+  metric_name: non_roaming_reconnect_duration
+  metric_type: INTEGER
+  metric_units: MICROSECONDS
+  metric_semantics: [NETWORK_COMMUNICATION]
+  reports:
+    - id: 1
+      <<: *default_fleetwide_histograms_report_name
+      <<: *fleetwide_histograms_report
+      int_buckets:
+        linear:
+          floor: 0
+          num_buckets: 600
+          step_size: 100000
+  meta_data:
+    max_release_stage: GA
+    expiration_date: "2022/08/01"
+
 ##################################################
 ### 5XXX - Statistics metrics (Usage distribution)
 ##################################################