summaryrefslogtreecommitdiff
path: root/system/common/metrics.cc
diff options
context:
space:
mode:
author Liang Li <lianglli@google.com> 2025-03-11 11:34:32 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-11 11:34:32 -0700
commitb2f0085cac5c7f69807ab078cb291d31c165a9d9 (patch)
treea2426136c0f34e4ab1db031f30fd418e81195567 /system/common/metrics.cc
parentfdbf19f4c09baffc00d00cbf3cbcdec8264c751c (diff)
parent59e9fa67a1ec68ade816a84d161dc4da93c7419f (diff)
Merge "Add metrics logging for Bluetooth offload socket" into main
Diffstat (limited to 'system/common/metrics.cc')
-rw-r--r--system/common/metrics.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/system/common/metrics.cc b/system/common/metrics.cc
index 45b11acf46..a3b3eea450 100644
--- a/system/common/metrics.cc
+++ b/system/common/metrics.cc
@@ -57,6 +57,9 @@ struct formatter<android::bluetooth::AddressTypeEnum>
template <>
struct formatter<android::bluetooth::DeviceInfoSrcEnum>
: enum_formatter<android::bluetooth::DeviceInfoSrcEnum> {};
+template <>
+struct formatter<android::bluetooth::SocketErrorEnum>
+ : enum_formatter<android::bluetooth::SocketErrorEnum> {};
} // namespace std
namespace bluetooth {
@@ -303,7 +306,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()) {
@@ -315,14 +321,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<int64_t>(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);
}
}