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

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

Issue 650233006: Remove UMAInitialMetricsTiming Trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 9 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 | no next file » | 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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 return NO_RESPONSE; 241 return NO_RESPONSE;
242 case 200: 242 case 200:
243 return SUCCESS; 243 return SUCCESS;
244 case 400: 244 case 400:
245 return BAD_REQUEST; 245 return BAD_REQUEST;
246 default: 246 default:
247 return UNKNOWN_FAILURE; 247 return UNKNOWN_FAILURE;
248 } 248 }
249 } 249 }
250 250
251 bool NewInitialMetricsTimingEnabled() {
252 return base::FieldTrialList::FindFullName("UMAInitialMetricsTiming") ==
253 "Enabled";
254 }
255
256 void MarkAppCleanShutdownAndCommit(CleanExitBeacon* clean_exit_beacon, 251 void MarkAppCleanShutdownAndCommit(CleanExitBeacon* clean_exit_beacon,
257 PrefService* local_state) { 252 PrefService* local_state) {
258 clean_exit_beacon->WriteBeaconValue(true); 253 clean_exit_beacon->WriteBeaconValue(true);
259 local_state->SetInteger(prefs::kStabilityExecutionPhase, 254 local_state->SetInteger(prefs::kStabilityExecutionPhase,
260 MetricsService::SHUTDOWN_COMPLETE); 255 MetricsService::SHUTDOWN_COMPLETE);
261 // Start writing right away (write happens on a different thread). 256 // Start writing right away (write happens on a different thread).
262 local_state->CommitPendingWrite(); 257 local_state->CommitPendingWrite();
263 } 258 }
264 259
265 } // namespace 260 } // namespace
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 if (log_manager_.has_staged_log()) 877 if (log_manager_.has_staged_log())
883 return; 878 return;
884 879
885 switch (state_) { 880 switch (state_) {
886 case INITIALIZED: 881 case INITIALIZED:
887 case INIT_TASK_SCHEDULED: // We should be further along by now. 882 case INIT_TASK_SCHEDULED: // We should be further along by now.
888 NOTREACHED(); 883 NOTREACHED();
889 return; 884 return;
890 885
891 case INIT_TASK_DONE: 886 case INIT_TASK_DONE:
892 if (NewInitialMetricsTimingEnabled()) { 887 PrepareInitialMetricsLog();
893 PrepareInitialMetricsLog(); 888 // Stage the first log, which could be a stability log (either one
894 // Stage the first log, which could be a stability log (either one 889 // for created in this session or from a previous session) or the
895 // for created in this session or from a previous session) or the 890 // initial metrics log that was just created.
896 // initial metrics log that was just created. 891 log_manager_.StageNextLogForUpload();
897 log_manager_.StageNextLogForUpload(); 892 if (has_initial_stability_log_) {
898 if (has_initial_stability_log_) { 893 // The initial stability log was just staged.
899 // The initial stability log was just staged. 894 has_initial_stability_log_ = false;
900 has_initial_stability_log_ = false; 895 state_ = SENDING_INITIAL_STABILITY_LOG;
901 state_ = SENDING_INITIAL_STABILITY_LOG;
902 } else {
903 state_ = SENDING_INITIAL_METRICS_LOG;
904 }
905 } else { 896 } else {
906 if (has_initial_stability_log_) { 897 state_ = SENDING_INITIAL_METRICS_LOG;
907 // There's an initial stability log, ready to send.
908 log_manager_.StageNextLogForUpload();
909 has_initial_stability_log_ = false;
910 state_ = SENDING_INITIAL_STABILITY_LOG;
911 } else {
912 PrepareInitialMetricsLog();
913 log_manager_.StageNextLogForUpload();
914 state_ = SENDING_INITIAL_METRICS_LOG;
915 }
916 } 898 }
917 break; 899 break;
918 900
919 case SENDING_OLD_LOGS: 901 case SENDING_OLD_LOGS:
920 NOTREACHED(); // Shouldn't be staging a new log during old log sending. 902 NOTREACHED(); // Shouldn't be staging a new log during old log sending.
921 return; 903 return;
922 904
923 case SENDING_CURRENT_LOGS: 905 case SENDING_CURRENT_LOGS:
924 CloseCurrentLog(); 906 CloseCurrentLog();
925 OpenNewLog(); 907 OpenNewLog();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 1022
1041 void MetricsService::OnLogUploadComplete(int response_code) { 1023 void MetricsService::OnLogUploadComplete(int response_code) {
1042 DCHECK(log_upload_in_progress_); 1024 DCHECK(log_upload_in_progress_);
1043 log_upload_in_progress_ = false; 1025 log_upload_in_progress_ = false;
1044 1026
1045 // Log a histogram to track response success vs. failure rates. 1027 // Log a histogram to track response success vs. failure rates.
1046 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf", 1028 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf",
1047 ResponseCodeToStatus(response_code), 1029 ResponseCodeToStatus(response_code),
1048 NUM_RESPONSE_STATUSES); 1030 NUM_RESPONSE_STATUSES);
1049 1031
1050 bool suppress_reschedule = false;
1051
1052 bool upload_succeeded = response_code == 200; 1032 bool upload_succeeded = response_code == 200;
1053 1033
1054 // Provide boolean for error recovery (allow us to ignore response_code). 1034 // Provide boolean for error recovery (allow us to ignore response_code).
1055 bool discard_log = false; 1035 bool discard_log = false;
1056 const size_t log_size = log_manager_.staged_log().length(); 1036 const size_t log_size = log_manager_.staged_log().length();
1057 if (upload_succeeded) { 1037 if (upload_succeeded) {
1058 UMA_HISTOGRAM_COUNTS_10000("UMA.LogSize.OnSuccess", log_size / 1024); 1038 UMA_HISTOGRAM_COUNTS_10000("UMA.LogSize.OnSuccess", log_size / 1024);
1059 } else if (log_size > kUploadLogAvoidRetransmitSize) { 1039 } else if (log_size > kUploadLogAvoidRetransmitSize) {
1060 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded", 1040 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded",
1061 static_cast<int>(log_size)); 1041 static_cast<int>(log_size));
1062 discard_log = true; 1042 discard_log = true;
1063 } else if (response_code == 400) { 1043 } else if (response_code == 400) {
1064 // Bad syntax. Retransmission won't work. 1044 // Bad syntax. Retransmission won't work.
1065 discard_log = true; 1045 discard_log = true;
1066 } 1046 }
1067 1047
1068 if (upload_succeeded || discard_log) { 1048 if (upload_succeeded || discard_log) {
1069 log_manager_.DiscardStagedLog(); 1049 log_manager_.DiscardStagedLog();
1070 // Store the updated list to disk now that the removed log is uploaded. 1050 // Store the updated list to disk now that the removed log is uploaded.
1071 log_manager_.PersistUnsentLogs(); 1051 log_manager_.PersistUnsentLogs();
1072 } 1052 }
1073 1053
1074 if (!log_manager_.has_staged_log()) { 1054 if (!log_manager_.has_staged_log()) {
1075 switch (state_) { 1055 switch (state_) {
1076 case SENDING_INITIAL_STABILITY_LOG: 1056 case SENDING_INITIAL_STABILITY_LOG:
1077 if (NewInitialMetricsTimingEnabled()) { 1057 // The initial metrics log is already in the queue of unsent logs.
1078 // The initial metrics log is already in the queue of unsent logs. 1058 state_ = SENDING_OLD_LOGS;
1079 state_ = SENDING_OLD_LOGS;
1080 } else {
1081 PrepareInitialMetricsLog();
1082 log_manager_.StageNextLogForUpload();
1083 SendStagedLog();
1084 state_ = SENDING_INITIAL_METRICS_LOG;
1085 suppress_reschedule = true;
1086 }
1087 break; 1059 break;
1088 1060
1089 case SENDING_INITIAL_METRICS_LOG: 1061 case SENDING_INITIAL_METRICS_LOG:
1090 state_ = log_manager_.has_unsent_logs() ? SENDING_OLD_LOGS 1062 state_ = log_manager_.has_unsent_logs() ? SENDING_OLD_LOGS
1091 : SENDING_CURRENT_LOGS; 1063 : SENDING_CURRENT_LOGS;
1092 break; 1064 break;
1093 1065
1094 case SENDING_OLD_LOGS: 1066 case SENDING_OLD_LOGS:
1095 if (!log_manager_.has_unsent_logs()) 1067 if (!log_manager_.has_unsent_logs())
1096 state_ = SENDING_CURRENT_LOGS; 1068 state_ = SENDING_CURRENT_LOGS;
1097 break; 1069 break;
1098 1070
1099 case SENDING_CURRENT_LOGS: 1071 case SENDING_CURRENT_LOGS:
1100 break; 1072 break;
1101 1073
1102 default: 1074 default:
1103 NOTREACHED(); 1075 NOTREACHED();
1104 break; 1076 break;
1105 } 1077 }
1106 1078
1107 if (log_manager_.has_unsent_logs()) 1079 if (log_manager_.has_unsent_logs())
1108 DCHECK_LT(state_, SENDING_CURRENT_LOGS); 1080 DCHECK_LT(state_, SENDING_CURRENT_LOGS);
1109 } 1081 }
1110 1082
1111 // Error 400 indicates a problem with the log, not with the server, so 1083 // Error 400 indicates a problem with the log, not with the server, so
1112 // don't consider that a sign that the server is in trouble. 1084 // don't consider that a sign that the server is in trouble.
1113 bool server_is_healthy = upload_succeeded || response_code == 400; 1085 bool server_is_healthy = upload_succeeded || response_code == 400;
1114 // Don't notify the scheduler that the upload is finished if we've only just 1086 scheduler_->UploadFinished(server_is_healthy, log_manager_.has_unsent_logs());
1115 // sent the initial stability log, but not yet the initial metrics log (treat
1116 // the two as a single unit of work as far as the scheduler is concerned).
1117 if (!suppress_reschedule) {
1118 scheduler_->UploadFinished(server_is_healthy,
1119 log_manager_.has_unsent_logs());
1120 }
1121 1087
1122 if (server_is_healthy) 1088 if (server_is_healthy)
1123 client_->OnLogUploadComplete(); 1089 client_->OnLogUploadComplete();
1124 } 1090 }
1125 1091
1126 void MetricsService::IncrementPrefValue(const char* path) { 1092 void MetricsService::IncrementPrefValue(const char* path) {
1127 int value = local_state_->GetInteger(path); 1093 int value = local_state_->GetInteger(path);
1128 local_state_->SetInteger(path, value + 1); 1094 local_state_->SetInteger(path, value + 1);
1129 } 1095 }
1130 1096
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 base::Time::Now().ToTimeT()); 1224 base::Time::Now().ToTimeT());
1259 } 1225 }
1260 1226
1261 void MetricsService::SetConnectionTypeCallback( 1227 void MetricsService::SetConnectionTypeCallback(
1262 base::Callback<void(bool*)> is_cellular_callback) { 1228 base::Callback<void(bool*)> is_cellular_callback) {
1263 DCHECK(!scheduler_); 1229 DCHECK(!scheduler_);
1264 is_cellular_callback_ = is_cellular_callback; 1230 is_cellular_callback_ = is_cellular_callback;
1265 } 1231 }
1266 1232
1267 } // namespace metrics 1233 } // namespace metrics
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698