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

Side by Side Diff: components/browser_watcher/postmortem_report_collector.cc

Issue 2883103002: Quantify instability according to the stability instrumentation (Closed)
Patch Set: address Siggi's comments Created 3 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser_watcher/postmortem_report_collector.h" 5 #include "components/browser_watcher/postmortem_report_collector.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 // Determine the crashpad client id. 85 // Determine the crashpad client id.
86 crashpad::UUID client_id; 86 crashpad::UUID client_id;
87 crashpad::Settings* settings = report_database->GetSettings(); 87 crashpad::Settings* settings = report_database->GetSettings();
88 if (settings) { 88 if (settings) {
89 // If GetSettings() or GetClientID() fails client_id will be left at its 89 // If GetSettings() or GetClientID() fails client_id will be left at its
90 // default value, all zeroes, which is appropriate. 90 // default value, all zeroes, which is appropriate.
91 settings->GetClientID(&client_id); 91 settings->GetClientID(&client_id);
92 } 92 }
93 93
94 // Number of unclean shutdowns based on successful collection of stability
95 // reports.
96 int unclean_cnt = 0;
97 // Number of unclean shutdowns that may be attributable to system instability
98 // based on successful collection of stability reports. This number should be
99 // smaller or equal to |unclean_cnt|.
100 int unclean_system_cnt = 0;
101
94 // Process each stability file. 102 // Process each stability file.
95 int success_cnt = 0;
96 for (const FilePath& file : debug_files) { 103 for (const FilePath& file : debug_files) {
97 CollectionStatus status = 104 CollectionStatus status = CollectAndSubmitOneReport(
98 CollectAndSubmitOneReport(client_id, file, report_database); 105 client_id, file, report_database, &unclean_system_cnt);
99 // TODO(manzagop): consider making this a stability metric. 106 // TODO(manzagop): consider making this a stability metric.
100 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Collect.Status", status, 107 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Collect.Status", status,
101 COLLECTION_STATUS_MAX); 108 COLLECTION_STATUS_MAX);
102 if (status == SUCCESS) 109 if (status == SUCCESS)
Sigurður Ásgeirsson 2017/05/18 12:45:03 yups, if the CollectOne function reports a bool, t
manzagop (departed) 2017/05/18 14:52:12 Done.
103 ++success_cnt; 110 ++unclean_cnt;
104 } 111 }
105 112
106 return success_cnt; 113 UMA_STABILITY_HISTOGRAM_COUNTS_100(
114 "ActivityTracker.Collect.UncleanShutdownCount", unclean_cnt);
115 UMA_STABILITY_HISTOGRAM_COUNTS_100(
116 "ActivityTracker.Collect.UncleanSystemCount", unclean_system_cnt);
117
118 return unclean_cnt;
107 } 119 }
108 120
109 std::vector<FilePath> PostmortemReportCollector::GetDebugStateFilePaths( 121 std::vector<FilePath> PostmortemReportCollector::GetDebugStateFilePaths(
110 const FilePath& debug_info_dir, 122 const FilePath& debug_info_dir,
111 const FilePath::StringType& debug_file_pattern, 123 const FilePath::StringType& debug_file_pattern,
112 const std::set<FilePath>& excluded_debug_files) { 124 const std::set<FilePath>& excluded_debug_files) {
113 DCHECK_NE(true, debug_info_dir.empty()); 125 DCHECK_NE(true, debug_info_dir.empty());
114 DCHECK_NE(true, debug_file_pattern.empty()); 126 DCHECK_NE(true, debug_file_pattern.empty());
115 127
116 std::vector<FilePath> paths; 128 std::vector<FilePath> paths;
117 base::FileEnumerator enumerator(debug_info_dir, false /* recursive */, 129 base::FileEnumerator enumerator(debug_info_dir, false /* recursive */,
118 base::FileEnumerator::FILES, 130 base::FileEnumerator::FILES,
119 debug_file_pattern); 131 debug_file_pattern);
120 FilePath path; 132 FilePath path;
121 for (path = enumerator.Next(); !path.empty(); path = enumerator.Next()) { 133 for (path = enumerator.Next(); !path.empty(); path = enumerator.Next()) {
122 if (excluded_debug_files.find(path) == excluded_debug_files.end()) 134 if (excluded_debug_files.find(path) == excluded_debug_files.end())
123 paths.push_back(path); 135 paths.push_back(path);
124 } 136 }
125 return paths; 137 return paths;
126 } 138 }
127 139
128 CollectionStatus PostmortemReportCollector::CollectAndSubmitOneReport( 140 CollectionStatus PostmortemReportCollector::CollectAndSubmitOneReport(
129 const crashpad::UUID& client_id, 141 const crashpad::UUID& client_id,
130 const FilePath& file, 142 const FilePath& file,
131 crashpad::CrashReportDatabase* report_database) { 143 crashpad::CrashReportDatabase* report_database,
144 int* unclean_system_cnt) {
132 DCHECK_NE(nullptr, report_database); 145 DCHECK_NE(nullptr, report_database);
146 DCHECK_NE(nullptr, unclean_system_cnt);
133 147
134 // Note: the code below involves two notions of report: chrome internal state 148 // Note: the code below involves two notions of report: chrome internal state
135 // reports and the crashpad reports they get wrapped into. 149 // reports and the crashpad reports they get wrapped into.
136 150
137 // Collect the data from the debug file to a proto. Note: a non-empty report 151 // Collect the data from the debug file to a proto. Note: a non-empty report
138 // is interpreted here as an unclean exit. 152 // is interpreted here as an unclean exit.
139 StabilityReport report_proto; 153 StabilityReport report_proto;
140 CollectionStatus status = CollectOneReport(file, &report_proto); 154 CollectionStatus status = CollectOneReport(file, &report_proto);
141 if (status != SUCCESS) { 155 if (status != SUCCESS) {
142 // The file was empty, or there was an error collecting the data. Detailed 156 // The file was empty, or there was an error collecting the data. Detailed
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // writing, the delay is on the order of up to 15 minutes). 196 // writing, the delay is on the order of up to 15 minutes).
183 call_error_writing_crash_report.Disarm(); 197 call_error_writing_crash_report.Disarm();
184 crashpad::UUID unused_report_id; 198 crashpad::UUID unused_report_id;
185 database_status = report_database->FinishedWritingCrashReport( 199 database_status = report_database->FinishedWritingCrashReport(
186 new_report, &unused_report_id); 200 new_report, &unused_report_id);
187 if (database_status != CrashReportDatabase::kNoError) { 201 if (database_status != CrashReportDatabase::kNoError) {
188 DLOG(ERROR) << "FinishedWritingCrashReport failed"; 202 DLOG(ERROR) << "FinishedWritingCrashReport failed";
189 return FINISHED_WRITING_CRASH_REPORT_FAILED; 203 return FINISHED_WRITING_CRASH_REPORT_FAILED;
190 } 204 }
191 205
206 // Report collection is successful. We may increment |unclean_system_cnt|.
207 if (report_proto.system_state().session_state() == SystemState::UNCLEAN)
208 (*unclean_system_cnt)++;
209
192 return SUCCESS; 210 return SUCCESS;
193 } 211 }
194 212
195 CollectionStatus PostmortemReportCollector::CollectOneReport( 213 CollectionStatus PostmortemReportCollector::CollectOneReport(
196 const base::FilePath& file, 214 const base::FilePath& file,
197 StabilityReport* report) { 215 StabilityReport* report) {
198 DCHECK(report); 216 DCHECK(report);
199 217
200 CollectionStatus status = Extract(file, report); 218 CollectionStatus status = Extract(file, report);
201 if (status != SUCCESS) 219 if (status != SUCCESS)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 StabilityReport* report, 291 StabilityReport* report,
274 const crashpad::UUID& client_id, 292 const crashpad::UUID& client_id,
275 const crashpad::UUID& report_id, 293 const crashpad::UUID& report_id,
276 base::PlatformFile minidump_file) { 294 base::PlatformFile minidump_file) {
277 DCHECK(report); 295 DCHECK(report);
278 296
279 return WritePostmortemDump(minidump_file, client_id, report_id, report); 297 return WritePostmortemDump(minidump_file, client_id, report_id, report);
280 } 298 }
281 299
282 } // namespace browser_watcher 300 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698