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

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: fixes test failures. Created 6 years, 4 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),
148 received_data_message_burst_size_(0) {
147 } 149 }
148 150
149 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() { 151 GCMStatsRecorderImpl::~GCMStatsRecorderImpl() {
150 } 152 }
151 153
152 void GCMStatsRecorderImpl::SetRecording(bool recording) { 154 void GCMStatsRecorderImpl::SetRecording(bool recording) {
153 is_recording_ = recording; 155 is_recording_ = recording;
154 } 156 }
155 157
156 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) { 158 void GCMStatsRecorderImpl::SetDelegate(Delegate* delegate) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 const std::string& details) { 219 const std::string& details) {
218 ConnectionActivity data; 220 ConnectionActivity data;
219 ConnectionActivity* inserted_data = InsertCircularBuffer( 221 ConnectionActivity* inserted_data = InsertCircularBuffer(
220 &connection_activities_, data); 222 &connection_activities_, data);
221 inserted_data->event = event; 223 inserted_data->event = event;
222 inserted_data->details = details; 224 inserted_data->details = details;
223 NotifyActivityRecorded(); 225 NotifyActivityRecorded();
224 } 226 }
225 227
226 void GCMStatsRecorderImpl::RecordConnectionInitiated(const std::string& host) { 228 void GCMStatsRecorderImpl::RecordConnectionInitiated(const std::string& host) {
229 last_connection_initiation_time_ = base::TimeTicks::Now();
230 last_connection_success_time_ = base::TimeTicks();
231 data_message_received_since_connected_ = false;
227 if (!is_recording_) 232 if (!is_recording_)
228 return; 233 return;
229 RecordConnection("Connection initiated", host); 234 RecordConnection("Connection initiated", host);
230 } 235 }
231 236
232 void GCMStatsRecorderImpl::RecordConnectionDelayedDueToBackoff( 237 void GCMStatsRecorderImpl::RecordConnectionDelayedDueToBackoff(
233 int64 delay_msec) { 238 int64 delay_msec) {
234 if (!is_recording_) 239 if (!is_recording_)
235 return; 240 return;
236 RecordConnection("Connection backoff", 241 RecordConnection("Connection backoff",
237 base::StringPrintf("Delayed for %" PRId64 " msec", 242 base::StringPrintf("Delayed for %" PRId64 " msec",
238 delay_msec)); 243 delay_msec));
239 } 244 }
240 245
241 void GCMStatsRecorderImpl::RecordConnectionSuccess() { 246 void GCMStatsRecorderImpl::RecordConnectionSuccess() {
247 DCHECK(!last_connection_initiation_time_.is_null());
248 UMA_HISTOGRAM_MEDIUM_TIMES(
249 "GCM.ConnectionLatency",
250 (base::TimeTicks::Now() - last_connection_initiation_time_));
251 last_connection_success_time_ = base::TimeTicks::Now();
252 last_connection_initiation_time_ = base::TimeTicks();
242 if (!is_recording_) 253 if (!is_recording_)
243 return; 254 return;
244 RecordConnection("Connection succeeded", std::string()); 255 RecordConnection("Connection succeeded", std::string());
245 } 256 }
246 257
247 void GCMStatsRecorderImpl::RecordConnectionFailure(int network_error) { 258 void GCMStatsRecorderImpl::RecordConnectionFailure(int network_error) {
248 if (!is_recording_) 259 if (!is_recording_)
249 return; 260 return;
250 RecordConnection("Connection failed", 261 RecordConnection("Connection failed",
251 base::StringPrintf("With network error %d", network_error)); 262 base::StringPrintf("With network error %d", network_error));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 368
358 void GCMStatsRecorderImpl::RecordDataMessageReceived( 369 void GCMStatsRecorderImpl::RecordDataMessageReceived(
359 const std::string& app_id, 370 const std::string& app_id,
360 const std::string& from, 371 const std::string& from,
361 int message_byte_size, 372 int message_byte_size,
362 bool to_registered_app, 373 bool to_registered_app,
363 ReceivedMessageType message_type) { 374 ReceivedMessageType message_type) {
364 if (to_registered_app) 375 if (to_registered_app)
365 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceived", 1); 376 UMA_HISTOGRAM_COUNTS("GCM.DataMessageReceived", 1);
366 377
367 base::Time new_timestamp = base::Time::Now(); 378 base::TimeTicks new_timestamp = base::TimeTicks::Now();
368 if (last_received_data_message_burst_start_time_.is_null()) { 379 if (last_received_data_message_burst_start_time_.is_null()) {
369 last_received_data_message_burst_start_time_ = new_timestamp; 380 last_received_data_message_burst_start_time_ = new_timestamp;
381 last_received_data_message_time_within_burst_ = new_timestamp;
382 received_data_message_burst_size_ = 1;
370 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >= 383 } else if ((new_timestamp - last_received_data_message_burst_start_time_) >=
371 base::TimeDelta::FromSeconds( 384 base::TimeDelta::FromSeconds(
372 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) { 385 RECEIVED_DATA_MESSAGE_BURST_LENGTH_SECONDS)) {
373 UMA_HISTOGRAM_COUNTS( 386 UMA_HISTOGRAM_LONG_TIMES(
374 "GCM.DataMessageBurstReceivedIntervalSeconds", 387 "GCM.DataMessageBurstReceivedInterval",
375 (new_timestamp - last_received_data_message_burst_start_time_) 388 (new_timestamp - last_received_data_message_burst_start_time_));
376 .InSeconds()); 389 UMA_HISTOGRAM_COUNTS("GCM.ReceivedDataMessageBurstSize",
390 received_data_message_burst_size_);
377 last_received_data_message_burst_start_time_ = new_timestamp; 391 last_received_data_message_burst_start_time_ = new_timestamp;
392 last_received_data_message_time_within_burst_ = new_timestamp;
393 received_data_message_burst_size_ = 1;
394 } else {
395 UMA_HISTOGRAM_TIMES(
396 "GCM.ReceivedDataMessageIntervalWithinBurst",
397 (new_timestamp - last_received_data_message_time_within_burst_));
398 last_received_data_message_time_within_burst_ = new_timestamp;
399 ++received_data_message_burst_size_;
400 }
401 if (!data_message_received_since_connected_) {
402 DCHECK(!last_connection_success_time_.is_null());
403 UMA_HISTOGRAM_TIMES("GCM.FirstReceivedDataMessageLatencyAfterConnection",
404 (new_timestamp - last_connection_success_time_));
405 data_message_received_since_connected_ = true;
378 } 406 }
379 407
380 if (!is_recording_) 408 if (!is_recording_)
381 return; 409 return;
382 if (!to_registered_app) { 410 if (!to_registered_app) {
383 RecordReceiving(app_id, from, message_byte_size, "Data msg received", 411 RecordReceiving(app_id,
384 to_registered_app ? std::string() : 412 from,
385 "No such registered app found"); 413 message_byte_size,
414 "Data msg received",
415 "No such registered app found");
386 } else { 416 } else {
387 switch(message_type) { 417 switch(message_type) {
388 case GCMStatsRecorderImpl::DATA_MESSAGE: 418 case GCMStatsRecorderImpl::DATA_MESSAGE:
389 RecordReceiving(app_id, from, message_byte_size, "Data msg received", 419 RecordReceiving(app_id, from, message_byte_size, "Data msg received",
390 std::string()); 420 std::string());
391 break; 421 break;
392 case GCMStatsRecorderImpl::DELETED_MESSAGES: 422 case GCMStatsRecorderImpl::DELETED_MESSAGES:
393 RecordReceiving(app_id, from, message_byte_size, "Data msg received", 423 RecordReceiving(app_id, from, message_byte_size, "Data msg received",
394 "Message has been deleted on server"); 424 "Message has been deleted on server");
395 break; 425 break;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 const std::string& receiver_id, 505 const std::string& receiver_id,
476 const std::string& message_id) { 506 const std::string& message_id) {
477 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1); 507 UMA_HISTOGRAM_COUNTS("GCM.IncomingSendErrors", 1);
478 if (!is_recording_) 508 if (!is_recording_)
479 return; 509 return;
480 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg", 510 RecordSending(app_id, receiver_id, message_id, "Received 'send error' msg",
481 std::string()); 511 std::string());
482 } 512 }
483 513
484 } // namespace gcm 514 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_stats_recorder_impl.h ('k') | components/gcm_driver/gcm_stats_recorder_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698