Skip to content

Commit

Permalink
Skip aggregation service histogram when ThreadTicks is not supported
Browse files Browse the repository at this point in the history
Currently, if the platform doesn't support threadticks, base::TimeDelta()
would be recorded. Instead, we want to skip the reporting entirely.

Bug: 1368649
Change-Id: I4bc1177fa8bf450ac9afd93fc146be8ad48bb088
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3922556
Reviewed-by: John Delaney <johnidel@chromium.org>
Commit-Queue: Anthony Garant <anthonygarant@google.com>
Cr-Commit-Position: refs/heads/main@{#1052666}
  • Loading branch information
Anthony Garant authored and Chromium LUCI CQ committed Sep 28, 2022
1 parent 8527201 commit 7f66748
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,11 @@ bool AggregationServiceStorageSql::CreateSchema() {
return false;
}

base::UmaHistogramMediumTimes(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime",
timer.Elapsed());
if (timer.is_supported()) {
base::UmaHistogramMediumTimes(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2",
timer.Elapsed());
}

return transaction.Commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST_F(AggregationServiceStorageSqlTest,

// DB creation UMA should not be recorded.
histograms.ExpectTotalCount(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime", 0);
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2", 0);

// Storing a public key should create and initialize the database.
OpenDatabase();
Expand All @@ -163,9 +163,10 @@ TEST_F(AggregationServiceStorageSqlTest,
storage_->SetPublicKeys(url, keyset);
CloseDatabase();

// DB creation UMA should be recorded.
// DB creation UMA should be recorded if ThreadTicks is supported
histograms.ExpectTotalCount(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime", 1);
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2",
base::ThreadTicks::IsSupported() ? 1 : 0);

{
sql::Database raw_db;
Expand Down Expand Up @@ -1155,7 +1156,8 @@ TEST_F(AggregationServiceStorageSqlMigrationsTest, MigrateEmptyToCurrent) {
}

histograms.ExpectTotalCount(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime", 1);
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2",
base::ThreadTicks::IsSupported() ? 1 : 0);
histograms.ExpectUniqueSample(
"PrivacySandbox.AggregationService.Storage.Sql.InitStatus",
AggregationServiceStorageSql::InitStatus::kSuccess, 1);
Expand Down Expand Up @@ -1204,7 +1206,7 @@ TEST_F(AggregationServiceStorageSqlMigrationsTest, MigrateVersion1ToCurrent) {
}

histograms.ExpectTotalCount(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime", 0);
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2", 0);
histograms.ExpectUniqueSample(
"PrivacySandbox.AggregationService.Storage.Sql.InitStatus",
AggregationServiceStorageSql::InitStatus::kSuccess, 1);
Expand Down Expand Up @@ -1253,7 +1255,7 @@ TEST_F(AggregationServiceStorageSqlMigrationsTest, MigrateVersion2ToCurrent) {
}

histograms.ExpectTotalCount(
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime", 0);
"PrivacySandbox.AggregationService.Storage.Sql.CreationTime2", 0);
histograms.ExpectUniqueSample(
"PrivacySandbox.AggregationService.Storage.Sql.InitStatus",
AggregationServiceStorageSql::InitStatus::kSuccess, 1);
Expand Down
16 changes: 16 additions & 0 deletions tools/metrics/histograms/metadata/privacy/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ reviewer.

<histogram name="PrivacySandbox.AggregationService.Storage.Sql.CreationTime"
units="ms" expires_after="2023-02-23">
<obsolete>
PrivacySandbox.AggregationService.Storage.Sql.CreationTime2 which only
records when Threadticks is supported, 10/2022.
</obsolete>
<owner>alexmt@chromium.org</owner>
<owner>linnan@chromium.org</owner>
<summary>
Expand All @@ -389,6 +393,18 @@ reviewer.
</summary>
</histogram>

<histogram name="PrivacySandbox.AggregationService.Storage.Sql.CreationTime2"
units="ms" expires_after="2023-02-23">
<owner>alexmt@chromium.org</owner>
<owner>linnan@chromium.org</owner>
<summary>
Records the time it took to initialize a new aggregation service database
from scratch. Recorded when the aggregation service database finishes
initialization. Note that no event is recorded if `ThreadTicks` is not
supported.
</summary>
</histogram>

<histogram name="PrivacySandbox.AggregationService.Storage.Sql.InitStatus"
enum="PrivacySandboxAggregationServiceStorageSqlInitStatus"
expires_after="2022-10-23">
Expand Down

0 comments on commit 7f66748

Please sign in to comment.