Commit 120b8784 authored by Andre Le's avatar Andre Le Committed by Chromium LUCI CQ

[CrOS PhoneHub] Add metrics for connection result in SecureChannel.

Add MultiDevice.SecureChannel.Nearby.ConnectionResult

Bug: 1106937, 1150634
Change-Id: I24a807a5de0e9322ae9e53ed6bf6290f0fa30861
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575516
Commit-Queue: Andre Le <leandre@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834825}
parent 12010682
...@@ -79,6 +79,8 @@ static_library("secure_channel") { ...@@ -79,6 +79,8 @@ static_library("secure_channel") {
"connection_attempt_details.h", "connection_attempt_details.h",
"connection_details.cc", "connection_details.cc",
"connection_details.h", "connection_details.h",
"connection_metrics_logger.cc",
"connection_metrics_logger.h",
"connection_observer.h", "connection_observer.h",
"connection_role.cc", "connection_role.cc",
"connection_role.h", "connection_role.h",
...@@ -98,8 +100,6 @@ static_library("secure_channel") { ...@@ -98,8 +100,6 @@ static_library("secure_channel") {
"error_tolerant_ble_advertisement_impl.h", "error_tolerant_ble_advertisement_impl.h",
"foreground_eid_generator.cc", "foreground_eid_generator.cc",
"foreground_eid_generator.h", "foreground_eid_generator.h",
"latency_metrics_logger.cc",
"latency_metrics_logger.h",
"multiplexed_channel.cc", "multiplexed_channel.cc",
"multiplexed_channel.h", "multiplexed_channel.h",
"multiplexed_channel_impl.cc", "multiplexed_channel_impl.cc",
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "chromeos/services/secure_channel/ble_listener_failure_type.h" #include "chromeos/services/secure_channel/ble_listener_failure_type.h"
#include "chromeos/services/secure_channel/ble_scanner_impl.h" #include "chromeos/services/secure_channel/ble_scanner_impl.h"
#include "chromeos/services/secure_channel/ble_weave_client_connection.h" #include "chromeos/services/secure_channel/ble_weave_client_connection.h"
#include "chromeos/services/secure_channel/latency_metrics_logger.h" #include "chromeos/services/secure_channel/connection_metrics_logger.h"
#include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h" #include "chromeos/services/secure_channel/public/mojom/secure_channel.mojom.h"
#include "chromeos/services/secure_channel/secure_channel_disconnector.h" #include "chromeos/services/secure_channel/secure_channel_disconnector.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h" #include "device/bluetooth/public/cpp/bluetooth_uuid.h"
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chromeos/services/secure_channel/ble_listener_operation.h" #include "chromeos/services/secure_channel/ble_listener_operation.h"
#include "chromeos/services/secure_channel/latency_metrics_logger.h" #include "chromeos/services/secure_channel/connection_metrics_logger.h"
namespace chromeos { namespace chromeos {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/services/secure_channel/latency_metrics_logger.h" #include "chromeos/services/secure_channel/connection_metrics_logger.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
...@@ -23,6 +23,12 @@ const int kNumMetricsBuckets = 100; ...@@ -23,6 +23,12 @@ const int kNumMetricsBuckets = 100;
} // namespace } // namespace
void LogNearbyInitiatorConnectionResult(
NearbyInitiatorConnectionResult connection_result) {
base::UmaHistogramEnumeration(
"MultiDevice.SecureChannel.Nearby.ConnectionResult", connection_result);
}
void LogLatencyMetric(const std::string& metric_name, void LogLatencyMetric(const std::string& metric_name,
const base::TimeDelta& duration) { const base::TimeDelta& duration) {
base::UmaHistogramCustomTimes(metric_name, duration, kMinLatencyDuration, base::UmaHistogramCustomTimes(metric_name, duration, kMinLatencyDuration,
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_SECURE_CHANNEL_LATENCY_METRICS_LOGGER_H_ #ifndef CHROMEOS_SERVICES_SECURE_CHANNEL_CONNECTION_METRICS_LOGGER_H_
#define CHROMEOS_SERVICES_SECURE_CHANNEL_LATENCY_METRICS_LOGGER_H_ #define CHROMEOS_SERVICES_SECURE_CHANNEL_CONNECTION_METRICS_LOGGER_H_
#include <string> #include <string>
...@@ -13,6 +13,24 @@ namespace chromeos { ...@@ -13,6 +13,24 @@ namespace chromeos {
namespace secure_channel { namespace secure_channel {
// Enumeration of possible connection result when connecting via Nearby
// Connection library. Keep in sync with corresponding enum in
// tools/metrics/histograms/enums.xml. These values are persisted to logs.
// Entries should not be renumbered and numeric values should never be reused.
enum class NearbyInitiatorConnectionResult {
kConnectionSuccess = 0,
kTimeoutDiscoveringDevice = 1,
kNearbyApiError = 2,
kConnectionRejected = 3,
kConnectivityError = 4,
kAuthenticationError = 5,
kMaxValue = kAuthenticationError,
};
// Logs a given connection result.
void LogNearbyInitiatorConnectionResult(
NearbyInitiatorConnectionResult connection_result);
// Logs metrics related to connection latencies. This function should be // Logs metrics related to connection latencies. This function should be
// utilized instead of the default UMA_HISTOGRAM_TIMES() macro because it // utilized instead of the default UMA_HISTOGRAM_TIMES() macro because it
// provides custom bucket sizes (e.g., UMA_HISTOGRAM_TIMES() only allows // provides custom bucket sizes (e.g., UMA_HISTOGRAM_TIMES() only allows
...@@ -25,4 +43,4 @@ void LogLatencyMetric(const std::string& metric_name, ...@@ -25,4 +43,4 @@ void LogLatencyMetric(const std::string& metric_name,
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_SERVICES_SECURE_CHANNEL_LATENCY_METRICS_LOGGER_H_ #endif // CHROMEOS_SERVICES_SECURE_CHANNEL_CONNECTION_METRICS_LOGGER_H_
...@@ -7,12 +7,33 @@ ...@@ -7,12 +7,33 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "chromeos/services/secure_channel/authenticated_channel.h" #include "chromeos/services/secure_channel/authenticated_channel.h"
#include "chromeos/services/secure_channel/connection_metrics_logger.h"
#include "chromeos/services/secure_channel/nearby_connection_manager.h" #include "chromeos/services/secure_channel/nearby_connection_manager.h"
namespace chromeos { namespace chromeos {
namespace secure_channel { namespace secure_channel {
namespace {
NearbyInitiatorConnectionResult GetMetricsConnectionResult(
NearbyInitiatorFailureType failure_type) {
switch (failure_type) {
case NearbyInitiatorFailureType::kTimeoutDiscoveringDevice:
return NearbyInitiatorConnectionResult::kTimeoutDiscoveringDevice;
case NearbyInitiatorFailureType::kNearbyApiError:
return NearbyInitiatorConnectionResult::kNearbyApiError;
case NearbyInitiatorFailureType::kConnectionRejected:
return NearbyInitiatorConnectionResult::kConnectionRejected;
case NearbyInitiatorFailureType::kConnectivityError:
return NearbyInitiatorConnectionResult::kConnectivityError;
case NearbyInitiatorFailureType::kAuthenticationError:
return NearbyInitiatorConnectionResult::kAuthenticationError;
}
}
} // namespace
// static // static
NearbyInitiatorOperation::Factory* NearbyInitiatorOperation::Factory*
NearbyInitiatorOperation::Factory::test_factory_ = nullptr; NearbyInitiatorOperation::Factory::test_factory_ = nullptr;
...@@ -92,11 +113,14 @@ void NearbyInitiatorOperation::PerformUpdateConnectionPriority( ...@@ -92,11 +113,14 @@ void NearbyInitiatorOperation::PerformUpdateConnectionPriority(
void NearbyInitiatorOperation::OnSuccessfulConnection( void NearbyInitiatorOperation::OnSuccessfulConnection(
std::unique_ptr<AuthenticatedChannel> authenticated_channel) { std::unique_ptr<AuthenticatedChannel> authenticated_channel) {
OnSuccessfulConnectionAttempt(std::move(authenticated_channel)); OnSuccessfulConnectionAttempt(std::move(authenticated_channel));
LogNearbyInitiatorConnectionResult(
NearbyInitiatorConnectionResult::kConnectionSuccess);
} }
void NearbyInitiatorOperation::OnConnectionFailure( void NearbyInitiatorOperation::OnConnectionFailure(
NearbyInitiatorFailureType failure_type) { NearbyInitiatorFailureType failure_type) {
OnFailedConnectionAttempt(failure_type); OnFailedConnectionAttempt(failure_type);
LogNearbyInitiatorConnectionResult(GetMetricsConnectionResult(failure_type));
} }
} // namespace secure_channel } // namespace secure_channel
......
...@@ -49882,6 +49882,15 @@ Called by update_use_counter_css.py.--> ...@@ -49882,6 +49882,15 @@ Called by update_use_counter_css.py.-->
<int value="1" label="Completed Setup"/> <int value="1" label="Completed Setup"/>
</enum> </enum>
<enum name="MultiDeviceNearbyConnectionsInitiatorResult">
<int value="0" label="Connection Success"/>
<int value="1" label="Timeout Discovering Device"/>
<int value="2" label="Nearby Api Error"/>
<int value="3" label="Connection Rejected"/>
<int value="4" label="Connectivity Error"/>
<int value="5" label="Authentication Error"/>
</enum>
<enum name="MultiDeviceNearbyMessageAction"> <enum name="MultiDeviceNearbyMessageAction">
<int value="0" label="Message Sent"/> <int value="0" label="Message Sent"/>
<int value="1" label="Message Received"/> <int value="1" label="Message Received"/>
...@@ -248,6 +248,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -248,6 +248,18 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="MultiDevice.SecureChannel.Nearby.ConnectionResult"
enum="MultiDeviceNearbyConnectionsInitiatorResult"
expires_after="2021-11-30">
<owner>khorimoto@chromium.org</owner>
<owner>better-together-dev@google.com</owner>
<summary>
Emitted the result of attempting to establish a connection when the Nearby
Connections library finishes trying to connect. This measures the success
rate of establishing a connection via the Nearby Connections library.
</summary>
</histogram>
<histogram name="MultiDevice.SecureChannel.Nearby.MessageAction" <histogram name="MultiDevice.SecureChannel.Nearby.MessageAction"
enum="MultiDeviceNearbyMessageAction" expires_after="2021-11-30"> enum="MultiDeviceNearbyMessageAction" expires_after="2021-11-30">
<owner>khorimoto@chromium.org</owner> <owner>khorimoto@chromium.org</owner>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment