Skip to content

Commit

Permalink
[Merge 110][ZPS][Journeys] Add metrics logging for ZPS cache observer…
Browse files Browse the repository at this point in the history
… in Journeys.

As a follow-up to previous work to integrate the in-memory ZPS caching
service with the Journeys feature in Chrome, this CL adds metrics
logging to the new "related searches" extraction flow in order to
achieve logging parity with the old "related searches" extraction flow.

(cherry picked from commit a8f02ec)

Bug: 1378776
Change-Id: I2bf878cf70dd709e18113402f5231b5c24073ca6
Low-Coverage-Reason: Minimal changes to implementation logic.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4133424
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Commit-Queue: Khalid Peer <khalidpeer@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1088882}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4138276
Cr-Commit-Position: refs/branch-heads/5481@{#146}
Cr-Branched-From: 130f3e4-refs/heads/main@{#1084008}
  • Loading branch information
Khalid Peer authored and Chromium LUCI CQ committed Jan 5, 2023
1 parent e3a816b commit dbfa148
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ void LogPageContentAnnotationsStorageStatus(
status);
}

void LogRelatedSearchesExtracted(bool success) {
base::UmaHistogramBoolean(
"OptimizationGuide.PageContentAnnotationsService."
"RelatedSearchesExtracted",
success);
}

#if BUILDFLAG(BUILD_WITH_TFLITE_LIB)
// Record the visibility score of the provided visit as a RAPPOR-style record to
// UKM.
Expand Down Expand Up @@ -475,7 +482,10 @@ void PageContentAnnotationsService::
ExtractRelatedSearchesFromZeroSuggestResponse(
const ZeroSuggestCacheService::CacheEntry& response,
history::QueryURLResult url_result) {
if (url_result.visits.empty()) {
if (!url_result.success || url_result.visits.empty()) {
LogPageContentAnnotationsStorageStatus(
PageContentAnnotationsStorageStatus::kNoVisitsForUrl,
PageContentAnnotationsType::kRelatedSearches);
return;
}

Expand All @@ -497,11 +507,18 @@ void PageContentAnnotationsService::
}

if (related_searches.empty()) {
LogRelatedSearchesExtracted(false);
return;
}

LogRelatedSearchesExtracted(true);

auto visit_id = url_result.visits.front().visit_id;
history_service_->AddRelatedSearchesForVisit(related_searches, visit_id);

LogPageContentAnnotationsStorageStatus(
PageContentAnnotationsStorageStatus::kSuccess,
PageContentAnnotationsType::kRelatedSearches);
}

void PageContentAnnotationsService::OnRelatedSearchesExtracted(
Expand All @@ -510,10 +527,7 @@ void PageContentAnnotationsService::OnRelatedSearchesExtracted(
continuous_search::mojom::CategoryResultsPtr results) {
const bool success =
status == continuous_search::SearchResultExtractorClientStatus::kSuccess;
base::UmaHistogramBoolean(
"OptimizationGuide.PageContentAnnotationsService."
"RelatedSearchesExtracted",
success);
LogRelatedSearchesExtracted(success);

if (!success) {
return;
Expand Down

0 comments on commit dbfa148

Please sign in to comment.