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.stats.pas; 18 19 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.JS_RUN_STATUS_UNSET; 20 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.SIZE_UNSET; 21 22 import com.android.adservices.service.stats.AdsRelevanceStatusUtils; 23 24 import com.google.auto.value.AutoValue; 25 26 /** Class for logging execution of the encoding JavaScript stats. */ 27 @AutoValue 28 public abstract class EncodingJsExecutionStats { 29 /** Returns the time to run the JavaScript. */ getJsLatency()30 public abstract int getJsLatency(); 31 32 /** Returns encoded signals size in bytes. */ getEncodedSignalsSize()33 public abstract int getEncodedSignalsSize(); 34 35 /** Returns JavaScript run status. */ 36 @AdsRelevanceStatusUtils.JsRunStatus getRunStatus()37 public abstract int getRunStatus(); 38 39 /** Returns how much memory did the JavaScript use. */ getJsMemoryUsed()40 public abstract int getJsMemoryUsed(); 41 42 /** Returns AdTech's eTLD+1 when the JsRunStatus is not success. */ getAdTechId()43 public abstract String getAdTechId(); 44 45 /** Returns generic builder. */ builder()46 public static Builder builder() { 47 return new AutoValue_EncodingJsExecutionStats.Builder() 48 .setJsLatency(SIZE_UNSET) 49 .setEncodedSignalsSize(SIZE_UNSET) 50 .setRunStatus(JS_RUN_STATUS_UNSET) 51 .setJsMemoryUsed(0) 52 .setAdTechId(""); 53 } 54 55 /** Builder class for EncodingJsExecutionStats. */ 56 @AutoValue.Builder 57 public abstract static class Builder { setJsLatency(int value)58 public abstract Builder setJsLatency(int value); 59 setEncodedSignalsSize(int value)60 public abstract Builder setEncodedSignalsSize(int value); 61 setRunStatus(@dsRelevanceStatusUtils.JsRunStatus int value)62 public abstract Builder setRunStatus(@AdsRelevanceStatusUtils.JsRunStatus int value); 63 setJsMemoryUsed(int value)64 public abstract Builder setJsMemoryUsed(int value); 65 setAdTechId(String value)66 public abstract Builder setAdTechId(String value); 67 build()68 public abstract EncodingJsExecutionStats build(); 69 } 70 } 71