Skip to content

Commit

Permalink
[launcher] Extend Error metrics.
Browse files Browse the repository at this point in the history
Add an extra error state to check if `AppServiceProxy` has been initialized. We also log `KOk` to calculate the error rate of each error state.

Bug: b/262818842, b/261867385
Change-Id: I728108504c256bd2f444a533f5239c8c67254a03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4113706
Auto-Submit: CJ Huang <chenjih@google.com>
Reviewed-by: Tony Yeoman <tby@chromium.org>
Commit-Queue: CJ Huang <chenjih@google.com>
Cr-Commit-Position: refs/heads/main@{#1084844}
  • Loading branch information
CJ Huang authored and Chromium LUCI CQ committed Dec 19, 2022
1 parent 360e8c6 commit e21eca8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 15 additions & 11 deletions chrome/browser/ash/app_list/search/os_settings_provider.cc
Expand Up @@ -35,10 +35,9 @@ constexpr char kOsSettingsResultPrefix[] = "os-settings://";

constexpr size_t kNumRequestedResults = 5u;

// Various error states of the OsSettingsProvider. kOk is currently not emitted,
// but may be used in future. These values persist to logs. Entries should not
// be renumbered and numeric values should never be reused.
enum class Error {
// Various states of the OsSettingsProvider. These values persist to logs.
// Entries should not be renumbered and numeric values should never be reused.
enum class Status {
kOk = 0,
// No longer used.
// kAppServiceUnavailable = 1,
Expand All @@ -47,11 +46,12 @@ enum class Error {
kHierarchyEmpty = 4,
kNoHierarchy = 5,
kSettingsAppNotReady = 6,
kMaxValue = kSettingsAppNotReady,
kNoAppServiceProxy = 7,
kMaxValue = kNoAppServiceProxy,
};

void LogError(Error error) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppList.OsSettingsProvider.Error", error);
void LogStatus(Status status) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppList.OsSettingsProvider.Error", status);
}

bool ContainsBetterAncestor(Subpage subpage,
Expand Down Expand Up @@ -126,7 +126,7 @@ OsSettingsResult::OsSettingsResult(Profile* profile,
// bluetooth), in which case we should leave the details blank.
const auto& hierarchy = result->settings_page_hierarchy;
if (hierarchy.empty()) {
LogError(Error::kHierarchyEmpty);
LogStatus(Status::kHierarchyEmpty);
} else if (result->type != SettingsResultType::kSection) {
SetDetails(hierarchy.back());
}
Expand Down Expand Up @@ -168,12 +168,12 @@ OsSettingsProvider::OsSettingsProvider(
// search chrome flag is disabled. If it is, we should effectively disable the
// search provider.
if (!search_handler_) {
LogError(Error::kSearchHandlerUnavailable);
LogStatus(Status::kSearchHandlerUnavailable);
return;
}

if (!hierarchy_) {
LogError(Error::kNoHierarchy);
LogStatus(Status::kNoHierarchy);
}

search_handler_->Observe(
Expand All @@ -189,6 +189,8 @@ OsSettingsProvider::OsSettingsProvider(
/*allow_placeholder_icon=*/false,
base::BindOnce(&OsSettingsProvider::OnLoadIcon,
weak_factory_.GetWeakPtr()));
} else {
LogStatus(Status::kNoAppServiceProxy);
}
}

Expand All @@ -208,7 +210,7 @@ void OsSettingsProvider::Start(const std::u16string& query) {
if (!search_handler_) {
return;
} else if (icon_.isNull()) {
LogError(Error::kNoSettingsIcon);
LogStatus(Status::kNoSettingsIcon);
return;
}

Expand Down Expand Up @@ -248,6 +250,8 @@ void OsSettingsProvider::OnSearchReturned(

UMA_HISTOGRAM_TIMES("Apps.AppList.OsSettingsProvider.QueryTime",
base::TimeTicks::Now() - start_time);
// Log the OS setting search has been successfully proceeded.
LogStatus(Status::kOk);
SwapResults(&search_results);
}

Expand Down
6 changes: 4 additions & 2 deletions tools/metrics/histograms/metadata/apps/histograms.xml
Expand Up @@ -730,8 +730,10 @@ chromium-metrics-reviews@google.com.
<owner>thanhdng@chromium.org</owner>
<summary>
Various error states of the provider for OS settings in the cros launcher.
Emitted only in the case of an unexpected error, the bucket proportion is
not meaningful.
Emitted either the case of an unexpected error or an successful non-empty
query search. the bucket proportion is not meaningful as overlaps can occur
among errors. Instead, the ratio between each error bucket and the
successful query search can be used to calculate the accurate error rate.
</summary>
</histogram>

Expand Down

0 comments on commit e21eca8

Please sign in to comment.