Commit 7c828057 authored by tby's avatar tby Committed by Commit Bot

[Suggested files] Add histograms for drive zero-state provider.

This adds two metrics:
 - a status/error metric we can use to track query QPS and errors
 - a query latency metric

Bug: 1034842
Change-Id: I4c426873a8685ce605df17b6a31d6ad17ef5c72b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436970Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarThanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Tony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812440}
parent f4491977
...@@ -33,6 +33,23 @@ namespace { ...@@ -33,6 +33,23 @@ namespace {
constexpr char kListSchema[] = "drive_zero_state://"; constexpr char kListSchema[] = "drive_zero_state://";
constexpr char kChipSchema[] = "drive_zero_state_chip://"; constexpr char kChipSchema[] = "drive_zero_state_chip://";
// Outcome of a call to DriverZeroStateProvider::Start. These values persist to
// logs. Entries should not be renumbered and numeric values should never be
// reused.
enum class Status {
kOk = 0,
kDriveFSNotMounted = 1,
kNoResults = 2,
kPathLocationFailed = 3,
kAllFilesErrored = 4,
kMaxValue = kAllFilesErrored,
};
void LogStatus(Status status) {
UMA_HISTOGRAM_ENUMERATION("Apps.AppList.DriveZeroStateProvider.Status",
status);
}
// Given an absolute path representing a file in the user's Drive, returns a // Given an absolute path representing a file in the user's Drive, returns a
// reparented version of the path within the user's drive fs mount. // reparented version of the path within the user's drive fs mount.
base::FilePath ReparentToDriveMount( base::FilePath ReparentToDriveMount(
...@@ -109,18 +126,22 @@ void DriveZeroStateProvider::Start(const base::string16& query) { ...@@ -109,18 +126,22 @@ void DriveZeroStateProvider::Start(const base::string16& query) {
// - this search has a non-empty query, we only handle zero-state. // - this search has a non-empty query, we only handle zero-state.
// - drive fs isn't mounted, as we launch results via drive fs. // - drive fs isn't mounted, as we launch results via drive fs.
const bool drive_fs_mounted = drive_service_ && drive_service_->IsMounted(); const bool drive_fs_mounted = drive_service_ && drive_service_->IsMounted();
if (!query.empty() || !drive_fs_mounted) { if (!query.empty()) {
// TODO(crbug.com/1034842): Log error metrics. return;
} else if (!drive_fs_mounted) {
LogStatus(Status::kDriveFSNotMounted);
return; return;
} }
query_start_time_ = base::TimeTicks::Now();
// Cancel any in-flight queries for this provider. // Cancel any in-flight queries for this provider.
weak_factory_.InvalidateWeakPtrs(); weak_factory_.InvalidateWeakPtrs();
// Get the most recent results from the cache. // Get the most recent results from the cache.
cache_results_ = item_suggest_cache_.GetResults(); cache_results_ = item_suggest_cache_.GetResults();
if (!cache_results_) { if (!cache_results_) {
// TODO(crbug.com/1034842): Log error metrics. LogStatus(Status::kNoResults);
return; return;
} }
...@@ -137,9 +158,10 @@ void DriveZeroStateProvider::Start(const base::string16& query) { ...@@ -137,9 +158,10 @@ void DriveZeroStateProvider::Start(const base::string16& query) {
void DriveZeroStateProvider::OnFilePathsLocated( void DriveZeroStateProvider::OnFilePathsLocated(
base::Optional<std::vector<drivefs::mojom::FilePathOrErrorPtr>> paths) { base::Optional<std::vector<drivefs::mojom::FilePathOrErrorPtr>> paths) {
if (!paths) { if (!paths) {
// TODO(crbug.com/1034842): Log error metrics. LogStatus(Status::kPathLocationFailed);
return; return;
} }
DCHECK(cache_results_); DCHECK(cache_results_);
DCHECK_EQ(cache_results_->results.size(), paths->size()); DCHECK_EQ(cache_results_->results.size(), paths->size());
...@@ -148,12 +170,14 @@ void DriveZeroStateProvider::OnFilePathsLocated( ...@@ -148,12 +170,14 @@ void DriveZeroStateProvider::OnFilePathsLocated(
// the first is better than the second, etc. Resulting scores are in [0, 1]. // the first is better than the second, etc. Resulting scores are in [0, 1].
const double total_items = static_cast<double>(paths->size()); const double total_items = static_cast<double>(paths->size());
int item_index = 0; int item_index = 0;
bool all_files_errored = true;
SearchProvider::Results provider_results; SearchProvider::Results provider_results;
for (int i = 0; i < static_cast<int>(paths->size()); ++i) { for (int i = 0; i < static_cast<int>(paths->size()); ++i) {
const auto& path_or_error = paths.value()[i]; const auto& path_or_error = paths.value()[i];
if (path_or_error->is_error()) { if (path_or_error->is_error()) {
// TODO(crbug.com/1034842): Log error metrics.
continue; continue;
} else {
all_files_errored = false;
} }
const double score = 1.0 - (item_index / total_items); const double score = 1.0 - (item_index / total_items);
...@@ -170,8 +194,20 @@ void DriveZeroStateProvider::OnFilePathsLocated( ...@@ -170,8 +194,20 @@ void DriveZeroStateProvider::OnFilePathsLocated(
} }
} }
// We expect some files to error sometimes, but we're mainly interested in
// when all of the files error at once. This also keeps the bucket proportion
// of the status metric meaningful.
if (all_files_errored) {
LogStatus(Status::kAllFilesErrored);
return;
}
cache_results_.reset(); cache_results_.reset();
SwapResults(&provider_results); SwapResults(&provider_results);
LogStatus(Status::kOk);
UMA_HISTOGRAM_TIMES("Apps.AppList.DriveZeroStateProvider.Latency",
base::TimeTicks::Now() - query_start_time_);
} }
std::unique_ptr<FileResult> DriveZeroStateProvider::MakeListResult( std::unique_ptr<FileResult> DriveZeroStateProvider::MakeListResult(
......
...@@ -64,6 +64,8 @@ class DriveZeroStateProvider : public SearchProvider, ...@@ -64,6 +64,8 @@ class DriveZeroStateProvider : public SearchProvider,
// OnFilePathsLocated has finished. // OnFilePathsLocated has finished.
base::Optional<ItemSuggestCache::Results> cache_results_; base::Optional<ItemSuggestCache::Results> cache_results_;
base::TimeTicks query_start_time_;
// Whether the suggested files experiment is enabled. // Whether the suggested files experiment is enabled.
const bool suggested_files_enabled_; const bool suggested_files_enabled_;
......
...@@ -19190,6 +19190,14 @@ Called by update_document_policy_enum.py.--> ...@@ -19190,6 +19190,14 @@ Called by update_document_policy_enum.py.-->
<int value="2" label="Batch"/> <int value="2" label="Batch"/>
</enum> </enum>
<enum name="DriveZeroStateProviderStatus">
<int value="0" label="Ok"/>
<int value="1" label="Drive FS not mounted"/>
<int value="2" label="No results"/>
<int value="3" label="Path location failed"/>
<int value="4" label="File error"/>
</enum>
<enum name="DspHotwordDetectionStatus"> <enum name="DspHotwordDetectionStatus">
<int value="0" label="HARDWARE_ACCEPTED"/> <int value="0" label="HARDWARE_ACCEPTED"/>
<int value="1" label="SOFTWARE_REJECTED"/> <int value="1" label="SOFTWARE_REJECTED"/>
...@@ -276,6 +276,30 @@ reviews. Googlers can read more about this at go/gwsq-gerrit. ...@@ -276,6 +276,30 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary> </summary>
</histogram> </histogram>
<histogram name="Apps.AppList.DriveZeroStateProvider.Latency" units="ms"
expires_after="2021-03-15">
<owner>tby@chromium.org</owner>
<owner>jiameng@chromium.org</owner>
<owner>thanhdng@chromium.org</owner>
<owner>wrong@chromium.org</owner>
<summary>
The time between sending a zero state query and receiving file
recommendations back from DriveZeroStateProvider.
</summary>
</histogram>
<histogram name="Apps.AppList.DriveZeroStateProvider.Status"
enum="DriveZeroStateProviderStatus" expires_after="2021-03-15">
<owner>tby@chromium.org</owner>
<owner>jiameng@chromium.org</owner>
<owner>thanhdng@chromium.org</owner>
<owner>wrong@chromium.org</owner>
<summary>
The outcome of a query for search results from DriverZeroStateProvider.
Recorded once per zero-state query.
</summary>
</histogram>
<histogram name="Apps.AppList.ItemSuggestCache.ResponseSize" units="bytes" <histogram name="Apps.AppList.ItemSuggestCache.ResponseSize" units="bytes"
expires_after="2021-03-15"> expires_after="2021-03-15">
<owner>tby@chromium.org</owner> <owner>tby@chromium.org</owner>
......
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