summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasharif@chromium.org <asharif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 19:45:44 +0000
committerasharif@chromium.org <asharif@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-10 19:45:44 +0000
commita11e160f0ed1cdf1bd3b7bf658449109717a440b (patch)
treeec10ef3babed803257e4578be3edc812eedaec97
parenta9f2482997d6afa4b71bd865f4ffc5bbd5608de6 (diff)
downloadchromium_src-a11e160f0ed1cdf1bd3b7bf658449109717a440b.zip
chromium_src-a11e160f0ed1cdf1bd3b7bf658449109717a440b.tar.gz
chromium_src-a11e160f0ed1cdf1bd3b7bf658449109717a440b.tar.bz2
metrics: Make it easy to analyze the gzipped protobufs field trial.
* Create the field trial at initialization time, so it gets included in the first upload. * Use one-time-randomization to select the experimental group. BUG=none TEST=git cl try. Also built locally and ran it successfully. Review URL: https://chromiumcodereview.appspot.com/18615013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210914 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chrome_browser_field_trials.cc2
-rw-r--r--chrome/browser/metrics/gzipped_protobufs_field_trial.cc55
-rw-r--r--chrome/browser/metrics/gzipped_protobufs_field_trial.h21
-rw-r--r--chrome/browser/metrics/metrics_service.cc37
-rw-r--r--chrome/browser/metrics/metrics_service.h12
-rw-r--r--chrome/chrome_browser.gypi2
6 files changed, 83 insertions, 46 deletions
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc
index 00256c7..aae3171 100644
--- a/chrome/browser/chrome_browser_field_trials.cc
+++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -11,6 +11,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
+#include "chrome/browser/metrics/gzipped_protobufs_field_trial.h"
#include "chrome/browser/omnibox/omnibox_field_trial.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
@@ -38,6 +39,7 @@ void ChromeBrowserFieldTrials::SetupFieldTrials(PrefService* local_state) {
// Field trials that are shared by all platforms.
chrome_variations::SetupUniformityFieldTrials(install_time);
+ metrics::CreateGzippedProtobufsFieldTrial();
InstantiateDynamicTrials();
#if defined(OS_ANDROID) || defined(OS_IOS)
diff --git a/chrome/browser/metrics/gzipped_protobufs_field_trial.cc b/chrome/browser/metrics/gzipped_protobufs_field_trial.cc
new file mode 100644
index 0000000..e12290d
--- /dev/null
+++ b/chrome/browser/metrics/gzipped_protobufs_field_trial.cc
@@ -0,0 +1,55 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/scoped_ptr.h"
+#include "base/metrics/field_trial.h"
+
+namespace {
+
+// Name of field trial for that sends gzipped UMA protobufs.
+const char kTrialName[] = "GZippedProtobufs";
+
+// Divisor for the gzipped protobufs trial.
+const int kTrialDivisor = 100;
+
+// Quotient for the gzipped protobufs trial.
+const int kTrialQuotient = 50;
+
+// Name of the group with gzipped protobufs.
+const char kGroupName[] = "GzippedProtobufsEnabled";
+
+// Name of the group with non-gzipped protobufs.
+const char kControlGroupName[] = "GzippedProtobufsDisabled";
+
+// This is set to true if we land in the Finch group that will be sending
+// protobufs after compressing them.
+bool should_gzip_protobufs = false;
+
+} // namespace
+
+namespace metrics {
+
+void CreateGzippedProtobufsFieldTrial() {
+ scoped_refptr<base::FieldTrial> gzipped_protobufs_trial =
+ base::FieldTrialList::FactoryGetFieldTrial(
+ kTrialName,
+ kTrialDivisor,
+ kControlGroupName,
+ 2013,
+ 9,
+ 1,
+ NULL);
+ gzipped_protobufs_trial->UseOneTimeRandomization();
+ int gzipped_protobufs_group = gzipped_protobufs_trial->AppendGroup(
+ kGroupName,
+ kTrialQuotient);
+ should_gzip_protobufs =
+ gzipped_protobufs_trial->group() == gzipped_protobufs_group;
+}
+
+bool ShouldGzipProtobufsBeforeUploading() {
+ return should_gzip_protobufs;
+}
+
+} // namespace metrics
diff --git a/chrome/browser/metrics/gzipped_protobufs_field_trial.h b/chrome/browser/metrics/gzipped_protobufs_field_trial.h
new file mode 100644
index 0000000..fe39f01
--- /dev/null
+++ b/chrome/browser/metrics/gzipped_protobufs_field_trial.h
@@ -0,0 +1,21 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_METRICS_GZIPPED_PROTOBUFS_FIELD_TRIAL_H_
+#define CHROME_BROWSER_METRICS_GZIPPED_PROTOBUFS_FIELD_TRIAL_H_
+
+namespace metrics {
+
+// Create a field trial for selecting whether to gzip protobufs before uploading
+// or not.
+void CreateGzippedProtobufsFieldTrial();
+
+// Returns whether we are in a field trial group that compresses protobufs
+// before uploading.
+bool ShouldGzipProtobufsBeforeUploading();
+
+} // namespace metrics
+
+
+#endif // CHROME_BROWSER_METRICS_GZIPPED_PROTOBUFS_FIELD_TRIAL_H_
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index 752cf83..784c615 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -176,6 +176,7 @@
#include "chrome/browser/io_thread.h"
#include "chrome/browser/memory_details.h"
#include "chrome/browser/metrics/compression_utils.h"
+#include "chrome/browser/metrics/gzipped_protobufs_field_trial.h"
#include "chrome/browser/metrics/metrics_log.h"
#include "chrome/browser/metrics/metrics_log_serializer.h"
#include "chrome/browser/metrics/metrics_reporting_scheduler.h"
@@ -271,21 +272,6 @@ const size_t kUploadLogAvoidRetransmitSize = 50000;
// Interval, in minutes, between state saves.
const int kSaveStateIntervalMinutes = 5;
-// Name of field trial for that sends gzipped UMA protobufs.
-const char kGzippedProtobufsTrialName[] = "GZippedProtobufs";
-
-// Divisor for the gzipped protobufs trial.
-const int kGzippedProtobufsTrialDivisor = 100;
-
-// Quotient for the gzipped protobufs trial.
-const int kGzippedProtobufsTrialQuotient = 50;
-
-// Name of the group with gzipped protobufs.
-const char kGzippedProtobufsGroupName[] = "GzippedProtobufsEnabled";
-
-// Name of the group with non-gzipped protobufs.
-const char kNonGzippedProtobufsGroupName[] = "GzippedProtobufsDisabled";
-
enum ResponseStatus {
UNKNOWN_FAILURE,
SUCCESS,
@@ -486,7 +472,6 @@ MetricsService::MetricsService()
reporting_active_(false),
test_mode_active_(false),
state_(INITIALIZED),
- gzipped_protobufs_group_(0),
low_entropy_source_(kLowEntropySourceNotSet),
idle_since_last_transmission_(false),
next_window_id_(0),
@@ -1438,7 +1423,8 @@ void MetricsService::PrepareFetchWithStagedLog() {
// Compress the protobufs 50% of the time. This can be used to see if
// compressed protobufs are being mishandled by machines between the
// client/server or monitoring programs/firewalls on the client.
- bool gzip_protobuf_before_uploading = GzipProtobufsBeforeUploading();
+ bool gzip_protobuf_before_uploading =
+ metrics::ShouldGzipProtobufsBeforeUploading();
if (gzip_protobuf_before_uploading) {
std::string log_text = log_manager_.staged_log_text();
std::string compressed_log_text;
@@ -1871,23 +1857,6 @@ void MetricsService::StartExternalMetrics() {
}
#endif
-bool MetricsService::GzipProtobufsBeforeUploading() {
- if (!gzipped_protobufs_trial_) {
- gzipped_protobufs_trial_ = base::FieldTrialList::FactoryGetFieldTrial(
- kGzippedProtobufsTrialName,
- kGzippedProtobufsTrialDivisor,
- kNonGzippedProtobufsGroupName,
- 2013,
- 8,
- 1,
- NULL);
- gzipped_protobufs_group_ = gzipped_protobufs_trial_->AppendGroup(
- kGzippedProtobufsGroupName,
- kGzippedProtobufsTrialQuotient);
- }
- return gzipped_protobufs_trial_->group() == gzipped_protobufs_group_;
-}
-
// static
bool MetricsServiceHelper::IsMetricsReportingEnabled() {
bool result = false;
diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h
index ced1614..52c9152 100644
--- a/chrome/browser/metrics/metrics_service.h
+++ b/chrome/browser/metrics/metrics_service.h
@@ -405,10 +405,6 @@ class MetricsService
// process, and false otherwise.
static bool IsPluginProcess(int process_type);
- // Returns true if we are in the Finch experiment group that should compress
- // protobufs before uploading.
- bool GzipProtobufsBeforeUploading();
-
content::ActionCallback action_callback_;
content::NotificationRegistrar registrar_;
@@ -439,14 +435,6 @@ class MetricsService
// Google Update statistics, which were retrieved on a blocking pool thread.
GoogleUpdateMetrics google_update_metrics_;
- // Field trial that determines whether we gzip protobufs before uploading
- // them.
- scoped_refptr<base::FieldTrial> gzipped_protobufs_trial_;
-
- // The integer value corresponding to the group that will be gzipping
- // protobufs before uploading them.
- int gzipped_protobufs_group_;
-
// The initial log, used to record startup metrics.
scoped_ptr<MetricsLog> initial_log_;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index bf9ebd3..2f01cb1 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1059,6 +1059,8 @@
'browser/metrics/compression_utils.h',
'browser/metrics/field_trial_synchronizer.cc',
'browser/metrics/field_trial_synchronizer.h',
+ 'browser/metrics/gzipped_protobufs_field_trial.cc',
+ 'browser/metrics/gzipped_protobufs_field_trial.h',
'browser/metrics/metric_event_duration_details.h',
'browser/metrics/metrics_log.cc',
'browser/metrics/metrics_log.h',