[connectivity_wlan] Add establish connection metrics

Bug: 77991
Change-Id: I8f43c854d6aae1e18626be75e133b7a53eccfc74
Reviewed-on: https://fuchsia-review.googlesource.com/c/cobalt-registry/+/571263
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Kiet Tran <kiettran@google.com>
Reviewed-by: Steve Fung <stevefung@google.com>
Reviewed-by: Marc Khouri <mnck@google.com>
Privacy-Approval: Steve Fung <stevefung@google.com>
diff --git a/fuchsia/connectivity_wlan/metrics.yaml b/fuchsia/connectivity_wlan/metrics.yaml
index 341216b..24fb596 100644
--- a/fuchsia/connectivity_wlan/metrics.yaml
+++ b/fuchsia/connectivity_wlan/metrics.yaml
@@ -3386,6 +3386,15 @@
   id: 2004
   metric_name: time_ratio_with_no_rx
 
+################################################################################
+# Connection success rate
+#
+# Every day, log connection success rate of the device on that day
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 2005
+  metric_name: connection_success_rate
+
 #############################################
 ### 3XXX - Monitoring metrics (device counts)
 #############################################
@@ -3489,6 +3498,15 @@
   id: 3005
   metric_name: device_with_frequent_no_rx
 
+################################################################################
+# Count of devices with low connection success rate
+#
+# Every day, log a count if the device has low connection success rate.
+################################################################################
+- <<: *device_counts_metric_template
+  id: 3006
+  metric_name: device_with_low_connection_success_rate
+
 #############################################
 ### 4XXX - Statistics metrics (WLAN area)
 #############################################
@@ -3691,7 +3709,8 @@
   id: 4006
   metric_name: disconnect_breakdown_by_primary_channel
   metric_dimensions:
-    - dimension: primary_channel
+    - &primary_channel_dim
+      dimension: primary_channel
       max_event_code: 196
 
 ################################################################################
@@ -3719,6 +3738,240 @@
     max_release_stage: GA
     expiration_date: "2022/08/01"
 
+################################################################################
+# Connect attempt breakdown by status code
+#
+# When a client makes a connection attempt, log the status code.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4008
+  metric_name: connect_attempt_breakdown_by_status_code
+  metric_dimensions:
+    - &status_code_dim
+      dimension: status_code
+      max_event_code: 1000
+
+################################################################################
+# Connect attempt on normal device breakdown by status code
+#
+# Once each day, check if the device has normal connection success rate. If it
+# does, log all the status code of all the connection attempts it has made
+# that day.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4009
+  metric_name: connect_attempt_on_normal_device_breakdown_by_status_code
+  metric_dimensions:
+    - *status_code_dim
+
+################################################################################
+# Connect attempt on bad device breakdown by status code
+#
+# Once each day, check if the device has low connection success rate. If it
+# does, log all the status code of all the connection attempts it has made
+# that day.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4010
+  metric_name: connect_attempt_on_bad_device_breakdown_by_status_code
+  metric_dimensions:
+    - *status_code_dim
+
+################################################################################
+# Successful connect breakdown by user wait time
+#
+# On connect success, log the duration the user has waited, including the
+# time of network selection and all the retries.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4011
+  metric_name: successful_connect_breakdown_by_user_wait_time
+  metric_dimensions:
+    - dimension: wait_time
+      event_codes:
+        1: LessThan1Second
+        2: LessThan3Seconds
+        3: LessThan5Seconds
+        4: LessThan8Seconds
+        5: LessThan15Seconds
+        6: AtLeast15Seconds
+
+################################################################################
+# Successful connect breakdown by is_multi_bss
+#
+# On connect success, log whether there are multiple BSS in the ESS.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4012
+  metric_name: successful_connect_breakdown_by_is_multi_bss
+  metric_dimensions:
+    - &is_multi_bss_dim
+      dimension: is_multi_bss
+      event_codes:
+        1: "Yes"
+        2: "No"
+
+################################################################################
+# Successful connect breakdown by BSS security type
+#
+# On connect success, log the security type of the BSS.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4013
+  metric_name: successful_connect_breakdown_by_security_type
+  metric_dimensions:
+    - &security_type_dim
+      dimension: security_type
+      event_codes: *protections
+
+################################################################################
+# Successful connect breakdown by WLAN primary channel
+#
+# On connect success, log the WLAN primary channel.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4014
+  metric_name: successful_connect_breakdown_by_primary_channel
+  metric_dimensions:
+    - *primary_channel_dim
+
+################################################################################
+# Successful connect breakdown by WLAN channel band
+#
+# On connect success, log the WLAN channel band.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4015
+  metric_name: successful_connect_breakdown_by_channel_band
+  metric_dimensions:
+    - &channel_band_dim
+      dimension: channel_band
+      event_codes:
+        1: Band2Dot4Ghz
+        2: Band5Ghz
+
+################################################################################
+# Successful connect breakdown by RSSI bucket
+#
+# On connect success, log the RSSI bucket.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4016
+  metric_name: successful_connect_breakdown_by_rssi_bucket
+  metric_dimensions:
+    - &rssi_bucket_dim
+      dimension: rssi_bucket
+      event_codes:
+        1: From128To90
+        2: From89To86
+        3: From85To83
+        4: From82To80
+        5: From79To77
+        6: From76To74
+        7: From73To71
+        8: From70To66
+        9: From65To61
+        10: From60To51
+        11: From50To35
+        # RSSI greater than -35dBm is considered too strong, which degrades
+        # throughput performance:
+        # https://helpcenter.engeniustech.com/hc/en-us/articles/360015304031-Outdoor-RSSI-and-Acceptable-Signal-Strength
+        12: From34To28
+        13: From27To1
+        14: "0"
+
+################################################################################
+# Successful connect breakdown by SNR bucket
+#
+# On connect success, log the SNR bucket.
+################################################################################
+- <<: *detailed_occurrence_metric_template
+  id: 4017
+  metric_name: successful_connect_breakdown_by_snr_bucket
+  metric_dimensions:
+    - &snr_bucket_dim
+      dimension: snr_bucket
+      event_codes:
+        1: "0"
+        2: From1To10
+        3: From11To15
+        4: From16To25
+        5: From26To40
+        6: MoreThan40
+
+################################################################################
+# Connect success rate per day breakdown by is_multi_bss
+#
+# Every day, separately compute the device's daily connect success rate on
+# networks that have multiple BSS and networks that have single BSS. Log a
+# number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4018
+  metric_name: daily_connect_success_rate_breakdown_by_is_multi_bss
+  metric_dimensions:
+    - *is_multi_bss_dim
+
+################################################################################
+# Connect success rate per day breakdown by security type
+#
+# Every day, separately compute the device's daily connect success rate for
+# each security type of encountered networks. Log a number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4019
+  metric_name: daily_connect_success_rate_breakdown_by_security_type
+  metric_dimensions:
+    - *security_type_dim
+
+################################################################################
+# Connect success rate per day breakdown by primary channel
+#
+# Every day, separately compute the device's daily connect success rate for
+# each primary channel of encountered networks. Log a number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4020
+  metric_name: daily_connect_success_rate_breakdown_by_primary_channel
+  metric_dimensions:
+    - *primary_channel_dim
+
+################################################################################
+# Connect success rate per day breakdown by channel band
+#
+# Every day, separately compute the device's daily connect success rate for
+# each channel band of encountered networks. Log a number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4021
+  metric_name: daily_connect_success_rate_breakdown_by_channel_band
+  metric_dimensions:
+    - *channel_band_dim
+
+################################################################################
+# Connect success rate per day breakdown by rssi bucket
+#
+# Every day, separately compute the device's daily connect success rate for
+# each rssi bucket of encountered networks. Log a number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4022
+  metric_name: daily_connect_success_rate_breakdown_by_rssi_bucket
+  metric_dimensions:
+    - *rssi_bucket_dim
+
+################################################################################
+# Connect success rate per day breakdown by snr bucket
+#
+# Every day, separately compute the device's daily connect success rate for
+# each snr bucket of encountered networks. Log a number for each dimension
+################################################################################
+- <<: *device_log_local_ratio_once_daily_monitoring_metric_template
+  id: 4023
+  metric_name: daily_connect_success_rate_breakdown_by_snr_bucket
+  metric_dimensions:
+    - *snr_bucket_dim
+
 ##################################################
 ### 5XXX - Statistics metrics (Usage distribution)
 ##################################################
@@ -3726,24 +3979,26 @@
 ################################################################################
 # Number of WiFi-connected devices
 #
-# When a client connects to an AP, log the occurrence. The resulting report
-# is the number of connected device.
+# When a client connects to an AP, log the occurrence. Every day, if the
+# client is still connected, log at least one occurrence.
+#
+# The resulting report is the number of connected device.
 ################################################################################
 - <<: *device_counts_metric_template
   id: 5000
   metric_name: number_of_connected_devices
 
 ################################################################################
-# Connected network security type
+# Device connected to AP with security type
 #
 # When a client connects to an AP, log the security type of that network.
+# Every day, if the client is still connected, log at least one occurrence.
 ################################################################################
 - <<: *device_counts_metric_template
   id: 5001
   metric_name: connected_network_security_type
   metric_dimensions:
-    - dimension: security_type
-      event_codes: *protections
+    - *security_type_dim
 
 ################################################################################
 # Device connected to an AP that supports APSD
@@ -3782,3 +4037,38 @@
 - <<: *device_counts_metric_template
   id: 5006
   metric_name: device_connected_to_ap_that_supports_bss_transition_management
+
+################################################################################
+# Device connected to AP breakdown by is_multi_bss
+################################################################################
+- <<: *device_counts_metric_template
+  id: 5007
+  metric_name: device_connected_to_ap_breakdown_by_is_multi_bss
+  metric_dimensions:
+    - *is_multi_bss_dim
+
+################################################################################
+# Device connected to AP breakdown by primary channel
+#
+# When a client connects to an AP, log primary channel it's on. On channel
+# switch, log the new primary channel. Every day, if the client is still
+# connected, log at least one occurrence.
+################################################################################
+- <<: *device_counts_metric_template
+  id: 5008
+  metric_name: device_connected_to_ap_breakdown_by_primary_channel
+  metric_dimensions:
+    - *primary_channel_dim
+
+################################################################################
+# Device connected to AP breakdown by channel band
+#
+# When a client connects to an AP, log channel band it's on. On channel
+# switch, log the (potentially) new channel band. Every day, if the client
+# is still connected, log at least one occurrence.
+################################################################################
+- <<: *device_counts_metric_template
+  id: 5009
+  metric_name: device_connected_to_ap_breakdown_by_channel_band
+  metric_dimensions:
+    - *channel_band_dim