From 88aa9330b9dcc79911d607c5d7156d5345d69633 Mon Sep 17 00:00:00 2001 From: asvitkine Date: Mon, 29 Sep 2014 16:29:17 -0700 Subject: [PATCH] Add a histogram to measure number of synthetic UMA trials. Also refactors some common code into a method in MetricsService. BUG=400357 Review URL: https://codereview.chromium.org/612883003 Cr-Commit-Position: refs/heads/master@{#297302} --- components/metrics/metrics_service.cc | 20 +++++++++++--------- components/metrics/metrics_service.h | 3 +++ tools/metrics/histograms/histograms.xml | 9 +++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/components/metrics/metrics_service.cc b/components/metrics/metrics_service.cc index 25240a2b95a66..35dd9276df925 100644 --- a/components/metrics/metrics_service.cc +++ b/components/metrics/metrics_service.cc @@ -766,10 +766,7 @@ void MetricsService::CloseCurrentLog() { // MetricsLog class. MetricsLog* current_log = log_manager_.current_log(); DCHECK(current_log); - std::vector synthetic_trials; - GetCurrentSyntheticFieldTrials(&synthetic_trials); - current_log->RecordEnvironment( - metrics_providers_.get(), synthetic_trials, GetInstallDate()); + RecordCurrentEnvironment(current_log); base::TimeDelta incremental_uptime; base::TimeDelta uptime; GetUptimes(local_state_, &incremental_uptime, &uptime); @@ -972,11 +969,7 @@ void MetricsService::PrepareInitialStabilityLog() { void MetricsService::PrepareInitialMetricsLog() { DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG); - std::vector synthetic_trials; - GetCurrentSyntheticFieldTrials(&synthetic_trials); - initial_metrics_log_->RecordEnvironment(metrics_providers_.get(), - synthetic_trials, - GetInstallDate()); + RecordCurrentEnvironment(initial_metrics_log_.get()); base::TimeDelta incremental_uptime; base::TimeDelta uptime; GetUptimes(local_state_, &incremental_uptime, &uptime); @@ -1177,6 +1170,15 @@ scoped_ptr MetricsService::CreateLog(MetricsLog::LogType log_type) { local_state_)); } +void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { + std::vector synthetic_trials; + GetCurrentSyntheticFieldTrials(&synthetic_trials); + log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, + GetInstallDate()); + UMA_HISTOGRAM_COUNTS_100("UMA.SyntheticTrials.Count", + synthetic_trials.size()); +} + void MetricsService::RecordCurrentHistograms() { DCHECK(log_manager_.current_log()); histogram_snapshot_manager_.PrepareDeltas( diff --git a/components/metrics/metrics_service.h b/components/metrics/metrics_service.h index a625953779240..fab569833d811 100644 --- a/components/metrics/metrics_service.h +++ b/components/metrics/metrics_service.h @@ -364,6 +364,9 @@ class MetricsService : public base::HistogramFlattener { // Creates a new MetricsLog instance with the given |log_type|. scoped_ptr CreateLog(MetricsLog::LogType log_type); + // Records the current environment (system profile) in |log|. + void RecordCurrentEnvironment(MetricsLog* log); + // Record complete list of histograms into the current log. // Called when we close a log. void RecordCurrentHistograms(); diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index fc6ac425ebc70..9feb26901c978 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -35618,6 +35618,15 @@ Therefore, the affected-histogram name has to have at least one dot in it. + + asvitkine@chromium.org + + The number of synthetic field trials added to the UMA log when the system + profile is recorded. Since this is done prior to capturing the histograms + from the current process, this will generally be logged once per UMA log. + + + Deprecated as of May, 2012 (i.e. Chrome 21+). Replaced by the