Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Add a histogram to measure number of synthetic UMA trials.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
asvitkine-chromium authored and Commit bot committed Sep 29, 2014
1 parent 6ecefe3 commit 88aa933
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
20 changes: 11 additions & 9 deletions components/metrics/metrics_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,7 @@ void MetricsService::CloseCurrentLog() {
// MetricsLog class.
MetricsLog* current_log = log_manager_.current_log();
DCHECK(current_log);
std::vector<variations::ActiveGroupId> 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);
Expand Down Expand Up @@ -972,11 +969,7 @@ void MetricsService::PrepareInitialStabilityLog() {
void MetricsService::PrepareInitialMetricsLog() {
DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG);

std::vector<variations::ActiveGroupId> 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);
Expand Down Expand Up @@ -1177,6 +1170,15 @@ scoped_ptr<MetricsLog> MetricsService::CreateLog(MetricsLog::LogType log_type) {
local_state_));
}

void MetricsService::RecordCurrentEnvironment(MetricsLog* log) {
std::vector<variations::ActiveGroupId> 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(
Expand Down
3 changes: 3 additions & 0 deletions components/metrics/metrics_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ class MetricsService : public base::HistogramFlattener {
// Creates a new MetricsLog instance with the given |log_type|.
scoped_ptr<MetricsLog> 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();
Expand Down
9 changes: 9 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35618,6 +35618,15 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>

<histogram name="UMA.SyntheticTrials.Count">
<owner>[email protected]</owner>
<summary>
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.
</summary>
</histogram>

<histogram name="UMA.Unacceptable_Log_Discarded">
<obsolete>
Deprecated as of May, 2012 (i.e. Chrome 21+). Replaced by the
Expand Down

0 comments on commit 88aa933

Please sign in to comment.