-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[M103][UPM] Report password checkup errors for the GMS backend.
Password checkup errors codes returned by the GMS Core 1P API are now reported as a separate metric. (cherry picked from commit 41071c8) Bug: 1325225 Change-Id: Ic5a28609fa3b61c0e23e168d3c13f861d3b28a0d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3645073 Reviewed-by: Ioana Pandele <ioanap@chromium.org> Reviewed-by: Andrey Zaytsev <andzaytsev@google.com> Commit-Queue: Maxim Anufriev <maxan@google.com> Cr-Original-Commit-Position: refs/heads/main@{#1007300} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3676993 Auto-Submit: Maxim Anufriev <maxan@google.com> Cr-Commit-Position: refs/branch-heads/5060@{#378} Cr-Branched-From: b83393d-refs/heads/main@{#1002911}
- Loading branch information
Maxim Anufriev
authored and
Chromium LUCI CQ
committed
May 30, 2022
1 parent
9e31291
commit 3846007
Showing
11 changed files
with
584 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...rc/org/chromium/chrome/browser/password_manager/PasswordCheckupClientMetricsRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright 2022 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.chrome.browser.password_manager; | ||
|
||
import com.google.common.base.Optional; | ||
|
||
import org.chromium.base.metrics.RecordHistogram; | ||
import org.chromium.chrome.browser.password_manager.CredentialManagerLauncher.CredentialManagerError; | ||
import org.chromium.chrome.browser.password_manager.PasswordManagerHelper.PasswordCheckOperation; | ||
|
||
/** | ||
* Records metrics for an asynchronous job or a series of jobs. The job is expected to have started | ||
* when the {@link PasswordCheckupClientMetricsRecorder} instance is created. Histograms are | ||
* recorded in {@link #recordMetrics(Exception) recordMetrics}. | ||
* | ||
* TODO(crbug.com/1326151): Report success and latency metrics. | ||
*/ | ||
class PasswordCheckupClientMetricsRecorder { | ||
private static final String PASSWORD_CHECKUP_HISTOGRAM_BASE = "PasswordManager.PasswordCheckup"; | ||
private static final String RUN_PASSWORD_CHECKUP_OPERATION_SUFFIX = "RunPasswordCheckup"; | ||
private static final String GET_BREACHED_CREDENTIALS_COUNT_OPERATION_SUFFIX = | ||
"GetBreachedCredentialsCount"; | ||
private static final String GET_PASSWORD_CHECKUP_INTENT_OPERATION_SUFFIX = "GetIntent"; | ||
|
||
private final @PasswordCheckOperation int mOperation; | ||
|
||
PasswordCheckupClientMetricsRecorder(@PasswordCheckOperation int operation) { | ||
mOperation = operation; | ||
} | ||
|
||
/** | ||
* Records the metrics depending on {@link Exception} provided. | ||
* Error codes are reported for all errors. For GMS errors, API error code is additionally | ||
* reported. | ||
* | ||
* @param exception {@link Exception} instance corresponding to the occurred error | ||
*/ | ||
void recordMetrics(Optional<Exception> exception) { | ||
// TODO(crbug.com/1326506): Record success and latency metrics. | ||
if (exception.isPresent()) { | ||
recordErrorMetrics(exception.get()); | ||
} | ||
} | ||
|
||
private void recordErrorMetrics(Exception exception) { | ||
@CredentialManagerError | ||
int error = PasswordManagerAndroidBackendUtil.getPasswordCheckupBackendError(exception); | ||
RecordHistogram.recordEnumeratedHistogram( | ||
getHistogramName("Error"), error, CredentialManagerError.COUNT); | ||
|
||
if (error == CredentialManagerError.API_ERROR) { | ||
int apiErrorCode = PasswordManagerAndroidBackendUtil.getApiErrorCode(exception); | ||
RecordHistogram.recordSparseHistogram(getHistogramName("APIError"), apiErrorCode); | ||
} | ||
} | ||
|
||
private String getHistogramName(String metric) { | ||
return PASSWORD_CHECKUP_HISTOGRAM_BASE + "." + getSuffixForOperation(mOperation) + "." | ||
+ metric; | ||
} | ||
|
||
/** Returns histogram suffix (infix in real) for a given operation. */ | ||
private static String getSuffixForOperation(@PasswordCheckOperation int operation) { | ||
switch (operation) { | ||
case PasswordCheckOperation.RUN_PASSWORD_CHECKUP: | ||
return RUN_PASSWORD_CHECKUP_OPERATION_SUFFIX; | ||
case PasswordCheckOperation.GET_BREACHED_CREDENTIALS_COUNT: | ||
return GET_BREACHED_CREDENTIALS_COUNT_OPERATION_SUFFIX; | ||
case PasswordCheckOperation.GET_PASSWORD_CHECKUP_INTENT: | ||
return GET_PASSWORD_CHECKUP_INTENT_OPERATION_SUFFIX; | ||
default: | ||
throw new AssertionError("All operations need to be handled."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.