Setting up the emit of the aggregate phase

This finds a proper spot to emit the aggregate phase of track 1. Since
we emit final phases of both track 1 and 2 using the same information
right afterwards, the aggregate phase can go right before that. That's
because it needs to fully collect the authentication entry clicks, which
may loop quite a while after the candidate finishes.

Bug: 271135048
Test: Build and won't submit without E2E Test
Change-Id: I94e95ead6e558fcb1f6be10d617f311b65eed7c3
This commit is contained in:
Arpan Kaphle
2023-05-02 20:55:20 +00:00
parent 9d77683ff3
commit e68cc2f42b
6 changed files with 27 additions and 19 deletions

View File

@@ -226,7 +226,7 @@ public class MetricUtilities {
/* auth_provider_status */
authenticationMetric.getProviderStatus(),
/* query_returned */
authenticationMetric.isQueryReturned()
authenticationMetric.isAuthReturned()
);
} catch (Exception e) {
Slog.w(TAG, "Unexpected error during candidate get metric logging: " + e);
@@ -454,9 +454,13 @@ public class MetricUtilities {
/*query_returned*/ candidateAggregateMetric.isQueryReturned(),
/*num_query_providers*/ candidateAggregateMetric.getNumProviders(),
/*min_query_start_timestamp_microseconds*/
DEFAULT_INT_32,
getMetricTimestampDifferenceMicroseconds(
candidateAggregateMetric.getMinProviderTimestampNanoseconds(),
candidateAggregateMetric.getServiceBeganTimeNanoseconds()),
/*max_query_end_timestamp_microseconds*/
DEFAULT_INT_32,
getMetricTimestampDifferenceMicroseconds(
candidateAggregateMetric.getMaxProviderTimestampNanoseconds(),
candidateAggregateMetric.getServiceBeganTimeNanoseconds()),
/*query_response_unique_classtypes*/
candidateAggregateMetric.getAggregateCollectiveQuery()
.getUniqueResponseStrings(),

View File

@@ -304,6 +304,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
* @param response the response associated with the API call that just completed
*/
protected void respondToClientWithResponseAndFinish(V response) {
mRequestSessionMetric.logCandidateAggregateMetrics(mProviders);
mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(/*has_exception=*/ false,
ProviderStatusForMetrics.FINAL_SUCCESS);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {
@@ -337,6 +338,7 @@ abstract class RequestSession<T, U, V> implements CredentialManagerUi.Credential
* @param errorMsg the error message given back in the flow
*/
protected void respondToClientWithErrorAndFinish(String errorType, String errorMsg) {
mRequestSessionMetric.logCandidateAggregateMetrics(mProviders);
mRequestSessionMetric.collectFinalPhaseProviderMetricStatus(
/*has_exception=*/ true, ProviderStatusForMetrics.FINAL_FAILURE);
if (mRequestSessionStatus == RequestSessionStatus.COMPLETE) {

View File

@@ -41,7 +41,7 @@ public class BrowsedAuthenticationMetric {
// The status of this particular provider
private int mProviderStatus = -1;
// Indicates if this provider returned from the authentication entry query, default false
private boolean mQueryReturned = false;
private boolean mAuthReturned = false;
// TODO(b/271135048) - Match the atom and provide a clean per provider session metric
// encapsulation.
@@ -83,12 +83,12 @@ public class BrowsedAuthenticationMetric {
mProviderStatus = providerStatus;
}
public void setQueryReturned(boolean queryReturned) {
mQueryReturned = queryReturned;
public void setAuthReturned(boolean authReturned) {
mAuthReturned = authReturned;
}
public boolean isQueryReturned() {
return mQueryReturned;
public boolean isAuthReturned() {
return mAuthReturned;
}
public int getProviderStatus() {

View File

@@ -54,13 +54,13 @@ public class CandidateAggregateMetric {
// The minimum of all the providers query start time, defaults to -1
private long mMinProviderTimestampNanoseconds = -1;
// The maximum of all the providers query finish time, defaults to -1
private long mMaxProviderTimestampsNanoseconds = -1;
// The total number of failures across all the providers, defaults to -1
private int mTotalQueryFailures = -1;
private long mMaxProviderTimestampNanoseconds = -1;
// The total number of failures across all the providers, defaults to 0
private int mTotalQueryFailures = 0;
// The map of all seen framework exceptions and their counts across all providers, default empty
private Map<String, Integer> mExceptionCountQuery = new LinkedHashMap<>();
// The total number of failures across all auth entries, defaults to -1
private int mTotalAuthFailures = -1;
// The total number of failures across all auth entries, defaults to 0
private int mTotalAuthFailures = 0;
// The map of all seen framework exceptions and their counts across auth entries, default empty
private Map<String, Integer> mExceptionCountAuth = new LinkedHashMap<>();
@@ -114,7 +114,7 @@ public class CandidateAggregateMetric {
}
}
mMinProviderTimestampNanoseconds = min_query_start;
mMaxProviderTimestampsNanoseconds = max_query_end;
mMaxProviderTimestampNanoseconds = max_query_end;
mAggregateCollectiveQuery = new ResponseCollective(responseCountQuery, entryCountQuery);
}
@@ -128,7 +128,7 @@ public class CandidateAggregateMetric {
var authMetrics = sessionMetric.getBrowsedAuthenticationMetric();
mNumAuthEntriesTapped += authMetrics.size();
for (var authMetric : authMetrics) {
mAuthReturned = mAuthReturned || authMetric.isQueryReturned();
mAuthReturned = mAuthReturned || authMetric.isAuthReturned();
ResponseCollective authCollective = authMetric.getAuthEntryCollective();
ResponseCollective.combineTypeCountMaps(responseCountAuth,
authCollective.getResponseCountsMap());
@@ -170,8 +170,8 @@ public class CandidateAggregateMetric {
return mAuthReturned;
}
public long getMaxProviderTimestampsNanoseconds() {
return mMaxProviderTimestampsNanoseconds;
public long getMaxProviderTimestampNanoseconds() {
return mMaxProviderTimestampNanoseconds;
}
public long getMinProviderTimestampNanoseconds() {

View File

@@ -126,12 +126,12 @@ public class ProviderSessionMetric {
getUsedAuthenticationMetric();
mostRecentAuthenticationMetric.setProviderUid(providerSessionUid);
if (isFailureStatus) {
mostRecentAuthenticationMetric.setQueryReturned(false);
mostRecentAuthenticationMetric.setAuthReturned(false);
mostRecentAuthenticationMetric.setProviderStatus(
ProviderStatusForMetrics.QUERY_FAILURE
.getMetricCode());
} else if (isCompletionStatus) {
mostRecentAuthenticationMetric.setQueryReturned(true);
mostRecentAuthenticationMetric.setAuthReturned(true);
mostRecentAuthenticationMetric.setProviderStatus(
ProviderStatusForMetrics.QUERY_SUCCESS
.getMetricCode());

View File

@@ -20,6 +20,7 @@ import static com.android.server.credentials.MetricUtilities.DEFAULT_INT_32;
import static com.android.server.credentials.MetricUtilities.DELTA_EXCEPTION_CUT;
import static com.android.server.credentials.MetricUtilities.DELTA_RESPONSES_CUT;
import static com.android.server.credentials.MetricUtilities.generateMetricKey;
import static com.android.server.credentials.MetricUtilities.logApiCalledAggregateCandidate;
import static com.android.server.credentials.MetricUtilities.logApiCalledAuthenticationMetric;
import static com.android.server.credentials.MetricUtilities.logApiCalledCandidateGetMetric;
import static com.android.server.credentials.MetricUtilities.logApiCalledCandidatePhase;
@@ -357,6 +358,7 @@ public class RequestSessionMetric {
public void logCandidateAggregateMetrics(Map<String, ProviderSession> providers) {
try {
mCandidateAggregateMetric.collectAverages(providers);
logApiCalledAggregateCandidate(mCandidateAggregateMetric, ++mSequenceCounter);
} catch (Exception e) {
Slog.i(TAG, "Unexpected error during aggregate candidate logging " + e);
}