Commit 8c25a456 authored by Paul Miller's avatar Paul Miller Committed by Commit Bot

WebView: Enable UMA on L/M and sample at 2%

According to https://developer.android.com/about/dashboards/index.html
today, L/M have 58.1% share while N/O have 20.9% share, so adding L/M
would increase log volume by ~4x. To compensate, also reduce sampling
from 10% to 2%.

Removing the platform check from AwFieldTrialCreator will have no effect
because that's currently disabled by a flag.

BUG=763551

Change-Id: I6bf28b7b73686879bec7b1c85dc8369524623d8a
Reviewed-on: https://chromium-review.googlesource.com/767019Reviewed-by: 's avatarTobias Sargeant <tobiasjs@chromium.org>
Commit-Queue: Paul Miller <paulmiller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516120}
parent a06a04a5
...@@ -74,9 +74,6 @@ std::unique_ptr<PrefService> AwFieldTrialCreator::CreateLocalState() { ...@@ -74,9 +74,6 @@ std::unique_ptr<PrefService> AwFieldTrialCreator::CreateLocalState() {
} }
void AwFieldTrialCreator::SetUpFieldTrials() { void AwFieldTrialCreator::SetUpFieldTrials() {
if (!AwMetricsServiceClient::CheckSDKVersionForMetrics())
return;
AwMetricsServiceClient::LoadOrCreateClientId(); AwMetricsServiceClient::LoadOrCreateClientId();
DCHECK(!field_trial_list_); DCHECK(!field_trial_list_);
......
...@@ -69,7 +69,7 @@ version_info::Channel GetChannelFromPackageName() { ...@@ -69,7 +69,7 @@ version_info::Channel GetChannelFromPackageName() {
// WebView Metrics are sampled based on GUID value. // WebView Metrics are sampled based on GUID value.
// TODO(paulmiller) Sample with Finch, once we have Finch. // TODO(paulmiller) Sample with Finch, once we have Finch.
bool CheckInSample(const std::string& client_id) { bool IsInSample(const std::string& client_id) {
// client_id comes from base::GenerateGUID(), so its value is random/uniform, // client_id comes from base::GenerateGUID(), so its value is random/uniform,
// except for a few bit positions with fixed values, and some hyphens. Rather // except for a few bit positions with fixed values, and some hyphens. Rather
// than separating the random payload from the fixed bits, just hash the whole // than separating the random payload from the fixed bits, just hash the whole
...@@ -77,8 +77,8 @@ bool CheckInSample(const std::string& client_id) { ...@@ -77,8 +77,8 @@ bool CheckInSample(const std::string& client_id) {
uint32_t hash = base::PersistentHash(client_id); uint32_t hash = base::PersistentHash(client_id);
// Since hashing is ~uniform, the chance that the value falls in the bottom // Since hashing is ~uniform, the chance that the value falls in the bottom
// 10% of possible values is 10%. // 2% (1/50th) of possible values is 2%.
return hash < UINT32_MAX / 10u; return hash < UINT32_MAX / 50u;
} }
} // namespace } // namespace
...@@ -89,12 +89,6 @@ AwMetricsServiceClient* AwMetricsServiceClient::GetInstance() { ...@@ -89,12 +89,6 @@ AwMetricsServiceClient* AwMetricsServiceClient::GetInstance() {
return g_lazy_instance_.Pointer(); return g_lazy_instance_.Pointer();
} }
bool AwMetricsServiceClient::CheckSDKVersionForMetrics() {
// For now, UMA is only enabled on Android N+.
return base::android::BuildInfo::GetInstance()->sdk_int() >=
base::android::SDK_VERSION_NOUGAT;
}
void AwMetricsServiceClient::LoadOrCreateClientId() { void AwMetricsServiceClient::LoadOrCreateClientId() {
// This function should only be called once at start up. // This function should only be called once at start up.
DCHECK_NE(g_client_id.Get().length(), GUID_SIZE); DCHECK_NE(g_client_id.Get().length(), GUID_SIZE);
...@@ -171,7 +165,7 @@ void AwMetricsServiceClient::InitializeWithClientId() { ...@@ -171,7 +165,7 @@ void AwMetricsServiceClient::InitializeWithClientId() {
DCHECK_EQ(g_client_id.Get().length(), GUID_SIZE); DCHECK_EQ(g_client_id.Get().length(), GUID_SIZE);
pref_service_->SetString(metrics::prefs::kMetricsClientID, g_client_id.Get()); pref_service_->SetString(metrics::prefs::kMetricsClientID, g_client_id.Get());
in_sample_ = CheckInSample(g_client_id.Get()); in_sample_ = IsInSample(g_client_id.Get());
metrics_state_manager_ = metrics::MetricsStateManager::Create( metrics_state_manager_ = metrics::MetricsStateManager::Create(
pref_service_, this, base::string16(), base::Bind(&StoreClientInfo), pref_service_, this, base::string16(), base::Bind(&StoreClientInfo),
...@@ -208,7 +202,7 @@ bool AwMetricsServiceClient::IsConsentGiven() { ...@@ -208,7 +202,7 @@ bool AwMetricsServiceClient::IsConsentGiven() {
} }
bool AwMetricsServiceClient::IsReportingEnabled() { bool AwMetricsServiceClient::IsReportingEnabled() {
return consent_ && in_sample_ && CheckSDKVersionForMetrics(); return consent_ && in_sample_;
} }
void AwMetricsServiceClient::SetHaveMetricsConsent(bool consent) { void AwMetricsServiceClient::SetHaveMetricsConsent(bool consent) {
......
...@@ -44,9 +44,6 @@ class AwMetricsServiceClient : public metrics::MetricsServiceClient, ...@@ -44,9 +44,6 @@ class AwMetricsServiceClient : public metrics::MetricsServiceClient,
public: public:
static AwMetricsServiceClient* GetInstance(); static AwMetricsServiceClient* GetInstance();
// Return true if running on an sdk version metrics should be enabled for.
static bool CheckSDKVersionForMetrics();
// Retrieve the client ID or generate one if none exists. // Retrieve the client ID or generate one if none exists.
static void LoadOrCreateClientId(); static void LoadOrCreateClientId();
......
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