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
This commit is contained in:
Arpan Kaphle
2023-03-03 19:38:17 +00:00
parent b7d1ff47e6
commit cf04631a9a
3 changed files with 80 additions and 11 deletions

View File

@@ -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 {

View File

@@ -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() {

View File

@@ -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;
}
}