Commit 6f6e2a84 authored by Xiaochu Liu's avatar Xiaochu Liu Committed by Commit Bot

component updater: report error code and mount time to UMA

New metric - ComponentUpdater.CROS.Result: track the chrome os installer result (error code, etc.).
New metric - ComponentUpdater.CROS.MountTime: track time to mount a component image.

BUG=chromium:793052
TEST=platform_AddPrinter.epson

Change-Id: I502e1983adcacb488877e83723cc91b6ee504312
Reviewed-on: https://chromium-review.googlesource.com/963182
Commit-Queue: Xiaochu Liu <xiaochu@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarDan Erat <derat@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarSorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548480}
parent 6f517c0c
......@@ -26,6 +26,8 @@ std::string ErrorToString(
case component_updater::CrOSComponentManager::Error::
COMPATIBILITY_CHECK_FAILED:
return "COMPATIBILITY_CHECK_FAILED";
case component_updater::CrOSComponentManager::Error::ERROR_MAX:
return "ERROR_MAX";
}
return "Unknown error code";
}
......
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "base/task_scheduler/post_task.h"
......@@ -86,6 +87,13 @@ std::vector<ComponentConfig> GetInstalled() {
return configs;
}
// Report Error code.
CrOSComponentManager::Error ReportError(CrOSComponentManager::Error error) {
UMA_HISTOGRAM_ENUMERATION("ComponentUpdater.ChromeOS.InstallResult", error,
CrOSComponentManager::Error::ERROR_MAX);
return error;
}
} // namespace
CrOSComponentInstallerPolicy::CrOSComponentInstallerPolicy(
......@@ -202,8 +210,9 @@ void CrOSComponentManager::Load(const std::string& name,
LoadInternal(name, std::move(load_callback));
} else {
// A compatible component is installed, do not load it.
base::PostTask(FROM_HERE, base::BindOnce(std::move(load_callback),
Error::NONE, base::FilePath()));
base::PostTask(FROM_HERE,
base::BindOnce(std::move(load_callback),
ReportError(Error::NONE), base::FilePath()));
}
}
......@@ -259,7 +268,8 @@ void CrOSComponentManager::Install(ComponentUpdateService* cus,
if (!config) {
base::PostTask(FROM_HERE,
base::BindOnce(std::move(load_callback),
Error::UNKNOWN_COMPONENT, base::FilePath()));
ReportError(Error::UNKNOWN_COMPONENT),
base::FilePath()));
return;
}
Register(
......@@ -283,14 +293,16 @@ void CrOSComponentManager::FinishInstall(const std::string& name,
LoadCallback load_callback,
update_client::Error error) {
if (error != update_client::Error::NONE) {
base::PostTask(FROM_HERE,
base::BindOnce(std::move(load_callback),
Error::INSTALL_FAILURE, base::FilePath()));
base::PostTask(
FROM_HERE,
base::BindOnce(std::move(load_callback),
ReportError(Error::INSTALL_FAILURE), base::FilePath()));
} else if (mount_policy == MountPolicy::kMount) {
LoadInternal(name, std::move(load_callback));
} else {
base::PostTask(FROM_HERE, base::BindOnce(std::move(load_callback),
Error::NONE, base::FilePath()));
base::PostTask(FROM_HERE,
base::BindOnce(std::move(load_callback),
ReportError(Error::NONE), base::FilePath()));
}
}
......@@ -305,23 +317,31 @@ void CrOSComponentManager::LoadInternal(const std::string& name,
->LoadComponentAtPath(
name, path,
base::BindOnce(&CrOSComponentManager::FinishLoad,
base::Unretained(this), std::move(load_callback)));
base::Unretained(this), std::move(load_callback),
base::TimeTicks::Now()));
} else {
base::PostTask(FROM_HERE, base::BindOnce(std::move(load_callback),
Error::COMPATIBILITY_CHECK_FAILED,
base::FilePath()));
base::PostTask(
FROM_HERE,
base::BindOnce(std::move(load_callback),
ReportError(Error::COMPATIBILITY_CHECK_FAILED),
base::FilePath()));
}
}
void CrOSComponentManager::FinishLoad(LoadCallback load_callback,
const base::TimeTicks start_time,
base::Optional<base::FilePath> result) {
// Report component image mount time.
UMA_HISTOGRAM_LONG_TIMES("ComponentUpdater.ChromeOS.MountTime",
base::TimeTicks::Now() - start_time);
if (!result.has_value()) {
base::PostTask(FROM_HERE, base::BindOnce(std::move(load_callback),
ReportError(Error::MOUNT_FAILURE),
base::FilePath()));
} else {
base::PostTask(FROM_HERE,
base::BindOnce(std::move(load_callback),
Error::MOUNT_FAILURE, base::FilePath()));
} else {
base::PostTask(FROM_HERE, base::BindOnce(std::move(load_callback),
Error::NONE, result.value()));
ReportError(Error::NONE), result.value()));
}
}
......
......@@ -68,12 +68,15 @@ class CrOSComponentInstallerPolicy : public ComponentInstallerPolicy {
// This class contains functions used to register and install a component.
class CrOSComponentManager {
public:
// Error needs to be consistent with CrosComponentManagerError in
// src/tools/metrics/histograms/enums.xml.
enum class Error {
NONE = 0,
UNKNOWN_COMPONENT = 1, // Component requested does not exist.
INSTALL_FAILURE = 2, // update_client fails to install component.
MOUNT_FAILURE = 3, // Component can not be mounted.
COMPATIBILITY_CHECK_FAILED = 4, // Compatibility check failed.
ERROR_MAX
};
using LoadCallback =
base::OnceCallback<void(Error error, const base::FilePath&)>;
......@@ -146,6 +149,7 @@ class CrOSComponentManager {
// Calls load_callback and pass in the parameter |result| (component mount
// point).
void FinishLoad(LoadCallback load_callback,
const base::TimeTicks start_time,
base::Optional<base::FilePath> result);
// Registers component |configs| to be updated.
......
......@@ -7737,6 +7737,14 @@ Called by update_net_error_codes.py.-->
<int value="3" label="User disabled"/>
</enum>
<enum name="CrosComponentManagerError">
<int value="0" label="NONE"/>
<int value="1" label="UNKNOWN_COMPONENT"/>
<int value="2" label="INSTALL_FAILURE"/>
<int value="3" label="MOUNT_FAILURE"/>
<int value="4" label="COMPATIBILITY_CHECK_FAILED"/>
</enum>
<enum name="CrosDisksArchiveType">
<int value="0" label="Unknown"/>
<int value="1" label="ZIP"/>
......@@ -10943,6 +10943,19 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
<histogram name="ComponentUpdater.ChromeOS.InstallResult"
enum="CrosComponentManagerError">
<owner>xiaochu@chromium.org</owner>
<summary>
Chrome OS only. Installation error code in CrosComponentManager.
</summary>
</histogram>
<histogram name="ComponentUpdater.ChromeOS.MountTime" units="ms">
<owner>xiaochu@chromium.org</owner>
<summary>Chrome OS only. Time it takes to mount a component image.</summary>
</histogram>
<histogram name="ComponentUpdater.UpdateCompleteResult" enum="BooleanError">
<owner>sorin@chromium.org</owner>
<summary>The result of an install or an update check.</summary>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment