From cf04631a9a0f0645e984888b8af9752a35199f5e Mon Sep 17 00:00:00 2001 From: Arpan Kaphle Date: Fri, 3 Mar 2023 19:38:17 +0000 Subject: [PATCH] Adding in Logic to hold Split 1/3 - InitPhase This sets up the underlying metric object to hold the required data across the flow for the PreCandidate split - known as the InitialPhase. This will be a part of the setup of the V3 metrics. Bug: 270403549 Test: To be chained in, building for now Change-Id: Idbc376cf79d0a7054192d66337ba1ff4cc82ca61 --- .../metrics/CandidateProviderMetric.java | 3 + .../metrics/ChosenProviderMetric.java | 15 ++-- ...ateMetric.java => InitialPhaseMetric.java} | 73 ++++++++++++++++++- 3 files changed, 80 insertions(+), 11 deletions(-) rename services/credentials/java/com/android/server/credentials/metrics/{PreCandidateMetric.java => InitialPhaseMetric.java} (53%) diff --git a/services/credentials/java/com/android/server/credentials/metrics/CandidateProviderMetric.java b/services/credentials/java/com/android/server/credentials/metrics/CandidateProviderMetric.java index f49995d041aad..9f438ecc11460 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/CandidateProviderMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/CandidateProviderMetric.java @@ -18,6 +18,9 @@ package com.android.server.credentials.metrics; /** * The central candidate provider metric object that mimics our defined metric setup. + * Some types are redundant across these metric collectors, but that has debug use-cases as + * these data-types are available at different moments of the flow (and typically, one can feed + * into the next). * TODO(b/270403549) - iterate on this in V3+ */ public class CandidateProviderMetric { diff --git a/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderMetric.java b/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderMetric.java index 75fdc567013cf..03102558d21bc 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/ChosenProviderMetric.java @@ -22,6 +22,9 @@ import com.android.server.credentials.MetricUtilities; /** * The central chosen provider metric object that mimics our defined metric setup. + * Some types are redundant across these metric collectors, but that has debug use-cases as + * these data-types are available at different moments of the flow (and typically, one can feed + * into the next). * TODO(b/270403549) - iterate on this in V3+ */ public class ChosenProviderMetric { @@ -65,12 +68,12 @@ public class ChosenProviderMetric { /** * In order for a chosen provider to be selected, the call must have successfully begun. - * Thus, the {@link PreCandidateMetric} can directly pass this initial latency figure into + * Thus, the {@link InitialPhaseMetric} can directly pass this initial latency figure into * this chosen provider metric. * * @param preQueryPhaseLatencyMicroseconds the millisecond latency for the service start, * typically passed in through the - * {@link PreCandidateMetric} + * {@link InitialPhaseMetric} */ public void setPreQueryPhaseLatencyMicroseconds(int preQueryPhaseLatencyMicroseconds) { mPreQueryPhaseLatencyMicroseconds = preQueryPhaseLatencyMicroseconds; @@ -112,7 +115,7 @@ public class ChosenProviderMetric { /** * Returns the full (platform invoked to response) latency in microseconds. Expects the - * start time to be provided, such as from {@link PreCandidateMetric}. + * start time to be provided, such as from {@link InitialPhaseMetric}. */ public int getEntireLatencyMicroseconds() { return (int) ((this.mFinalFinishTimeNanoseconds @@ -123,11 +126,11 @@ public class ChosenProviderMetric { /** * In order for a chosen provider to be selected, the call must have successfully begun. - * Thus, the {@link PreCandidateMetric} can directly pass this initial timestamp into this + * Thus, the {@link InitialPhaseMetric} can directly pass this initial timestamp into this * chosen provider metric. * * @param serviceBeganTimeNanoseconds the timestamp moment when the platform was called, - * typically passed in through the {@link PreCandidateMetric} + * typically passed in through the {@link InitialPhaseMetric} */ public void setServiceBeganTimeNanoseconds(long serviceBeganTimeNanoseconds) { mServiceBeganTimeNanoseconds = serviceBeganTimeNanoseconds; @@ -188,8 +191,6 @@ public class ChosenProviderMetric { - this.mServiceBeganTimeNanoseconds) / 1000); } - - /* ----------- Provider Status -------------- */ public int getChosenProviderStatus() { diff --git a/services/credentials/java/com/android/server/credentials/metrics/PreCandidateMetric.java b/services/credentials/java/com/android/server/credentials/metrics/InitialPhaseMetric.java similarity index 53% rename from services/credentials/java/com/android/server/credentials/metrics/PreCandidateMetric.java rename to services/credentials/java/com/android/server/credentials/metrics/InitialPhaseMetric.java index 952328f6ba3ae..5f062b05df67c 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/PreCandidateMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/InitialPhaseMetric.java @@ -18,19 +18,34 @@ package com.android.server.credentials.metrics; /** * This handles metrics collected prior to any remote calls to providers. + * Some types are redundant across these metric collectors, but that has debug use-cases as + * these data-types are available at different moments of the flow (and typically, one can feed + * into the next). * TODO(b/270403549) - iterate on this in V3+ */ -public class PreCandidateMetric { - +public class InitialPhaseMetric { private static final String TAG = "PreCandidateMetric"; + // The api being called, default set to unknown + private int mApiName = ApiName.UNKNOWN.getMetricCode(); + // The caller uid of the calling application, default to -1 + private int mCallerUid = -1; + // The session id to unite multiple atom emits, default to -1 + private long mSessionId = -1; + // A sequence id to order united emits, default to -1 + private int mSequenceId = -1; + private int mCountRequestClassType = -1; + // Raw timestamps in nanoseconds, *the only* one logged as such (i.e. 64 bits) since it is a // reference point. - private long mCredentialServiceStartedTimeNanoseconds = -1; + + // A reference point to give this object utility to capture latency. Can be directly handed + // over to the next latency object. private long mCredentialServiceBeginQueryTimeNanoseconds = -1; - public PreCandidateMetric() { + + public InitialPhaseMetric() { } /* ---------- Latencies ---------- */ @@ -62,4 +77,54 @@ public class PreCandidateMetric { public long getCredentialServiceBeginQueryTimeNanoseconds() { return mCredentialServiceBeginQueryTimeNanoseconds; } + + /* ------ ApiName ------ */ + + public void setApiName(int apiName) { + mApiName = apiName; + } + + public int getApiName() { + return mApiName; + } + + /* ------ CallerUid ------ */ + + public void setCallerUid(int callerUid) { + mCallerUid = callerUid; + } + + public int getCallerUid() { + return mCallerUid; + } + + /* ------ SessionId ------ */ + + public void setSessionId(long sessionId) { + mSessionId = sessionId; + } + + public long getSessionId() { + return mSessionId; + } + + /* ------ SequenceId ------ */ + + public void setSequenceId(int sequenceId) { + mSequenceId = sequenceId; + } + + public int getSequenceId() { + return mSequenceId; + } + + /* ------ Count Request Class Types ------ */ + + public void setCountRequestClassType(int countRequestClassType) { + mCountRequestClassType = countRequestClassType; + } + + public int getCountRequestClassType() { + return mCountRequestClassType; + } }