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

Side by Side Diff: components/gcm_driver/gcm_stats_recorder_impl.cc

Issue 409653004: Record latencies of connection and arrival of first message in UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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/gcm_driver/gcm_stats_recorder_impl.h" 5 #include "components/gcm_driver/gcm_stats_recorder_impl.h"
6 6
7 #include <deque> 7 #include <deque>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 default: 136 default:
137 NOTREACHED(); 137 NOTREACHED();
138 return "UNKNOWN_STATUS"; 138 return "UNKNOWN_STATUS";
139 } 139 }
140 } 140 }
141 141
142 } // namespace 142 } // namespace
143 143
144 GCMStatsRecorderImpl::GCMStatsRecorderImpl() 144 GCMStatsRecorderImpl::GCMStatsRecorderImpl()
145 : is_recording_(false), 145 : is_recording_(false),
146 delegate_(NULL) { 146 delegate_(NULL),
147 data_message_received_since_connected_(false) {
147 } 148 }
148 149
149 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { 150 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() {
150 } 151 }
151 152
152 void GCMStatsRecorderImpl::SetRecording(bool recording) { 153 void GCMStatsRecorderImpl::SetRecording(bool recording) {
153 is_recording_ = recording; 154 is_recording_ = recording;
154 } 155 }
155 156
156 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { 157 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 const std::string& details) { 218 const std::string& details) {
218 ConnectionActivity data; 219 ConnectionActivity data;
219 ConnectionActivity* inserted_data = InsertCircularBuffer( 220 ConnectionActivity* inserted_data = InsertCircularBuffer(
220 &connection_activities_, data); 221 &connection_activities_, data);
221 inserted_data->event = event; 222 inserted_data->event = event;
222 inserted_data->details = details; 223 inserted_data->details = details;
223 NotifyActivityRecorded(); 224 NotifyActivityRecorded();
224 } 225 }
225 226
226 void GCMStatsRecorderImpl::RecordConnectionInitiated(const std::string& host) { 227 void GCMStatsRecorderImpl::RecordConnectionInitiated(const std::string& host) {
228 last_connection_initiation_time_ = base::Time::Now();
fgorski 2014/07/22 04:08:36 make sure last_connection_success_time_ is null fo
juyik 2014/07/22 17:51:20 Done.
229 data_message_received_since_connected_ = false;
227 if (!is_recording_) 230 if (!is_recording_)
228 return; 231 return;
229 RecordConnection("Connection initiated", host); 232 RecordConnection("Connection initiated", host);
230 } 233 }
231 234
232 void GCMStatsRecorderImpl::RecordConnectionDelayedDueToBackoff( 235 void GCMStatsRecorderImpl::RecordConnectionDelayedDueToBackoff(
233 int64 delay_msec) { 236 int64 delay_msec) {
234 if (!is_recording_) 237 if (!is_recording_)
235 return; 238 return;
236 RecordConnection("Connection backoff", 239 RecordConnection("Connection backoff",
237 base::StringPrintf("Delayed for %" PRId64 " msec", 240 base::StringPrintf("Delayed for %" PRId64 " msec",
238 delay_msec)); 241 delay_msec));
239 } 242 }
240 243
241 void GCMStatsRecorderImpl::RecordConnectionSuccess() { 244 void GCMStatsRecorderImpl::RecordConnectionSuccess() {
245 DCHECK(!last_connection_initiation_time_.is_null());
246 UMA_HISTOGRAM_COUNTS(
247 "GCM.ConnectionLatency",
248 (base::Time::Now() - last_connection_initiation_time_).InMilliseconds());
249 last_connection_success_time_ = base::Time::Now();
fgorski 2014/07/22 04:08:36 make sure last_connection_initiation_time_ is set
juyik 2014/07/22 17:51:20 Done.
242 if (!is_recording_) 250 if (!is_recording_)
243 return; 251 return;
244 RecordConnection("Connection succeeded", std::string()); 252 RecordConnection("Connection succeeded", std::string());
245 } 253 }
246 254
247 void GCMStatsRecorderImpl::RecordConnectionFailure(int network_error) { 255 void GCMStatsRecorderImpl::RecordConnectionFailure(int network_error) {
248 if (!is_recording_) 256 if (!is_recording_)
249 return; 257 return;
250 RecordConnection("Connection failed", 258 RecordConnection("Connection failed",
251 base::StringPrintf("With network error %d", network_error)); 259 base::StringPrintf("With network error %d", network_error));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 last_received_data_message_burst_start_time_ = new_timestamp; 377 last_received_data_message_burst_start_time_ = new_timestamp;
370 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >= 378 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >=
371 base::TimeDelta::FromSeconds( 379 base::TimeDelta::FromSeconds(
372 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) { 380 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) {
373 UMA_HISTOGRAM_COUNTS( 381 UMA_HISTOGRAM_COUNTS(
374 "GCM.DataMessageBurstReceivedIntervalSeconds", 382 "GCM.DataMessageBurstReceivedIntervalSeconds",
375 (new_timestamp - last_received_data_message_burst_start_time_) 383 (new_timestamp - last_received_data_message_burst_start_time_)
376 .InSeconds()); 384 .InSeconds());
377 last_received_data_message_burst_start_time_ = new_timestamp; 385 last_received_data_message_burst_start_time_ = new_timestamp;
378 } 386 }
387 if (!data_message_received_since_connected_) {
388 DCHECK(!last_connection_success_time_.is_null());
389 UMA_HISTOGRAM_COUNTS(
390 "GCM.FirstReceivedDataMessageLatencyAfterConnection",
391 (new_timestamp - last_connection_success_time_).InMilliseconds());
392 data_message_received_since_connected_ = true;
393 }
379 394
380 if (!is_recording_) 395 if (!is_recording_)
381 return; 396 return;
382 if (!to_registered_app) { 397 if (!to_registered_app) {
383 RecordReceiving(app_id, from, message_byte_size, "Data msg received", 398 RecordReceiving(app_id, from, message_byte_size, "Data msg received",
384 to_registered_app ? std::string() : 399 to_registered_app ? std::string() :
385 "No such registered app found"); 400 "No such registered app found");
386 } else { 401 } else {
387 switch(message_type) { 402 switch(message_type) {
388 case GCMStatsRecorderImpl::DATA_MESSAGE: 403 case GCMStatsRecorderImpl::DATA_MESSAGE:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const std::string& receiver_id, 490 const std::string& receiver_id,
476 const std::string& message_id) { 491 const std::string& message_id) {
477 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); 492 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1);
478 if (!is_recording_) 493 if (!is_recording_)
479 return; 494 return;
480 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", 495 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg",
481 std::string()); 496 std::string());
482 } 497 }
483 498
484 } // namespace gcm 499 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_stats_recorder_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698