Commit de8dad51 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Chromium LUCI CQ

[CrOS PhoneHub] Update MultiDevice.SecureChannel.Nearby.ConnectionMedium

This metric records one bucket when a connection is accepted and another
bucket when a WebRTC upgrade occurs, as a measure of the effectiveness
of WebRTC upgrades. If these buckets have equal counts, this means that
WebRTC upgrades occurred 100% of the time.

However, WebRTC upgrades are not instantaneous; the median upgrade time
is ~5s, and the 95th percentile is 30s. For short-lived connections, we
don't provide enough time for the connection to upgrade, so this
shouldn't really be counted as a "failure" to upgrade.

If a connection disconnects in under 30s, we now log to a new bucket
indicating that the connection disconnected before 30s was up. This will
help us measure a more accurate success rate for WebRTC upgrades.

Bug: 1163779, 1106937
Change-Id: I135820c6541e96818cced0e91719a591ec1510d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617304
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841695}
parent 744ba8cd
......@@ -33,12 +33,19 @@ NearbyConnectionBrokerImpl::Factory* g_test_factory = nullptr;
constexpr base::TimeDelta kConnectionStatusChangeTimeout =
base::TimeDelta::FromSeconds(10);
// The amount of time by which we can expect a WebRTC upgrade to have been
// completed. According to metrics, 30 seconds is the 95th+ percentile of how
// long it takes to upgrade to WebRTC.
constexpr base::TimeDelta kWebRtcUpgradeDelay =
base::TimeDelta::FromSeconds(30);
// Numerical values should not be reused or changed since this is used by
// metrics.
enum class ConnectionMedium {
kConnectedViaBluetooth = 0,
kUpgradedToWebRtc = 1,
kMaxValue = kUpgradedToWebRtc
kDisconnectedInUnder30Seconds = 2,
kMaxValue = kDisconnectedInUnder30Seconds
};
void RecordConnectionMediumMetric(ConnectionMedium medium) {
......@@ -151,6 +158,15 @@ void NearbyConnectionBrokerImpl::Disconnect(
util::RecordNearbyDisconnection(reason);
}
if (!has_recorded_no_webrtc_metric_ && !has_upgraded_to_webrtc_ &&
!time_when_connection_accepted_.is_null() &&
(base::Time::Now() - time_when_connection_accepted_) <
kWebRtcUpgradeDelay) {
has_recorded_no_webrtc_metric_ = true;
RecordConnectionMediumMetric(
ConnectionMedium::kDisconnectedInUnder30Seconds);
}
if (!need_to_disconnect_endpoint_) {
TransitionToDisconnectedAndInvokeCallback();
return;
......@@ -398,6 +414,7 @@ void NearbyConnectionBrokerImpl::OnBandwidthChanged(
PA_LOG(INFO) << "Bandwidth changed: " << medium;
if (medium == Medium::kWebRtc) {
has_upgraded_to_webrtc_ = true;
RecordConnectionMediumMetric(ConnectionMedium::kUpgradedToWebRtc);
DCHECK(!time_when_connection_accepted_.is_null());
......
......@@ -168,6 +168,14 @@ class NearbyConnectionBrokerImpl
// Starts empty, then set in OnEndpointDiscovered().
std::string remote_endpoint_id_;
// Starts as false and changes to true when WebRTC upgrade occurs.
bool has_upgraded_to_webrtc_ = false;
// Whether or not a metric has been logged to note that a metric has been
// logged indicated that Disconnect() was called before a WebRTC upgrade
// occurred.
bool has_recorded_no_webrtc_metric_ = false;
// Starts as false; set to true in OnConnectionInitiated() and back to false
// in OnDisconnected().
bool need_to_disconnect_endpoint_ = false;
......
......@@ -66900,6 +66900,9 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
<enum name="SecureChannelNearbyConnectionMedium">
<int value="0" label="Connected via Bluetooth"/>
<int value="1" label="Upgraded bandwidth to WebRTC"/>
<int value="2"
label="Disconnected in under 30s without WebRTC upgrade; not provided
enough time to complete bandwidth upgrade process"/>
</enum>
<enum name="SecureCookieAction">
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