diff options
author | Akshay Miterani <akshaymiterani@google.com> | 2022-10-31 23:36:37 +0000 |
---|---|---|
committer | Akshay Miterani <akshaymiterani@google.com> | 2022-11-01 06:49:23 +0000 |
commit | 7fecafced26913e084df244b1667003ab0b55fe6 (patch) | |
tree | 5110bd536780ea7a633be4f6cca5dceb439af942 | |
parent | 14f8da51a473542057639c1448ae6e9351bc1e96 (diff) | |
download | AdServices-7fecafced26913e084df244b1667003ab0b55fe6.tar.gz |
Add count of topic ids returned in the GetTopics API call.
Design doc: go/rb-aggregated-classifier-metrics
Eldar: http://eldar/u/0/assessments/180284551/drafts/335994807?jsmode=du&mods=eldarui_search#sections/999003
Bug: 256651503
Bug: 254302206
Bug: 246360597
Test: m; atest CacheManagerTest
Change-Id: Ia61ddcae655b2efc71939a80436d45a1e7b8aeac
4 files changed, 19 insertions, 20 deletions
diff --git a/adservices/service-core/java/com/android/adservices/service/stats/GetTopicsReportedStats.java b/adservices/service-core/java/com/android/adservices/service/stats/GetTopicsReportedStats.java index 359504815b..06b4c2c14f 100644 --- a/adservices/service-core/java/com/android/adservices/service/stats/GetTopicsReportedStats.java +++ b/adservices/service-core/java/com/android/adservices/service/stats/GetTopicsReportedStats.java @@ -17,20 +17,19 @@ package com.android.adservices.service.stats; import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; /** Class for AdServicesGetTopicsReported atom. */ @AutoValue public abstract class GetTopicsReportedStats { - /** @return the list of topic ids. */ - public abstract ImmutableList<Integer> getTopicIds(); - /** @return number of topic ids filtered due to duplication. */ public abstract int getDuplicateTopicCount(); /** @return number of topic ids filtered due to being blocked. */ public abstract int getFilteredBlockedTopicCount(); + /** @return number of topic ids returned. */ + public abstract int getTopicIdsCount(); + /** @return generic builder. */ public static GetTopicsReportedStats.Builder builder() { return new AutoValue_GetTopicsReportedStats.Builder(); @@ -39,15 +38,15 @@ public abstract class GetTopicsReportedStats { /** Builder class for {@link GetTopicsReportedStats}. */ @AutoValue.Builder public abstract static class Builder { - /** Set topic ids. */ - public abstract GetTopicsReportedStats.Builder setTopicIds(ImmutableList<Integer> value); - /** Set duplicate topic count. */ public abstract GetTopicsReportedStats.Builder setDuplicateTopicCount(int value); /** Set filtered blocked topic count. */ public abstract GetTopicsReportedStats.Builder setFilteredBlockedTopicCount(int value); + /** Set number of topic ids returned. */ + public abstract GetTopicsReportedStats.Builder setTopicIdsCount(int value); + /** build for {@link GetTopicsReportedStats}. */ public abstract GetTopicsReportedStats build(); } diff --git a/adservices/service-core/java/com/android/adservices/service/stats/StatsdAdServicesLogger.java b/adservices/service-core/java/com/android/adservices/service/stats/StatsdAdServicesLogger.java index c506877acb..23eec17e21 100644 --- a/adservices/service-core/java/com/android/adservices/service/stats/StatsdAdServicesLogger.java +++ b/adservices/service-core/java/com/android/adservices/service/stats/StatsdAdServicesLogger.java @@ -189,8 +189,10 @@ public class StatsdAdServicesLogger implements AdServicesLogger { public void logGetTopicsReportedStats(GetTopicsReportedStats stats) { AdServicesStatsLog.write( AD_SERVICES_GET_TOPICS_REPORTED, - stats.getTopicIds().stream().mapToInt(Integer::intValue).toArray(), + new int[] {}, // TODO(b/256649873): Log empty topic ids until the long term + // solution. stats.getDuplicateTopicCount(), - stats.getFilteredBlockedTopicCount()); + stats.getFilteredBlockedTopicCount(), + stats.getTopicIdsCount()); } } diff --git a/adservices/service-core/java/com/android/adservices/service/topics/CacheManager.java b/adservices/service-core/java/com/android/adservices/service/topics/CacheManager.java index c90eb617a1..25358bf528 100644 --- a/adservices/service-core/java/com/android/adservices/service/topics/CacheManager.java +++ b/adservices/service-core/java/com/android/adservices/service/topics/CacheManager.java @@ -178,9 +178,9 @@ public class CacheManager implements Dumpable { } mLogger.logGetTopicsReportedStats( GetTopicsReportedStats.builder() - .setTopicIds(topicIds.build()) .setDuplicateTopicCount(duplicateTopicCount) .setFilteredBlockedTopicCount(blockedTopicCount) + .setTopicIdsCount(topics.size()) .build()); return topics; diff --git a/adservices/tests/unittest/service-core/src/com/android/adservices/service/topics/CacheManagerTest.java b/adservices/tests/unittest/service-core/src/com/android/adservices/service/topics/CacheManagerTest.java index 22ff48c95a..ef39584e4a 100644 --- a/adservices/tests/unittest/service-core/src/com/android/adservices/service/topics/CacheManagerTest.java +++ b/adservices/tests/unittest/service-core/src/com/android/adservices/service/topics/CacheManagerTest.java @@ -38,7 +38,6 @@ import com.android.adservices.service.Flags; import com.android.adservices.service.stats.AdServicesLogger; import com.android.adservices.service.stats.GetTopicsReportedStats; -import com.google.common.collect.ImmutableList; import org.junit.Before; import org.junit.Test; @@ -105,9 +104,9 @@ public final class CacheManagerTest { .logGetTopicsReportedStats( eq( GetTopicsReportedStats.builder() - .setTopicIds(ImmutableList.of()) .setFilteredBlockedTopicCount(0) .setDuplicateTopicCount(0) + .setTopicIdsCount(0) .build())); } @@ -237,9 +236,9 @@ public final class CacheManagerTest { assertThat(argument.getAllValues().get(0)) .isEqualTo( GetTopicsReportedStats.builder() - .setTopicIds(ImmutableList.of()) .setFilteredBlockedTopicCount(0) .setDuplicateTopicCount(0) + .setTopicIdsCount(0) .build()); } @@ -376,9 +375,9 @@ public final class CacheManagerTest { assertThat(argument.getAllValues().get(0)) .isEqualTo( GetTopicsReportedStats.builder() - .setTopicIds(ImmutableList.of()) .setFilteredBlockedTopicCount(0) .setDuplicateTopicCount(0) + .setTopicIdsCount(0) .build()); } @@ -452,20 +451,19 @@ public final class CacheManagerTest { assertThat(argument.getAllValues()).hasSize(3); // Should return topic1, topic2 and topic3, but topic2 is blocked - so only topic1 and // topic3 are expected. - assertThat(argument.getAllValues().get(0).getTopicIds()) - .containsExactly(topic1.getTopic(), topic3.getTopic()); assertThat(argument.getAllValues().get(0).getFilteredBlockedTopicCount()).isEqualTo(1); assertThat(argument.getAllValues().get(0).getDuplicateTopicCount()).isEqualTo(0); + assertThat(argument.getAllValues().get(0).getTopicIdsCount()).isEqualTo(2); // Should return topic1 and topic2, but topic2 is blocked 2 times - so only topic1 is // expected. - assertThat(argument.getAllValues().get(1).getTopicIds()).containsExactly(topic1.getTopic()); assertThat(argument.getAllValues().get(1).getFilteredBlockedTopicCount()).isEqualTo(2); assertThat(argument.getAllValues().get(1).getDuplicateTopicCount()).isEqualTo(0); + assertThat(argument.getAllValues().get(1).getTopicIdsCount()).isEqualTo(1); // Should return topic1 and topic2, but topic2 is blocked - so only topic1 is expected. // topic1 is deduplicated. - assertThat(argument.getAllValues().get(2).getTopicIds()).containsExactly(topic1.getTopic()); assertThat(argument.getAllValues().get(2).getFilteredBlockedTopicCount()).isEqualTo(1); assertThat(argument.getAllValues().get(2).getDuplicateTopicCount()).isEqualTo(1); + assertThat(argument.getAllValues().get(2).getTopicIdsCount()).isEqualTo(1); } @Test @@ -636,9 +634,9 @@ public final class CacheManagerTest { assertThat(argument.getAllValues().get(0)) .isEqualTo( GetTopicsReportedStats.builder() - .setTopicIds(ImmutableList.of(topic1.getTopic())) .setFilteredBlockedTopicCount(0) .setDuplicateTopicCount(0) + .setTopicIdsCount(1) .build()); } @@ -662,9 +660,9 @@ public final class CacheManagerTest { .logGetTopicsReportedStats( eq( GetTopicsReportedStats.builder() - .setTopicIds(ImmutableList.of()) .setFilteredBlockedTopicCount(0) .setDuplicateTopicCount(0) + .setTopicIdsCount(0) .build())); } |