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

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

Issue 2646163004: Add a feature to control if we drop records due to excess events. Enabled by default as this is cur… (Closed)
Patch Set: wording Created 3 years, 11 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 | « no previous file | 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 namespace { 172 namespace {
173 173
174 // This feature moves the upload schedule to a seperate schedule from the 174 // This feature moves the upload schedule to a seperate schedule from the
175 // log rotation schedule. This may change upload timing slightly, but 175 // log rotation schedule. This may change upload timing slightly, but
176 // would allow some compartmentalization of uploader logic to allow more 176 // would allow some compartmentalization of uploader logic to allow more
177 // code reuse between different metrics services. 177 // code reuse between different metrics services.
178 const base::Feature kUploadSchedulerFeature{"UMAUploadScheduler", 178 const base::Feature kUploadSchedulerFeature{"UMAUploadScheduler",
179 base::FEATURE_DISABLED_BY_DEFAULT}; 179 base::FEATURE_DISABLED_BY_DEFAULT};
180 180
181 // This drops records if the number of events (user action and omnibox) exceeds
182 // the kEventLimit.
183 const base::Feature kUMAThrottleEvents{"UMAThrottleEvents",
184 base::FEATURE_ENABLED_BY_DEFAULT};
185
181 bool HasUploadScheduler() { 186 bool HasUploadScheduler() {
182 return base::FeatureList::IsEnabled(kUploadSchedulerFeature); 187 return base::FeatureList::IsEnabled(kUploadSchedulerFeature);
183 } 188 }
184 189
185 // Check to see that we're being called on only one thread. 190 // Check to see that we're being called on only one thread.
186 bool IsSingleThreaded() { 191 bool IsSingleThreaded() {
187 static base::PlatformThreadId thread_id = 0; 192 static base::PlatformThreadId thread_id = 0;
188 if (!thread_id) 193 if (!thread_id)
189 thread_id = base::PlatformThread::CurrentId(); 194 thread_id = base::PlatformThread::CurrentId();
190 return base::PlatformThread::CurrentId() == thread_id; 195 return base::PlatformThread::CurrentId() == thread_id;
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 void MetricsService::StartInitTask() { 801 void MetricsService::StartInitTask() {
797 client_->InitializeSystemProfileMetrics( 802 client_->InitializeSystemProfileMetrics(
798 base::Bind(&MetricsService::FinishedInitTask, 803 base::Bind(&MetricsService::FinishedInitTask,
799 self_ptr_factory_.GetWeakPtr())); 804 self_ptr_factory_.GetWeakPtr()));
800 } 805 }
801 806
802 void MetricsService::CloseCurrentLog() { 807 void MetricsService::CloseCurrentLog() {
803 if (!log_manager_.current_log()) 808 if (!log_manager_.current_log())
804 return; 809 return;
805 810
806 // TODO(jar): Integrate bounds on log recording more consistently, so that we 811 // TODO(rkaplow): Evaluate if this is needed.
807 // can stop recording logs that are too big much sooner.
808 if (log_manager_.current_log()->num_events() > kEventLimit) { 812 if (log_manager_.current_log()->num_events() > kEventLimit) {
809 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events", 813 UMA_HISTOGRAM_COUNTS("UMA.Discarded Log Events",
810 log_manager_.current_log()->num_events()); 814 log_manager_.current_log()->num_events());
811 log_manager_.DiscardCurrentLog(); 815 if (base::FeatureList::IsEnabled(kUMAThrottleEvents)) {
812 OpenNewLog(); // Start trivial log to hold our histograms. 816 log_manager_.DiscardCurrentLog();
817 OpenNewLog(); // Start trivial log to hold our histograms.
818 }
813 } 819 }
814 820
815 // If a persistent allocator is in use, update its internal histograms (such 821 // If a persistent allocator is in use, update its internal histograms (such
816 // as how much memory is being used) before reporting. 822 // as how much memory is being used) before reporting.
817 base::PersistentHistogramAllocator* allocator = 823 base::PersistentHistogramAllocator* allocator =
818 base::GlobalHistogramAllocator::Get(); 824 base::GlobalHistogramAllocator::Get();
819 if (allocator) 825 if (allocator)
820 allocator->UpdateTrackingHistograms(); 826 allocator->UpdateTrackingHistograms();
821 827
822 // Put incremental data (histogram deltas, and realtime stats deltas) at the 828 // Put incremental data (histogram deltas, and realtime stats deltas) at the
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed); 1312 local_state_->SetBoolean(prefs::kStabilitySessionEndCompleted, end_completed);
1307 RecordCurrentState(local_state_); 1313 RecordCurrentState(local_state_);
1308 } 1314 }
1309 1315
1310 void MetricsService::RecordCurrentState(PrefService* pref) { 1316 void MetricsService::RecordCurrentState(PrefService* pref) {
1311 pref->SetInt64(prefs::kStabilityLastTimestampSec, 1317 pref->SetInt64(prefs::kStabilityLastTimestampSec,
1312 base::Time::Now().ToTimeT()); 1318 base::Time::Now().ToTimeT());
1313 } 1319 }
1314 1320
1315 } // namespace metrics 1321 } // namespace metrics
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698