This adds UMA metrics for the diagnostics recovery mode that is invoked when Chrome crashes and restarts on ChromeOS.
In order to be able to identify tests to UMA that were run, I also had to rearrange how tests were identified so that they could be identified by an enum value.
This change creates individual UMA stats for each type of diagnostic test and recovery so that we can track changes in diagnostic and recovery failure rates across versions. It also tracks the number of times diagnostics are invoked as a result of a crash vs normal starts, and keeps track of the failures of each type of diagnostic.
BUG=chromium:245827
Review URL: https://chromiumcodereview.appspot.com/22314016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219380 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/diagnostics/diagnostics_test.cc b/chrome/browser/diagnostics/diagnostics_test.cc
index 4e6e020..65482da 100644
--- a/chrome/browser/diagnostics/diagnostics_test.cc
+++ b/chrome/browser/diagnostics/diagnostics_test.cc
@@ -5,18 +5,16 @@
#include "chrome/browser/diagnostics/diagnostics_test.h"
#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/path_service.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
namespace diagnostics {
-DiagnosticsTest::DiagnosticsTest(const std::string& id,
- const std::string& title)
- : id_(id),
- title_(title),
- outcome_code_(-1),
- result_(DiagnosticsModel::TEST_NOT_RUN) {}
+DiagnosticsTest::DiagnosticsTest(DiagnosticsTestId id)
+ : id_(id), outcome_code_(-1), result_(DiagnosticsModel::TEST_NOT_RUN) {}
DiagnosticsTest::~DiagnosticsTest() {}
@@ -38,6 +36,15 @@
bool keep_going = RecoveryImpl(observer);
result_ = keep_going ? DiagnosticsModel::RECOVERY_OK
: DiagnosticsModel::RECOVERY_FAIL_STOP;
+#if defined(OS_CHROMEOS) // Only collecting UMA stats on ChromeOS
+ if (result_ == DiagnosticsModel::RECOVERY_OK) {
+ RecordUMARecoveryResult(static_cast<DiagnosticsTestId>(GetId()),
+ RESULT_SUCCESS);
+ } else {
+ RecordUMARecoveryResult(static_cast<DiagnosticsTestId>(GetId()),
+ RESULT_FAILURE);
+ }
+#endif
if (observer)
observer->OnRecoveryFinished(index, model);
return keep_going;
@@ -50,6 +57,21 @@
outcome_code_ = outcome_code;
additional_info_ = additional_info;
result_ = result;
+#if defined(OS_CHROMEOS) // Only collecting UMA stats on ChromeOS
+ if (result_ == DiagnosticsModel::TEST_OK) {
+ // Record individual test success.
+ RecordUMATestResult(static_cast<DiagnosticsTestId>(GetId()),
+ RESULT_SUCCESS);
+ } else if (result_ == DiagnosticsModel::TEST_FAIL_CONTINUE ||
+ result_ == DiagnosticsModel::TEST_FAIL_STOP) {
+ // Record test failure in summary histogram.
+ UMA_HISTOGRAM_ENUMERATION(
+ "Diagnostics.TestFailures", GetId(), DIAGNOSTICS_TEST_ID_COUNT);
+ // Record individual test failure.
+ RecordUMATestResult(static_cast<DiagnosticsTestId>(GetId()),
+ RESULT_FAILURE);
+ }
+#endif
}
// static
@@ -60,9 +82,13 @@
return path.AppendASCII(chrome::kInitialProfile);
}
-std::string DiagnosticsTest::GetId() const { return id_; }
+int DiagnosticsTest::GetId() const { return id_; }
-std::string DiagnosticsTest::GetTitle() const { return title_; }
+std::string DiagnosticsTest::GetName() const { return GetTestName(id_); }
+
+std::string DiagnosticsTest::GetTitle() const {
+ return GetTestDescription(id_);
+}
DiagnosticsModel::TestResult DiagnosticsTest::GetResult() const {
return result_;
@@ -80,7 +106,6 @@
bool DiagnosticsTest::RecoveryImpl(DiagnosticsModel::Observer* observer) {
return true;
-};
-
+}
} // namespace diagnostics