Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: components/metrics/metrics_service.cc

Issue 612883003: Add a histogram to measure number of synthetic UMA trials. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/metrics/metrics_service.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 //------------------------------------------------------------------------------ 5 //------------------------------------------------------------------------------
6 // Description of the life cycle of a instance of MetricsService. 6 // Description of the life cycle of a instance of MetricsService.
7 // 7 //
8 // OVERVIEW 8 // OVERVIEW
9 // 9 //
10 // A MetricsService instance is typically created at application startup. It is 10 // A MetricsService instance is typically created at application startup. It is
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 log_manager_.DiscardCurrentLog(); 759 log_manager_.DiscardCurrentLog();
760 OpenNewLog(); // Start trivial log to hold our histograms. 760 OpenNewLog(); // Start trivial log to hold our histograms.
761 } 761 }
762 762
763 // Put incremental data (histogram deltas, and realtime stats deltas) at the 763 // Put incremental data (histogram deltas, and realtime stats deltas) at the
764 // end of all log transmissions (initial log handles this separately). 764 // end of all log transmissions (initial log handles this separately).
765 // RecordIncrementalStabilityElements only exists on the derived 765 // RecordIncrementalStabilityElements only exists on the derived
766 // MetricsLog class. 766 // MetricsLog class.
767 MetricsLog* current_log = log_manager_.current_log(); 767 MetricsLog* current_log = log_manager_.current_log();
768 DCHECK(current_log); 768 DCHECK(current_log);
769 std::vector<variations::ActiveGroupId> synthetic_trials; 769 RecordCurrentEnvironment(current_log);
770 GetCurrentSyntheticFieldTrials(&synthetic_trials);
771 current_log->RecordEnvironment(
772 metrics_providers_.get(), synthetic_trials, GetInstallDate());
773 base::TimeDelta incremental_uptime; 770 base::TimeDelta incremental_uptime;
774 base::TimeDelta uptime; 771 base::TimeDelta uptime;
775 GetUptimes(local_state_, &incremental_uptime, &uptime); 772 GetUptimes(local_state_, &incremental_uptime, &uptime);
776 current_log->RecordStabilityMetrics(metrics_providers_.get(), 773 current_log->RecordStabilityMetrics(metrics_providers_.get(),
777 incremental_uptime, uptime); 774 incremental_uptime, uptime);
778 775
779 RecordCurrentHistograms(); 776 RecordCurrentHistograms();
780 current_log->RecordGeneralMetrics(metrics_providers_.get()); 777 current_log->RecordGeneralMetrics(metrics_providers_.get());
781 778
782 log_manager_.FinishCurrentLog(); 779 log_manager_.FinishCurrentLog();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 // Store unsent logs, including the stability log that was just saved, so 962 // Store unsent logs, including the stability log that was just saved, so
966 // that they're not lost in case of a crash before upload time. 963 // that they're not lost in case of a crash before upload time.
967 log_manager_.PersistUnsentLogs(); 964 log_manager_.PersistUnsentLogs();
968 965
969 has_initial_stability_log_ = true; 966 has_initial_stability_log_ = true;
970 } 967 }
971 968
972 void MetricsService::PrepareInitialMetricsLog() { 969 void MetricsService::PrepareInitialMetricsLog() {
973 DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG); 970 DCHECK(state_ == INIT_TASK_DONE || state_ == SENDING_INITIAL_STABILITY_LOG);
974 971
975 std::vector<variations::ActiveGroupId> synthetic_trials; 972 RecordCurrentEnvironment(initial_metrics_log_.get());
976 GetCurrentSyntheticFieldTrials(&synthetic_trials);
977 initial_metrics_log_->RecordEnvironment(metrics_providers_.get(),
978 synthetic_trials,
979 GetInstallDate());
980 base::TimeDelta incremental_uptime; 973 base::TimeDelta incremental_uptime;
981 base::TimeDelta uptime; 974 base::TimeDelta uptime;
982 GetUptimes(local_state_, &incremental_uptime, &uptime); 975 GetUptimes(local_state_, &incremental_uptime, &uptime);
983 976
984 // Histograms only get written to the current log, so make the new log current 977 // Histograms only get written to the current log, so make the new log current
985 // before writing them. 978 // before writing them.
986 log_manager_.PauseCurrentLog(); 979 log_manager_.PauseCurrentLog();
987 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass()); 980 log_manager_.BeginLoggingWithLog(initial_metrics_log_.Pass());
988 981
989 // Note: Some stability providers may record stability stats via histograms, 982 // Note: Some stability providers may record stability stats via histograms,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 } 1163 }
1171 1164
1172 scoped_ptr<MetricsLog> MetricsService::CreateLog(MetricsLog::LogType log_type) { 1165 scoped_ptr<MetricsLog> MetricsService::CreateLog(MetricsLog::LogType log_type) {
1173 return make_scoped_ptr(new MetricsLog(state_manager_->client_id(), 1166 return make_scoped_ptr(new MetricsLog(state_manager_->client_id(),
1174 session_id_, 1167 session_id_,
1175 log_type, 1168 log_type,
1176 client_, 1169 client_,
1177 local_state_)); 1170 local_state_));
1178 } 1171 }
1179 1172
1173 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) {
1174 std::vector<variations::ActiveGroupId> synthetic_trials;
1175 GetCurrentSyntheticFieldTrials(&synthetic_trials);
1176 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials,
1177 GetInstallDate());
1178 UMA_HISTOGRAM_COUNTS_100("UMA.SyntheticTrials.Count",
1179 synthetic_trials.size());
1180 }
1181
1180 void MetricsService::RecordCurrentHistograms() { 1182 void MetricsService::RecordCurrentHistograms() {
1181 DCHECK(log_manager_.current_log()); 1183 DCHECK(log_manager_.current_log());
1182 histogram_snapshot_manager_.PrepareDeltas( 1184 histogram_snapshot_manager_.PrepareDeltas(
1183 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); 1185 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag);
1184 } 1186 }
1185 1187
1186 void MetricsService::RecordCurrentStabilityHistograms() { 1188 void MetricsService::RecordCurrentStabilityHistograms() {
1187 DCHECK(log_manager_.current_log()); 1189 DCHECK(log_manager_.current_log());
1188 histogram_snapshot_manager_.PrepareDeltas( 1190 histogram_snapshot_manager_.PrepareDeltas(
1189 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); 1191 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag);
(...skipping 25 matching lines...) Expand all
1215 local_state_->SetBoolean(path, value); 1217 local_state_->SetBoolean(path, value);
1216 RecordCurrentState(local_state_); 1218 RecordCurrentState(local_state_);
1217 } 1219 }
1218 1220
1219 void MetricsService::RecordCurrentState(PrefService* pref) { 1221 void MetricsService::RecordCurrentState(PrefService* pref) {
1220 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, 1222 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
1221 base::Time::Now().ToTimeT()); 1223 base::Time::Now().ToTimeT());
1222 } 1224 }
1223 1225
1224 } // namespace metrics 1226 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_service.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698