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

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

Issue 633373011: Histogram for recording actual log upload interval added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Max value of histogram extended and bucket number reduced + few fixes 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
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 #include "components/metrics/metrics_reporting_scheduler.h" 5 #include "components/metrics/metrics_reporting_scheduler.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 TIMER_FIRED_FIRST, 55 TIMER_FIRED_FIRST,
56 INIT_TASK_COMPLETED_FIRST, 56 INIT_TASK_COMPLETED_FIRST,
57 INIT_SEQUENCE_ENUM_SIZE, 57 INIT_SEQUENCE_ENUM_SIZE,
58 }; 58 };
59 59
60 void LogMetricsInitSequence(InitSequence sequence) { 60 void LogMetricsInitSequence(InitSequence sequence) {
61 UMA_HISTOGRAM_ENUMERATION("UMA.InitSequence", sequence, 61 UMA_HISTOGRAM_ENUMERATION("UMA.InitSequence", sequence,
62 INIT_SEQUENCE_ENUM_SIZE); 62 INIT_SEQUENCE_ENUM_SIZE);
63 } 63 }
64 64
65 void LogActualUploadInterval(TimeDelta interval) {
66 UMA_HISTOGRAM_CUSTOM_COUNTS("UMA.ActualLogUploadInterval",
Alexei Svitkine (slow) 2014/10/15 21:14:45 Nit: I think this is indented 1 space too much. Pl
67 interval.InMinutes(),
68 1,
69 base::TimeDelta::FromHours(12).InMinutes(),
70 50);
71 }
72
65 // Returns upload interval specified for the current experiment running. 73 // Returns upload interval specified for the current experiment running.
66 // TODO(gayane): Only for experimenting with upload interval for Android 74 // TODO(gayane): Only for experimenting with upload interval for Android
67 // (bug: 17391128). Should be removed once the experiments are done. 75 // (bug: 17391128). Should be removed once the experiments are done.
68 base::TimeDelta GetUploadIntervalFromExperiment() { 76 base::TimeDelta GetUploadIntervalFromExperiment() {
69 std::string interval_str = variations::GetVariationParamValue( 77 std::string interval_str = variations::GetVariationParamValue(
70 "UMALogUploadInterval", "interval"); 78 "UMALogUploadInterval", "interval");
71 int interval; 79 int interval;
72 if (interval_str.empty() || !base::StringToInt(interval_str, &interval)) 80 if (interval_str.empty() || !base::StringToInt(interval_str, &interval))
73 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); 81 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
74 82
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 callback_pending_ = false; 127 callback_pending_ = false;
120 // If the server is having issues, back off. Otherwise, reset to default 128 // If the server is having issues, back off. Otherwise, reset to default
121 // (unless there are more logs to send, in which case the next upload should 129 // (unless there are more logs to send, in which case the next upload should
122 // happen sooner). 130 // happen sooner).
123 if (!server_is_healthy) { 131 if (!server_is_healthy) {
124 BackOffUploadInterval(); 132 BackOffUploadInterval();
125 } else if (more_logs_remaining) { 133 } else if (more_logs_remaining) {
126 upload_interval_ = TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds); 134 upload_interval_ = TimeDelta::FromSeconds(kUnsentLogsIntervalSeconds);
127 } else { 135 } else {
128 upload_interval_ = GetStandardUploadInterval(); 136 upload_interval_ = GetStandardUploadInterval();
137 last_upload_finish_time_ = base::TimeTicks::Now();
129 } 138 }
130 139
131 if (running_) 140 if (running_)
132 ScheduleNextUpload(); 141 ScheduleNextUpload();
133 } 142 }
134 143
135 void MetricsReportingScheduler::UploadCancelled() { 144 void MetricsReportingScheduler::UploadCancelled() {
136 DCHECK(callback_pending_); 145 DCHECK(callback_pending_);
137 callback_pending_ = false; 146 callback_pending_ = false;
138 if (running_) 147 if (running_)
139 ScheduleNextUpload(); 148 ScheduleNextUpload();
140 } 149 }
141 150
142 void MetricsReportingScheduler::SetUploadIntervalForTesting( 151 void MetricsReportingScheduler::SetUploadIntervalForTesting(
143 base::TimeDelta interval) { 152 base::TimeDelta interval) {
144 upload_interval_ = interval; 153 upload_interval_ = interval;
145 } 154 }
146 155
147 void MetricsReportingScheduler::TriggerUpload() { 156 void MetricsReportingScheduler::TriggerUpload() {
148 // If the timer fired before the init task has completed, don't trigger the 157 // If the timer fired before the init task has completed, don't trigger the
149 // upload yet - wait for the init task to complete and do it then. 158 // upload yet - wait for the init task to complete and do it then.
150 if (!init_task_complete_) { 159 if (!init_task_complete_) {
151 LogMetricsInitSequence(TIMER_FIRED_FIRST); 160 LogMetricsInitSequence(TIMER_FIRED_FIRST);
152 waiting_for_init_task_complete_ = true; 161 waiting_for_init_task_complete_ = true;
153 return; 162 return;
154 } 163 }
164
165 if (!last_upload_finish_time_.is_null()) {
166 LogActualUploadInterval(base::TimeTicks::Now() - last_upload_finish_time_);
167 last_upload_finish_time_= base::TimeTicks();
Alexei Svitkine (slow) 2014/10/15 21:14:45 Nit: Space =.
168 }
169
155 callback_pending_ = true; 170 callback_pending_ = true;
156 upload_callback_.Run(); 171 upload_callback_.Run();
157 } 172 }
158 173
159 void MetricsReportingScheduler::ScheduleNextUpload() { 174 void MetricsReportingScheduler::ScheduleNextUpload() {
160 DCHECK(running_); 175 DCHECK(running_);
161 if (upload_timer_.IsRunning() || callback_pending_) 176 if (upload_timer_.IsRunning() || callback_pending_)
162 return; 177 return;
163 178
164 upload_timer_.Start(FROM_HERE, upload_interval_, this, 179 upload_timer_.Start(FROM_HERE, upload_interval_, this,
(...skipping 14 matching lines...) Expand all
179 194
180 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() { 195 base::TimeDelta MetricsReportingScheduler::GetStandardUploadInterval() {
181 #if defined(OS_ANDROID) 196 #if defined(OS_ANDROID)
182 return GetUploadIntervalFromExperiment(); 197 return GetUploadIntervalFromExperiment();
183 #else 198 #else
184 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds); 199 return TimeDelta::FromSeconds(kStandardUploadIntervalSeconds);
185 #endif 200 #endif
186 } 201 }
187 202
188 } // namespace metrics 203 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_reporting_scheduler.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698