Commit 6cb8fa07 authored by Meilin Wang's avatar Meilin Wang Committed by Chromium LUCI CQ

[CrOS PhoneHub] Add metrics for tracking message results.

Added a series of histograms under name
"PhoneHub.TaskCompletion.{MessageType}.Result" to track results of each
type of request messages. "RequestAttempted" is logged when a message
was sent, and "ResponseReceived" is logged when a response has came back

Bug: 1150634
Change-Id: I6e57c2a071536a09c8260d89d1e6dc551a7fe57e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568556
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833976}
parent 52b823c8
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "chromeos/components/phonehub/proto/phonehub_api.pb.h" #include "chromeos/components/phonehub/proto/phonehub_api.pb.h"
#include "chromeos/components/phonehub/util/histogram_util.h"
namespace chromeos { namespace chromeos {
namespace phonehub { namespace phonehub {
...@@ -61,6 +62,8 @@ void MessageReceiverImpl::OnMessageReceived(const std::string& payload) { ...@@ -61,6 +62,8 @@ void MessageReceiverImpl::OnMessageReceived(const std::string& payload) {
PA_LOG(INFO) << "MessageReceiver received a " PA_LOG(INFO) << "MessageReceiver received a "
<< GetMessageTypeName(message_type) << " message."; << GetMessageTypeName(message_type) << " message.";
util::LogMessageResult(message_type,
util::PhoneHubMessageResult::kResponseReceived);
// Decode the proto message if the message is something we want to notify to // Decode the proto message if the message is something we want to notify to
// clients. // clients.
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chromeos/components/phonehub/connection_manager.h" #include "chromeos/components/phonehub/connection_manager.h"
#include "chromeos/components/phonehub/util/histogram_util.h"
namespace chromeos { namespace chromeos {
namespace phonehub { namespace phonehub {
...@@ -109,7 +110,9 @@ void MessageSenderImpl::SendMessage(proto::MessageType message_type, ...@@ -109,7 +110,9 @@ void MessageSenderImpl::SendMessage(proto::MessageType message_type,
connection_manager_->SendMessage(SerializeMessage(message_type, request)); connection_manager_->SendMessage(SerializeMessage(message_type, request));
UMA_HISTOGRAM_ENUMERATION("PhoneHub.Usage.SentMessageTypeCount", message_type, UMA_HISTOGRAM_ENUMERATION("PhoneHub.Usage.SentMessageTypeCount", message_type,
proto::MessageType_MAX); proto::MessageType_MAX);
util::LogMessageResult(message_type,
util::PhoneHubMessageResult::kRequestAttempted);
} }
} // namespace phonehub } // namespace phonehub
} // namespace chromeos } // namespace chromeos
\ No newline at end of file
...@@ -4,12 +4,59 @@ ...@@ -4,12 +4,59 @@
#include "chromeos/components/phonehub/util/histogram_util.h" #include "chromeos/components/phonehub/util/histogram_util.h"
#include <string>
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "chromeos/components/phonehub/proto/phonehub_api.pb.h"
namespace chromeos { namespace chromeos {
namespace phonehub { namespace phonehub {
namespace util { namespace util {
namespace {
std::string GetMessageResultHistogramName(proto::MessageType message_type) {
switch (message_type) {
case proto::MessageType::DISMISS_NOTIFICATION_REQUEST:
FALLTHROUGH;
case proto::MessageType::DISMISS_NOTIFICATION_RESPONSE:
return "PhoneHub.TaskCompletion.NotificationDismissal.Result";
case proto::MessageType::NOTIFICATION_INLINE_REPLY_REQUEST:
FALLTHROUGH;
case proto::MessageType::NOTIFICATION_INLINE_REPLY_RESPONSE:
return "PhoneHub.TaskCompletion.NotificationInlineReply.Result";
case proto::MessageType::UPDATE_NOTIFICATION_MODE_REQUEST:
FALLTHROUGH;
case proto::MessageType::UPDATE_NOTIFICATION_MODE_RESPONSE:
return "PhoneHub.TaskCompletion.SilencePhone.Result";
case proto::MessageType::RING_DEVICE_REQUEST:
FALLTHROUGH;
case proto::MessageType::RING_DEVICE_RESPONSE:
return "PhoneHub.TaskCompletion.LocatePhone.Result";
case proto::MessageType::SHOW_NOTIFICATION_ACCESS_SETUP_REQUEST:
FALLTHROUGH;
case proto::MessageType::SHOW_NOTIFICATION_ACCESS_SETUP_RESPONSE:
return "PhoneHub.TaskCompletion.ShowNotificationAccessSetup.Result";
case proto::MessageType::UPDATE_BATTERY_MODE_REQUEST:
FALLTHROUGH;
case proto::MessageType::UPDATE_BATTERY_MODE_RESPONSE:
return "PhoneHub.TaskCompletion.UpdateBatteryMode.Result";
default:
// Note that PROVIDE_CROS_STATE, PHONE_STATUS_SNAPSHOT and
// PHONE_STATUS_UPDATE message types are not logged as part of this
// metrics.
return std::string();
}
}
} // namespace
void LogFeatureOptInEntryPoint(OptInEntryPoint entry_point) { void LogFeatureOptInEntryPoint(OptInEntryPoint entry_point) {
base::UmaHistogramEnumeration("PhoneHub.OptInEntryPoint", entry_point); base::UmaHistogramEnumeration("PhoneHub.OptInEntryPoint", entry_point);
} }
...@@ -19,6 +66,14 @@ void LogTetherConnectionResult(TetherConnectionResult result) { ...@@ -19,6 +66,14 @@ void LogTetherConnectionResult(TetherConnectionResult result) {
"PhoneHub.TaskCompletion.TetherConnection.Result", result); "PhoneHub.TaskCompletion.TetherConnection.Result", result);
} }
void LogMessageResult(proto::MessageType message_type,
PhoneHubMessageResult result) {
const std::string histogram_name =
GetMessageResultHistogramName(message_type);
if (!histogram_name.empty())
base::UmaHistogramEnumeration(histogram_name, result);
}
} // namespace util } // namespace util
} // namespace phonehub } // namespace phonehub
} // namespace chromeos } // namespace chromeos
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef CHROMEOS_COMPONENTS_PHONEHUB_UTIL_HISTOGRAM_UTIL_H_ #ifndef CHROMEOS_COMPONENTS_PHONEHUB_UTIL_HISTOGRAM_UTIL_H_
#define CHROMEOS_COMPONENTS_PHONEHUB_UTIL_HISTOGRAM_UTIL_H_ #define CHROMEOS_COMPONENTS_PHONEHUB_UTIL_HISTOGRAM_UTIL_H_
#include "chromeos/components/phonehub/proto/phonehub_api.pb.h"
namespace chromeos { namespace chromeos {
namespace phonehub { namespace phonehub {
namespace util { namespace util {
...@@ -27,12 +29,24 @@ enum class TetherConnectionResult { ...@@ -27,12 +29,24 @@ enum class TetherConnectionResult {
kMaxValue = kSuccess, kMaxValue = kSuccess,
}; };
// 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 PhoneHubMessageResult {
kRequestAttempted = 0,
kResponseReceived = 1,
kMaxValue = kResponseReceived,
};
// Logs a given opt-in |entry_point| for the PhoneHub feature. // Logs a given opt-in |entry_point| for the PhoneHub feature.
void LogFeatureOptInEntryPoint(OptInEntryPoint entry_point); void LogFeatureOptInEntryPoint(OptInEntryPoint entry_point);
// Logs a given |result| of a tethering connection attempt. // Logs a given |result| of a tethering connection attempt.
void LogTetherConnectionResult(TetherConnectionResult result); void LogTetherConnectionResult(TetherConnectionResult result);
// Logs a given |result| for a request message.
void LogMessageResult(proto::MessageType message, PhoneHubMessageResult result);
} // namespace util } // namespace util
} // namespace phonehub } // namespace phonehub
} // namespace chromeos } // namespace chromeos
......
...@@ -58264,6 +58264,11 @@ Called by update_net_trust_anchors.py.--> ...@@ -58264,6 +58264,11 @@ Called by update_net_trust_anchors.py.-->
<int value="3" label="Confirm Clicked"/> <int value="3" label="Confirm Clicked"/>
</enum> </enum>
<enum name="PhoneHubMessageResult">
<int value="0" label="Request message was sent"/>
<int value="1" label="Response was sent back"/>
</enum>
<enum name="PhoneHubMessageType"> <enum name="PhoneHubMessageType">
<int value="0" label="Provide CrOS State"/> <int value="0" label="Provide CrOS State"/>
<int value="1" label="Phone status snapshot"/> <int value="1" label="Phone status snapshot"/>
...@@ -181,6 +181,24 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -181,6 +181,24 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="PhoneHub.TaskCompletion.{MessageType}.Result"
enum="PhoneHubMessageResult" expires_after="2021-12-03">
<owner>khorimoto@chromium.org</owner>
<owner>phonehub-dev@google.com</owner>
<summary>
Tracks the result of each type of message request. Logged each time a
request message was sent and a response was received.
</summary>
<token key="MessageType">
<variant name="LocatePhone"/>
<variant name="NotificationDismissal"/>
<variant name="NotificationInlineReply"/>
<variant name="ShowNotificationAccessSetup"/>
<variant name="SilencePhone"/>
<variant name="UpdateBatteryMode"/>
</token>
</histogram>
<histogram name="PhoneHub.Usage.SentMessageTypeCount" <histogram name="PhoneHub.Usage.SentMessageTypeCount"
enum="PhoneHubMessageType" expires_after="M98"> enum="PhoneHubMessageType" expires_after="M98">
<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