0

Add histograms for the URL consent checks

This CL adds two histograms to verify the total number of consent check
requests and the status on timeout. These are useful to distinguish
cases when metrics are not recorded due to browser shutdown and to
verify that SyncService notifies observers on the latest changes.

Bug: 1425071
Change-Id: If0547f78975d3f346a61fb4e0c97d28d5c783ad3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4905182
Commit-Queue: Rushan Suleymanov <rushans@google.com>
Reviewed-by: Sophie Chang <sophiechang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1203353}
This commit is contained in:
Rushan Suleymanov
2023-09-29 17:45:35 +00:00
committed by Chromium LUCI CQ
parent 955a35d044
commit b11a297447
2 changed files with 41 additions and 1 deletions
components/page_image_service
tools/metrics/histograms/metadata/others

@ -6,6 +6,7 @@
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_functions.h"
#include "components/page_image_service/features.h"
#include "components/page_image_service/metrics_util.h"
#include "components/sync/service/sync_service.h"
@ -23,6 +24,15 @@ void RunConsentThrottleCallback(
: PageImageServiceConsentStatus::kFailure);
}
PageImageServiceConsentStatus ConsentStatusToUmaStatus(
absl::optional<bool> consent_status) {
if (!consent_status) {
return PageImageServiceConsentStatus::kTimedOut;
}
return consent_status.value() ? PageImageServiceConsentStatus::kSuccess
: PageImageServiceConsentStatus::kFailure;
}
} // namespace
ImageServiceConsentHelper::ImageServiceConsentHelper(
@ -58,6 +68,7 @@ ImageServiceConsentHelper::~ImageServiceConsentHelper() = default;
void ImageServiceConsentHelper::EnqueueRequest(
base::OnceCallback<void(PageImageServiceConsentStatus)> callback) {
base::UmaHistogramBoolean("PageImageService.ConsentStatusRequestCount", true);
if (consent_throttle_) {
consent_throttle_->EnqueueRequest(
base::BindOnce(&RunConsentThrottleCallback, std::move(callback)));
@ -126,6 +137,10 @@ absl::optional<bool> ImageServiceConsentHelper::GetConsentStatus() {
void ImageServiceConsentHelper::OnTimeoutExpired() {
for (auto& request_callback : enqueued_request_callbacks_) {
// Report consent status on timeout for each request to compare against the
// number of all requests.
base::UmaHistogramEnumeration("PageImageService.ConsentStatusOnTimeout",
ConsentStatusToUmaStatus(GetConsentStatus()));
std::move(request_callback).Run(PageImageServiceConsentStatus::kTimedOut);
}
enqueued_request_callbacks_.clear();

@ -9451,13 +9451,38 @@ chromium-metrics-reviews@google.com.
<token key="ClientId" variants="PageImageServiceClientId"/>
</histogram>
<histogram name="PageImageService.ConsentStatusOnTimeout"
enum="PageImageServiceConsentStatus" expires_after="2024-02-20">
<owner>tommycli@chromium.org</owner>
<owner>chrome-journeys@google.com</owner>
<component>UI&gt;Browser&gt;Journeys</component>
<summary>
Records the result of the URL consent check after timeout has expired.
Recorded for each request which was enqueued by the time when timeout
happened.
</summary>
</histogram>
<histogram name="PageImageService.ConsentStatusRequestCount" enum="Boolean"
expires_after="2024-02-20">
<owner>tommycli@chromium.org</owner>
<owner>chrome-journeys@google.com</owner>
<component>UI&gt;Browser&gt;Journeys</component>
<summary>
Recorded on each URL consent check request. This metric is used to compare
numbers with consent check result in PageImageService.ConsentStatus.
</summary>
</histogram>
<histogram name="PageImageService.ConsentStatus{ClientId}"
enum="PageImageServiceConsentStatus" expires_after="2024-02-20">
<owner>tommycli@chromium.org</owner>
<owner>chrome-journeys@google.com</owner>
<component>UI&gt;Browser&gt;Journeys</component>
<summary>
Records the result of the URL consent check for this request.
Records the result of the URL consent check for this request. The number of
consent check requests is recorded in
PageImageService.ConsentStatusRequestCount.
Note that only success and failure are captured if the &quot;old&quot;
unified consent throttle is used.