-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android][UPM] Log the latency and success metrics for PasswordStoreB…
…uiltInBackend MetricsRecorder is moved so it can be used by both PasswordStoreAndroidBackend and PasswordStoreBuiltInBackend and it was renamed to PasswordStoreBackendMetricsRecorder. PasswordStoreBackendMetricsRecorder now needs a ClassInfix so we could distinguish and compare the logs coming from the two different backends. The plan is to add logging for the methods of PasswordStoreBuiltInBackend that correspond to the methods of PasswordStoreAndroidBackend that log their metrics. This will be done in a followup CL. For now, just GetAllLoginsAsync is logged. Bug: 1298467 Change-Id: I7bc93f4ef6d20d7ca0463fff3f946dc20c1ed0ed Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3535784 Reviewed-by: Friedrich Horschig <fhorschig@chromium.org> Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org> Commit-Queue: Ivana Žužić <izuzic@google.com> Cr-Commit-Position: refs/heads/main@{#987988}
- Loading branch information
Ivana Žužić
authored and
Chromium LUCI CQ
committed
Apr 1, 2022
1 parent
727f58e
commit 0a8dc25
Showing
12 changed files
with
323 additions
and
119 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
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
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
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
66 changes: 66 additions & 0 deletions
66
components/password_manager/core/browser/password_store_backend_metrics_recorder.cc
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,66 @@ | ||
// 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. | ||
|
||
#include "components/password_manager/core/browser/password_store_backend_metrics_recorder.h" | ||
|
||
namespace password_manager { | ||
|
||
PasswordStoreBackendMetricsRecorder::PasswordStoreBackendMetricsRecorder() = | ||
default; | ||
|
||
PasswordStoreBackendMetricsRecorder::PasswordStoreBackendMetricsRecorder( | ||
ClassInfix class_infix, | ||
MetricInfix metric_infix) | ||
: class_infix_(std::move(class_infix)), | ||
metric_infix_(std::move(metric_infix)) {} | ||
|
||
PasswordStoreBackendMetricsRecorder::PasswordStoreBackendMetricsRecorder( | ||
PasswordStoreBackendMetricsRecorder&&) = default; | ||
|
||
PasswordStoreBackendMetricsRecorder& PasswordStoreBackendMetricsRecorder:: | ||
PasswordStoreBackendMetricsRecorder::operator=( | ||
PasswordStoreBackendMetricsRecorder&&) = default; | ||
|
||
PasswordStoreBackendMetricsRecorder::~PasswordStoreBackendMetricsRecorder() = | ||
default; | ||
|
||
void PasswordStoreBackendMetricsRecorder::RecordMetrics( | ||
bool success, | ||
absl::optional<ErrorFromPasswordStoreOrAndroidBackend> error) const { | ||
auto BuildMetricName = [this](base::StringPiece suffix) { | ||
return base::StrCat( | ||
{"PasswordManager.", *class_infix_, ".", *metric_infix_, ".", suffix}); | ||
}; | ||
base::TimeDelta duration = base::Time::Now() - start_; | ||
base::UmaHistogramMediumTimes(BuildMetricName("Latency"), duration); | ||
base::UmaHistogramBoolean(BuildMetricName("Success"), success); | ||
if (!error.has_value()) | ||
return; | ||
|
||
DCHECK(!success); | ||
ErrorFromPasswordStoreOrAndroidBackend error_variant = | ||
std::move(error.value()); | ||
// In case of AndroidBackend error, we report additional metrics. | ||
if (absl::holds_alternative<AndroidBackendError>(error_variant)) { | ||
AndroidBackendError backend_error = std::move(absl::get<1>(error_variant)); | ||
base::UmaHistogramEnumeration( | ||
"PasswordManager.PasswordStoreAndroidBackend.ErrorCode", | ||
backend_error.type); | ||
base::UmaHistogramEnumeration(BuildMetricName("ErrorCode"), | ||
backend_error.type); | ||
if (backend_error.type == AndroidBackendErrorType::kExternalError) { | ||
DCHECK(backend_error.api_error_code.has_value()); | ||
base::HistogramBase* histogram = base::SparseHistogram::FactoryGet( | ||
"PasswordManager.PasswordStoreAndroidBackend.APIError", | ||
base::HistogramBase::kUmaTargetedHistogramFlag); | ||
histogram->Add(backend_error.api_error_code.value()); | ||
histogram = base::SparseHistogram::FactoryGet( | ||
BuildMetricName("APIError"), | ||
base::HistogramBase::kUmaTargetedHistogramFlag); | ||
histogram->Add(backend_error.api_error_code.value()); | ||
} | ||
} | ||
} | ||
|
||
} // namespace password_manager |
Oops, something went wrong.