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

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

Issue 2883103002: Quantify instability according to the stability instrumentation (Closed)
Patch Set: 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } // namespace 56 } // namespace
57 57
58 PostmortemReportCollector::PostmortemReportCollector( 58 PostmortemReportCollector::PostmortemReportCollector(
59 const std::string& product_name, 59 const std::string& product_name,
60 const std::string& version_number, 60 const std::string& version_number,
61 const std::string& channel_name, 61 const std::string& channel_name,
62 SystemSessionAnalyzer* analyzer) 62 SystemSessionAnalyzer* analyzer)
63 : product_name_(product_name), 63 : product_name_(product_name),
64 version_number_(version_number), 64 version_number_(version_number),
65 channel_name_(channel_name), 65 channel_name_(channel_name),
66 system_session_analyzer_(analyzer) {} 66 system_session_analyzer_(analyzer),
67 unclean_system_cnt_(0) {}
67 68
68 PostmortemReportCollector::~PostmortemReportCollector() {} 69 PostmortemReportCollector::~PostmortemReportCollector() {}
69 70
70 int PostmortemReportCollector::CollectAndSubmitAllPendingReports( 71 int PostmortemReportCollector::CollectAndSubmitAllPendingReports(
71 const base::FilePath& debug_info_dir, 72 const base::FilePath& debug_info_dir,
72 const base::FilePath::StringType& debug_file_pattern, 73 const base::FilePath::StringType& debug_file_pattern,
73 const std::set<base::FilePath>& excluded_debug_files, 74 const std::set<base::FilePath>& excluded_debug_files,
74 crashpad::CrashReportDatabase* report_database) { 75 crashpad::CrashReportDatabase* report_database) {
75 DCHECK_NE(true, debug_info_dir.empty()); 76 DCHECK_NE(true, debug_info_dir.empty());
76 DCHECK_NE(true, debug_file_pattern.empty()); 77 DCHECK_NE(true, debug_file_pattern.empty());
77 DCHECK_NE(nullptr, report_database); 78 DCHECK_NE(nullptr, report_database);
79 unclean_system_cnt_ = 0;
Sigurður Ásgeirsson 2017/05/15 20:18:04 looks like rather than a member variable, you want
manzagop (departed) 2017/05/17 22:31:56 Yes! Done.
78 80
79 // Collect the list of files to harvest. 81 // Collect the list of files to harvest.
80 std::vector<FilePath> debug_files = GetDebugStateFilePaths( 82 std::vector<FilePath> debug_files = GetDebugStateFilePaths(
81 debug_info_dir, debug_file_pattern, excluded_debug_files); 83 debug_info_dir, debug_file_pattern, excluded_debug_files);
82 UMA_HISTOGRAM_COUNTS_100("ActivityTracker.Collect.StabilityFileCount", 84 UMA_HISTOGRAM_COUNTS_100("ActivityTracker.Collect.StabilityFileCount",
83 debug_files.size()); 85 debug_files.size());
84 86
85 // Determine the crashpad client id. 87 // Determine the crashpad client id.
86 crashpad::UUID client_id; 88 crashpad::UUID client_id;
87 crashpad::Settings* settings = report_database->GetSettings(); 89 crashpad::Settings* settings = report_database->GetSettings();
88 if (settings) { 90 if (settings) {
89 // If GetSettings() or GetClientID() fails client_id will be left at its 91 // If GetSettings() or GetClientID() fails client_id will be left at its
90 // default value, all zeroes, which is appropriate. 92 // default value, all zeroes, which is appropriate.
91 settings->GetClientID(&client_id); 93 settings->GetClientID(&client_id);
92 } 94 }
93 95
94 // Process each stability file. 96 // Process each stability file.
95 int success_cnt = 0; 97 int success_cnt = 0;
96 for (const FilePath& file : debug_files) { 98 for (const FilePath& file : debug_files) {
97 CollectionStatus status = 99 CollectionStatus status =
98 CollectAndSubmitOneReport(client_id, file, report_database); 100 CollectAndSubmitOneReport(client_id, file, report_database);
99 // TODO(manzagop): consider making this a stability metric. 101 // TODO(manzagop): consider making this a stability metric.
100 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Collect.Status", status, 102 UMA_HISTOGRAM_ENUMERATION("ActivityTracker.Collect.Status", status,
101 COLLECTION_STATUS_MAX); 103 COLLECTION_STATUS_MAX);
102 if (status == SUCCESS) 104 if (status == SUCCESS)
103 ++success_cnt; 105 ++success_cnt;
104 } 106 }
105 107
108 UMA_STABILITY_HISTOGRAM_COUNTS_100(
109 "ActivityTracker.Collect.UncleanShutdownCount", success_cnt);
110 UMA_STABILITY_HISTOGRAM_COUNTS_100(
Sigurður Ásgeirsson 2017/05/15 20:18:04 is it possible to test these metrics - it'd be pre
manzagop (departed) 2017/05/17 22:31:56 I've added some histogram testing.
111 "ActivityTracker.Collect.UncleanSystemCount", unclean_system_cnt_);
112
106 return success_cnt; 113 return success_cnt;
107 } 114 }
108 115
109 std::vector<FilePath> PostmortemReportCollector::GetDebugStateFilePaths( 116 std::vector<FilePath> PostmortemReportCollector::GetDebugStateFilePaths(
110 const FilePath& debug_info_dir, 117 const FilePath& debug_info_dir,
111 const FilePath::StringType& debug_file_pattern, 118 const FilePath::StringType& debug_file_pattern,
112 const std::set<FilePath>& excluded_debug_files) { 119 const std::set<FilePath>& excluded_debug_files) {
113 DCHECK_NE(true, debug_info_dir.empty()); 120 DCHECK_NE(true, debug_info_dir.empty());
114 DCHECK_NE(true, debug_file_pattern.empty()); 121 DCHECK_NE(true, debug_file_pattern.empty());
115 122
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 system_session_analyzer_->IsSessionUnclean(time); 256 system_session_analyzer_->IsSessionUnclean(time);
250 switch (analyzer_status) { 257 switch (analyzer_status) {
251 case SystemSessionAnalyzer::FAILED: 258 case SystemSessionAnalyzer::FAILED:
252 status = SYSTEM_SESSION_ANALYSIS_FAILED; 259 status = SYSTEM_SESSION_ANALYSIS_FAILED;
253 break; 260 break;
254 case SystemSessionAnalyzer::CLEAN: 261 case SystemSessionAnalyzer::CLEAN:
255 session_state = SystemState::CLEAN; 262 session_state = SystemState::CLEAN;
256 break; 263 break;
257 case SystemSessionAnalyzer::UNCLEAN: 264 case SystemSessionAnalyzer::UNCLEAN:
258 session_state = SystemState::UNCLEAN; 265 session_state = SystemState::UNCLEAN;
266 unclean_system_cnt_++;
259 break; 267 break;
260 case SystemSessionAnalyzer::OUTSIDE_RANGE: 268 case SystemSessionAnalyzer::OUTSIDE_RANGE:
261 status = SYSTEM_SESSION_ANALYSIS_OUTSIDE_RANGE; 269 status = SYSTEM_SESSION_ANALYSIS_OUTSIDE_RANGE;
262 break; 270 break;
263 } 271 }
264 } 272 }
265 273
266 report->mutable_system_state()->set_session_state(session_state); 274 report->mutable_system_state()->set_session_state(session_state);
267 UMA_HISTOGRAM_ENUMERATION( 275 UMA_HISTOGRAM_ENUMERATION(
268 "ActivityTracker.Collect.SystemSessionAnalysisStatus", status, 276 "ActivityTracker.Collect.SystemSessionAnalysisStatus", status,
269 SYSTEM_SESSION_ANALYSIS_STATUS_MAX); 277 SYSTEM_SESSION_ANALYSIS_STATUS_MAX);
270 } 278 }
271 279
272 bool PostmortemReportCollector::WriteReportToMinidump( 280 bool PostmortemReportCollector::WriteReportToMinidump(
273 StabilityReport* report, 281 StabilityReport* report,
274 const crashpad::UUID& client_id, 282 const crashpad::UUID& client_id,
275 const crashpad::UUID& report_id, 283 const crashpad::UUID& report_id,
276 base::PlatformFile minidump_file) { 284 base::PlatformFile minidump_file) {
277 DCHECK(report); 285 DCHECK(report);
278 286
279 return WritePostmortemDump(minidump_file, client_id, report_id, report); 287 return WritePostmortemDump(minidump_file, client_id, report_id, report);
280 } 288 }
281 289
282 } // namespace browser_watcher 290 } // namespace browser_watcher
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698