• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.adservices.service.adselection;
18 
19 import android.adservices.common.AdServicesStatusUtils;
20 import android.adservices.common.AdTechIdentifier;
21 
22 import com.android.adservices.data.customaudience.DBCustomAudience;
23 import com.android.adservices.service.proto.bidding_auction_servers.BiddingAuctionServers;
24 import com.android.adservices.service.stats.AdsRelevanceStatusUtils;
25 import com.android.adservices.service.stats.BuyerInputGeneratorIntermediateStats;
26 import com.android.adservices.service.stats.GetAdSelectionDataApiCalledStats;
27 
28 import java.util.Map;
29 
30 /** Strategy interface denoting how to log GetAdSelectionData payload size metrics */
31 public interface AuctionServerPayloadMetricsStrategy {
32     /** Sets the number of buyers to the {@link GetAdSelectionDataApiCalledStats#builder()} */
setNumBuyers(GetAdSelectionDataApiCalledStats.Builder builder, int numBuyers)33     void setNumBuyers(GetAdSelectionDataApiCalledStats.Builder builder, int numBuyers);
34 
35     /** Sets the seller configuration metrics. */
setSellerConfigurationMetrics( GetAdSelectionDataApiCalledStats.Builder builder, GetAdSelectionDataApiCalledStats.PayloadOptimizationResult payloadOptimizationResult, int inputGenerationLatencyMs, int compressedBuyerInputCreatorVersion, int numReEstimations)36     void setSellerConfigurationMetrics(
37             GetAdSelectionDataApiCalledStats.Builder builder,
38             GetAdSelectionDataApiCalledStats.PayloadOptimizationResult payloadOptimizationResult,
39             int inputGenerationLatencyMs,
40             int compressedBuyerInputCreatorVersion,
41             int numReEstimations);
42 
43     /** Sets the seller's requested payload max size in kb. */
setSellerMaxPayloadSizeKb( GetAdSelectionDataApiCalledStats.Builder builder, int sellerMaxPayloadSizeKb)44     void setSellerMaxPayloadSizeKb(
45             GetAdSelectionDataApiCalledStats.Builder builder, int sellerMaxPayloadSizeKb);
46 
47     /** Sets the input generation latency and compressed buyer input creator version. */
setInputGenerationLatencyMsAndBuyerCreatorVersion( GetAdSelectionDataApiCalledStats.Builder builder, int inputGenerationLatencyMs, int compressedBuyerInputCreatorVersion)48     void setInputGenerationLatencyMsAndBuyerCreatorVersion(
49             GetAdSelectionDataApiCalledStats.Builder builder,
50             int inputGenerationLatencyMs,
51             int compressedBuyerInputCreatorVersion);
52 
53     /** Sets the number of buyers to the {@link GetAdSelectionDataApiCalledStats#builder()} */
setServerAuctionCoordinatorSource( GetAdSelectionDataApiCalledStats.Builder builder, @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource)54     void setServerAuctionCoordinatorSource(
55             GetAdSelectionDataApiCalledStats.Builder builder,
56             @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource);
57 
58     /** Invokes the logger to log {@link GetAdSelectionDataApiCalledStats} */
logGetAdSelectionDataApiCalledStats( GetAdSelectionDataApiCalledStats.Builder builder, int payloadSize, @AdServicesStatusUtils.StatusCode int statusCode)59     void logGetAdSelectionDataApiCalledStats(
60             GetAdSelectionDataApiCalledStats.Builder builder,
61             int payloadSize,
62             @AdServicesStatusUtils.StatusCode int statusCode);
63 
64     /**
65      * Loops thorough each buyer and logs {@link
66      * com.android.adservices.service.stats.GetAdSelectionDataBuyerInputGeneratedStats}
67      */
logGetAdSelectionDataBuyerInputGeneratedStats( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap)68     void logGetAdSelectionDataBuyerInputGeneratedStats(
69             Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap);
70 
71     /**
72      * Adds this custom audiences stats to the map of buyer to {@link
73      * BuyerInputGeneratorIntermediateStats}
74      */
addToBuyerIntermediateStats( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> perBuyerStats, DBCustomAudience dbCustomAudience, BiddingAuctionServers.BuyerInput.CustomAudience customAudience)75     void addToBuyerIntermediateStats(
76             Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> perBuyerStats,
77             DBCustomAudience dbCustomAudience,
78             BiddingAuctionServers.BuyerInput.CustomAudience customAudience);
79 
80     /**
81      * Loops thorough each buyer and logs {@link
82      * com.android.adservices.service.stats.GetAdSelectionDataBuyerInputGeneratedStats} with
83      * extended PAS metrics
84      */
logGetAdSelectionDataBuyerInputGeneratedStatsWithExtendedPasMetrics( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap, int encodedSignalsCount, int encodedSignalsTotalSizeInBytes, int encodedSignalsMaxSizeInBytes, int encodedSignalsMinSizeInBytes)85     void logGetAdSelectionDataBuyerInputGeneratedStatsWithExtendedPasMetrics(
86             Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap,
87             int encodedSignalsCount,
88             int encodedSignalsTotalSizeInBytes,
89             int encodedSignalsMaxSizeInBytes,
90             int encodedSignalsMinSizeInBytes);
91 }
92