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

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

Issue 523153002: Add a histogram to log the size of an UMA upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename. Created 6 years, 3 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 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 // Log a histogram to track response success vs. failure rates. 1019 // Log a histogram to track response success vs. failure rates.
1020 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf", 1020 UMA_HISTOGRAM_ENUMERATION("UMA.UploadResponseStatus.Protobuf",
1021 ResponseCodeToStatus(response_code), 1021 ResponseCodeToStatus(response_code),
1022 NUM_RESPONSE_STATUSES); 1022 NUM_RESPONSE_STATUSES);
1023 1023
1024 bool upload_succeeded = response_code == 200; 1024 bool upload_succeeded = response_code == 200;
1025 1025
1026 // Provide boolean for error recovery (allow us to ignore response_code). 1026 // Provide boolean for error recovery (allow us to ignore response_code).
1027 bool discard_log = false; 1027 bool discard_log = false;
1028 const size_t log_size = log_manager_.staged_log().length(); 1028 const size_t log_size = log_manager_.staged_log().length();
1029 if (!upload_succeeded && log_size > kUploadLogAvoidRetransmitSize) { 1029 if (upload_succeeded) {
1030 UMA_HISTOGRAM_COUNTS_10000("UMA.LogSize.OnSuccess", log_size / 1024);
1031 } else if (log_size > kUploadLogAvoidRetransmitSize) {
1030 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded", 1032 UMA_HISTOGRAM_COUNTS("UMA.Large Rejected Log was Discarded",
1031 static_cast<int>(log_size)); 1033 static_cast<int>(log_size));
1032 discard_log = true; 1034 discard_log = true;
1033 } else if (response_code == 400) { 1035 } else if (response_code == 400) {
1034 // Bad syntax. Retransmission won't work. 1036 // Bad syntax. Retransmission won't work.
1035 discard_log = true; 1037 discard_log = true;
1036 } 1038 }
1037 1039
1038 if (upload_succeeded || discard_log) { 1040 if (upload_succeeded || discard_log) {
1039 log_manager_.DiscardStagedLog(); 1041 log_manager_.DiscardStagedLog();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 local_state_->SetBoolean(path, value); 1188 local_state_->SetBoolean(path, value);
1187 RecordCurrentState(local_state_); 1189 RecordCurrentState(local_state_);
1188 } 1190 }
1189 1191
1190 void MetricsService::RecordCurrentState(PrefService* pref) { 1192 void MetricsService::RecordCurrentState(PrefService* pref) {
1191 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec, 1193 pref->SetInt64(metrics::prefs::kStabilityLastTimestampSec,
1192 base::Time::Now().ToTimeT()); 1194 base::Time::Now().ToTimeT());
1193 } 1195 }
1194 1196
1195 } // namespace metrics 1197 } // 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