OLD | NEW |
---|---|
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 | 126 |
127 #include <stddef.h> | 127 #include <stddef.h> |
128 #include <algorithm> | 128 #include <algorithm> |
129 #include <utility> | 129 #include <utility> |
130 | 130 |
131 #include "base/bind.h" | 131 #include "base/bind.h" |
132 #include "base/callback.h" | 132 #include "base/callback.h" |
133 #include "base/location.h" | 133 #include "base/location.h" |
134 #include "base/metrics/histogram_base.h" | 134 #include "base/metrics/histogram_base.h" |
135 #include "base/metrics/histogram_macros.h" | 135 #include "base/metrics/histogram_macros.h" |
136 #include "base/metrics/histogram_persistence.h" | |
136 #include "base/metrics/histogram_samples.h" | 137 #include "base/metrics/histogram_samples.h" |
137 #include "base/metrics/sparse_histogram.h" | 138 #include "base/metrics/sparse_histogram.h" |
138 #include "base/metrics/statistics_recorder.h" | 139 #include "base/metrics/statistics_recorder.h" |
139 #include "base/prefs/pref_registry_simple.h" | 140 #include "base/prefs/pref_registry_simple.h" |
140 #include "base/prefs/pref_service.h" | 141 #include "base/prefs/pref_service.h" |
141 #include "base/rand_util.h" | 142 #include "base/rand_util.h" |
142 #include "base/single_thread_task_runner.h" | 143 #include "base/single_thread_task_runner.h" |
143 #include "base/strings/string_number_conversions.h" | 144 #include "base/strings/string_number_conversions.h" |
144 #include "base/strings/utf_string_conversions.h" | 145 #include "base/strings/utf_string_conversions.h" |
145 #include "base/thread_task_runner_handle.h" | 146 #include "base/thread_task_runner_handle.h" |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
733 | 734 |
734 // TODO(jar): Integrate bounds on log recording more consistently, so that we | 735 // TODO(jar): Integrate bounds on log recording more consistently, so that we |
735 // can stop recording logs that are too big much sooner. | 736 // can stop recording logs that are too big much sooner. |
736 if (log_manager_.current_log()->num_events() > kEventLimit) { | 737 if (log_manager_.current_log()->num_events() > kEventLimit) { |
737 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", | 738 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", |
738 log_manager_.current_log()->num_events()); | 739 log_manager_.current_log()->num_events()); |
739 log_manager_.DiscardCurrentLog(); | 740 log_manager_.DiscardCurrentLog(); |
740 OpenNewLog(); // Start trivial log to hold our histograms. | 741 OpenNewLog(); // Start trivial log to hold our histograms. |
741 } | 742 } |
742 | 743 |
744 // If a persistent allocator is in use, update its internal histograms (such | |
745 // as how much memory is being used) before reporting. | |
746 base::PersistentMemoryAllocator* allocator = | |
747 base::GetPersistentHistogramMemoryAllocator(); | |
748 if (allocator) | |
749 allocator->UpdateStaticHistograms(); | |
750 | |
743 // Put incremental data (histogram deltas, and realtime stats deltas) at the | 751 // Put incremental data (histogram deltas, and realtime stats deltas) at the |
744 // end of all log transmissions (initial log handles this separately). | 752 // end of all log transmissions (initial log handles this separately). |
745 // RecordIncrementalStabilityElements only exists on the derived | 753 // RecordIncrementalStabilityElements only exists on the derived |
746 // MetricsLog class. | 754 // MetricsLog class. |
747 MetricsLog* current_log = log_manager_.current_log(); | 755 MetricsLog* current_log = log_manager_.current_log(); |
748 DCHECK(current_log); | 756 DCHECK(current_log); |
749 RecordCurrentEnvironment(current_log); | 757 RecordCurrentEnvironment(current_log); |
750 base::TimeDelta incremental_uptime; | 758 base::TimeDelta incremental_uptime; |
751 base::TimeDelta uptime; | 759 base::TimeDelta uptime; |
752 GetUptimes(local_state_, &incremental_uptime, &uptime); | 760 GetUptimes(local_state_, &incremental_uptime, &uptime); |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1093 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { | 1101 void MetricsService::RecordCurrentEnvironment(MetricsLog* log) { |
1094 std::vector<variations::ActiveGroupId> synthetic_trials; | 1102 std::vector<variations::ActiveGroupId> synthetic_trials; |
1095 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); | 1103 GetSyntheticFieldTrialsOlderThan(log->creation_time(), &synthetic_trials); |
1096 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, | 1104 log->RecordEnvironment(metrics_providers_.get(), synthetic_trials, |
1097 GetInstallDate(), GetMetricsReportingEnabledDate()); | 1105 GetInstallDate(), GetMetricsReportingEnabledDate()); |
1098 } | 1106 } |
1099 | 1107 |
1100 void MetricsService::RecordCurrentHistograms() { | 1108 void MetricsService::RecordCurrentHistograms() { |
1101 DCHECK(log_manager_.current_log()); | 1109 DCHECK(log_manager_.current_log()); |
1102 histogram_snapshot_manager_.PrepareDeltas( | 1110 histogram_snapshot_manager_.PrepareDeltas( |
1111 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), | |
1103 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); | 1112 base::Histogram::kNoFlags, base::Histogram::kUmaTargetedHistogramFlag); |
1104 } | 1113 } |
1105 | 1114 |
1106 void MetricsService::RecordCurrentStabilityHistograms() { | 1115 void MetricsService::RecordCurrentStabilityHistograms() { |
1107 DCHECK(log_manager_.current_log()); | 1116 DCHECK(log_manager_.current_log()); |
1108 histogram_snapshot_manager_.PrepareDeltas( | 1117 histogram_snapshot_manager_.PrepareDeltas( |
1118 base::StatisticsRecorder::begin(true), base::StatisticsRecorder::end(), | |
Alexei Svitkine (slow)
2016/01/18 19:25:36
For all the calls to begin(), can you add a commen
bcwhite
2016/01/22 15:24:53
Done.
| |
1109 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); | 1119 base::Histogram::kNoFlags, base::Histogram::kUmaStabilityHistogramFlag); |
1110 } | 1120 } |
1111 | 1121 |
1112 void MetricsService::LogCleanShutdown() { | 1122 void MetricsService::LogCleanShutdown() { |
1113 // Redundant setting to assure that we always reset this value at shutdown | 1123 // Redundant setting to assure that we always reset this value at shutdown |
1114 // (and that we don't use some alternate path, and not call LogCleanShutdown). | 1124 // (and that we don't use some alternate path, and not call LogCleanShutdown). |
1115 clean_shutdown_status_ = CLEANLY_SHUTDOWN; | 1125 clean_shutdown_status_ = CLEANLY_SHUTDOWN; |
1116 | 1126 |
1117 clean_exit_beacon_.WriteBeaconValue(true); | 1127 clean_exit_beacon_.WriteBeaconValue(true); |
1118 RecordCurrentState(local_state_); | 1128 RecordCurrentState(local_state_); |
(...skipping 19 matching lines...) Expand all Loading... | |
1138 base::Time::Now().ToTimeT()); | 1148 base::Time::Now().ToTimeT()); |
1139 } | 1149 } |
1140 | 1150 |
1141 void MetricsService::SkipAndDiscardUpload() { | 1151 void MetricsService::SkipAndDiscardUpload() { |
1142 log_manager_.DiscardStagedLog(); | 1152 log_manager_.DiscardStagedLog(); |
1143 scheduler_->UploadCancelled(); | 1153 scheduler_->UploadCancelled(); |
1144 log_upload_in_progress_ = false; | 1154 log_upload_in_progress_ = false; |
1145 } | 1155 } |
1146 | 1156 |
1147 } // namespace metrics | 1157 } // namespace metrics |
OLD | NEW |