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 number of buyers to the {@link GetAdSelectionDataApiCalledStats#builder()} */ setServerAuctionCoordinatorSource( GetAdSelectionDataApiCalledStats.Builder builder, @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource)36 void setServerAuctionCoordinatorSource( 37 GetAdSelectionDataApiCalledStats.Builder builder, 38 @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource); 39 40 /** Invokes the logger to log {@link GetAdSelectionDataApiCalledStats} */ logGetAdSelectionDataApiCalledStats( GetAdSelectionDataApiCalledStats.Builder builder, int payloadSize, @AdServicesStatusUtils.StatusCode int statusCode)41 void logGetAdSelectionDataApiCalledStats( 42 GetAdSelectionDataApiCalledStats.Builder builder, 43 int payloadSize, 44 @AdServicesStatusUtils.StatusCode int statusCode); 45 46 /** 47 * Loops thorough each buyer and logs {@link 48 * com.android.adservices.service.stats.GetAdSelectionDataBuyerInputGeneratedStats} 49 */ logGetAdSelectionDataBuyerInputGeneratedStats( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap)50 void logGetAdSelectionDataBuyerInputGeneratedStats( 51 Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap); 52 53 /** 54 * Adds this custom audiences stats to the map of buyer to {@link 55 * BuyerInputGeneratorIntermediateStats} 56 */ addToBuyerIntermediateStats( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> perBuyerStats, DBCustomAudience dbCustomAudience, BiddingAuctionServers.BuyerInput.CustomAudience customAudience)57 void addToBuyerIntermediateStats( 58 Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> perBuyerStats, 59 DBCustomAudience dbCustomAudience, 60 BiddingAuctionServers.BuyerInput.CustomAudience customAudience); 61 62 /** 63 * Loops thorough each buyer and logs {@link 64 * com.android.adservices.service.stats.GetAdSelectionDataBuyerInputGeneratedStats} with 65 * extended PAS metrics 66 */ logGetAdSelectionDataBuyerInputGeneratedStatsWithExtendedPasMetrics( Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap, int encodedSignalsCount, int encodedSignalsTotalSizeInBytes, int encodedSignalsMaxSizeInBytes, int encodedSignalsMinSizeInBytes)67 void logGetAdSelectionDataBuyerInputGeneratedStatsWithExtendedPasMetrics( 68 Map<AdTechIdentifier, BuyerInputGeneratorIntermediateStats> statsMap, 69 int encodedSignalsCount, 70 int encodedSignalsTotalSizeInBytes, 71 int encodedSignalsMaxSizeInBytes, 72 int encodedSignalsMinSizeInBytes); 73 } 74