1 /*
2  * Copyright (C) 2022 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.stats;
18 
19 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.JS_RUN_STATUS_UNSET;
20 
21 import com.google.auto.value.AutoValue;
22 
23 /** Class for runAdScoring process reported stats. */
24 @AutoValue
25 public abstract class RunAdScoringProcessReportedStats {
26     /** @return getAdSelectionLogic latency in milliseconds. */
getGetAdSelectionLogicLatencyInMillis()27     public abstract int getGetAdSelectionLogicLatencyInMillis();
28 
29     /** @return getAdSelectionLogic result code. */
getGetAdSelectionLogicResultCode()30     public abstract int getGetAdSelectionLogicResultCode();
31 
32     /** @return getAdSelectionLogic script type. */
getGetAdSelectionLogicScriptType()33     public abstract int getGetAdSelectionLogicScriptType();
34 
35     /** @return fetched ad selection logic script size in bytes. */
getFetchedAdSelectionLogicScriptSizeInBytes()36     public abstract int getFetchedAdSelectionLogicScriptSizeInBytes();
37 
38     /** @return getTrustedScoringSignals latency in milliseconds. */
getGetTrustedScoringSignalsLatencyInMillis()39     public abstract int getGetTrustedScoringSignalsLatencyInMillis();
40 
41     /** @return getTrustedScoringSignals result code. */
getGetTrustedScoringSignalsResultCode()42     public abstract int getGetTrustedScoringSignalsResultCode();
43 
44     /** @return fetched trusted scoring signals data size in bytes. */
getFetchedTrustedScoringSignalsDataSizeInBytes()45     public abstract int getFetchedTrustedScoringSignalsDataSizeInBytes();
46 
47     /** @return the total scoreAds script execution time when getAdScores() is called. */
getScoreAdsLatencyInMillis()48     public abstract int getScoreAdsLatencyInMillis();
49 
50     /** @return the overall latency of the getAdScores(). */
getGetAdScoresLatencyInMillis()51     public abstract int getGetAdScoresLatencyInMillis();
52 
53     /** @return the getAdScores result code. */
getGetAdScoresResultCode()54     public abstract int getGetAdScoresResultCode();
55 
56     /** @return the num of CAs entered scoring. */
getNumOfCasEnteringScoring()57     public abstract int getNumOfCasEnteringScoring();
58 
59     /** @return the num of remarketing ads entered scoring. */
getNumOfRemarketingAdsEnteringScoring()60     public abstract int getNumOfRemarketingAdsEnteringScoring();
61 
62     /** @return the num of contextual ads entered scoring. */
getNumOfContextualAdsEnteringScoring()63     public abstract int getNumOfContextualAdsEnteringScoring();
64 
65     /** @return the overall latency of the runAdScoring process. */
getRunAdScoringLatencyInMillis()66     public abstract int getRunAdScoringLatencyInMillis();
67 
68     /** @return the runAdScoring result code. */
getRunAdScoringResultCode()69     public abstract int getRunAdScoringResultCode();
70 
71     /**
72      * @return whether the scoreAd SellerAdditionalSignals contained DataVersion.
73      */
getScoreAdSellerAdditionalSignalsContainedDataVersion()74     public abstract boolean getScoreAdSellerAdditionalSignalsContainedDataVersion();
75 
76     /**
77      * @return the ScoreAd JsScript result code.
78      */
79     @AdsRelevanceStatusUtils.JsRunStatus
getScoreAdJsScriptResultCode()80     public abstract int getScoreAdJsScriptResultCode();
81 
82     /** @return generic builder. */
builder()83     static Builder builder() {
84         return new AutoValue_RunAdScoringProcessReportedStats.Builder()
85                 .setScoreAdSellerAdditionalSignalsContainedDataVersion(false)
86                 .setScoreAdJsScriptResultCode(JS_RUN_STATUS_UNSET);
87     }
88 
89     /** Builder class for RunAdScoringProcessReportedStats. */
90     @AutoValue.Builder
91     abstract static class Builder {
setGetAdSelectionLogicLatencyInMillis(int value)92         abstract Builder setGetAdSelectionLogicLatencyInMillis(int value);
93 
setGetAdSelectionLogicResultCode(int value)94         abstract Builder setGetAdSelectionLogicResultCode(int value);
95 
setGetAdSelectionLogicScriptType(int value)96         abstract Builder setGetAdSelectionLogicScriptType(int value);
97 
setFetchedAdSelectionLogicScriptSizeInBytes(int value)98         abstract Builder setFetchedAdSelectionLogicScriptSizeInBytes(int value);
99 
setGetTrustedScoringSignalsLatencyInMillis(int value)100         abstract Builder setGetTrustedScoringSignalsLatencyInMillis(int value);
101 
setGetTrustedScoringSignalsResultCode(int value)102         abstract Builder setGetTrustedScoringSignalsResultCode(int value);
103 
setFetchedTrustedScoringSignalsDataSizeInBytes(int value)104         abstract Builder setFetchedTrustedScoringSignalsDataSizeInBytes(int value);
105 
setScoreAdsLatencyInMillis(int value)106         abstract Builder setScoreAdsLatencyInMillis(int value);
107 
setGetAdScoresLatencyInMillis(int value)108         abstract Builder setGetAdScoresLatencyInMillis(int value);
109 
setGetAdScoresResultCode(int value)110         abstract Builder setGetAdScoresResultCode(int value);
111 
setNumOfCasEnteringScoring(int value)112         abstract Builder setNumOfCasEnteringScoring(int value);
113 
setNumOfRemarketingAdsEnteringScoring(int value)114         abstract Builder setNumOfRemarketingAdsEnteringScoring(int value);
115 
setNumOfContextualAdsEnteringScoring(int value)116         abstract Builder setNumOfContextualAdsEnteringScoring(int value);
117 
setRunAdScoringLatencyInMillis(int value)118         abstract Builder setRunAdScoringLatencyInMillis(int value);
119 
setRunAdScoringResultCode(int value)120         abstract Builder setRunAdScoringResultCode(int value);
121 
setScoreAdSellerAdditionalSignalsContainedDataVersion(boolean value)122         abstract Builder setScoreAdSellerAdditionalSignalsContainedDataVersion(boolean value);
123 
setScoreAdJsScriptResultCode( @dsRelevanceStatusUtils.JsRunStatus int value)124         abstract Builder setScoreAdJsScriptResultCode(
125                 @AdsRelevanceStatusUtils.JsRunStatus int value);
126 
build()127         abstract RunAdScoringProcessReportedStats build();
128     }
129 }
130