From 59e9fa67a1ec68ade816a84d161dc4da93c7419f Mon Sep 17 00:00:00 2001 From: Liang Li Date: Fri, 7 Feb 2025 17:48:44 -0800 Subject: Add metrics logging for Bluetooth offload socket Bug: 399022276 Flag: EXEMPT, metrics update Test: m com.google.android.bt Test: Android Data Hub Atom Tester Change-Id: Ib5a4a0d6970287388851bcf5fdb71121e3092b76 --- system/common/metrics.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'system/common/metrics.cc') diff --git a/system/common/metrics.cc b/system/common/metrics.cc index 1ece069ab3..809b3c4d31 100644 --- a/system/common/metrics.cc +++ b/system/common/metrics.cc @@ -58,6 +58,9 @@ struct formatter template <> struct formatter : enum_formatter {}; +template <> +struct formatter + : enum_formatter {}; } // namespace std namespace bluetooth { @@ -778,7 +781,10 @@ void LogSdpAttribute(const RawAddress& address, uint16_t protocol_uuid, uint16_t void LogSocketConnectionState(const RawAddress& address, int port, int type, android::bluetooth::SocketConnectionstateEnum connection_state, int64_t tx_bytes, int64_t rx_bytes, int uid, int server_port, - android::bluetooth::SocketRoleEnum socket_role) { + android::bluetooth::SocketRoleEnum socket_role, + uint64_t connection_duration_ms, + android::bluetooth::SocketErrorEnum error_code, + bool is_hardware_offload) { std::string obfuscated_id; int metric_id = 0; if (!address.IsEmpty()) { @@ -790,14 +796,16 @@ void LogSocketConnectionState(const RawAddress& address, int port, int type, address.IsEmpty() ? 0 : obfuscated_id.size()); int ret = stats_write(BLUETOOTH_SOCKET_CONNECTION_STATE_CHANGED, obfuscated_id_field, port, type, connection_state, tx_bytes, rx_bytes, uid, server_port, socket_role, - metric_id, 0 /* connection_duration_ms */, 1 /* error_code */, - 0 /* is_hardware_offload */); + metric_id, static_cast(connection_duration_ms), error_code, + is_hardware_offload); if (ret < 0) { log::warn( "failed for {}, port {}, type {}, state {}, tx_bytes {}, rx_bytes {}, " - "uid {}, server_port {}, socket_role {}, error {}", + "uid {}, server_port {}, socket_role {}, error {}, connection_duration_ms {}, " + "socket_error_code {}, " + "is_hardware_offload {}", address, port, type, connection_state, tx_bytes, rx_bytes, uid, server_port, - socket_role, ret); + socket_role, ret, connection_duration_ms, error_code, is_hardware_offload); } } -- cgit v1.2.3-59-g8ed1b