diff --git a/services/credentials/java/com/android/server/credentials/MetricUtilities.java b/services/credentials/java/com/android/server/credentials/MetricUtilities.java index 25400394816e9..a86974a47d2ab 100644 --- a/services/credentials/java/com/android/server/credentials/MetricUtilities.java +++ b/services/credentials/java/com/android/server/credentials/MetricUtilities.java @@ -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(), diff --git a/services/credentials/java/com/android/server/credentials/RequestSession.java b/services/credentials/java/com/android/server/credentials/RequestSession.java index e48534c9c0413..38372ad551784 100644 --- a/services/credentials/java/com/android/server/credentials/RequestSession.java +++ b/services/credentials/java/com/android/server/credentials/RequestSession.java @@ -304,6 +304,7 @@ abstract class RequestSession 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 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) { diff --git a/services/credentials/java/com/android/server/credentials/metrics/BrowsedAuthenticationMetric.java b/services/credentials/java/com/android/server/credentials/metrics/BrowsedAuthenticationMetric.java index e24d7994a7978..62b8f24eb2013 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/BrowsedAuthenticationMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/BrowsedAuthenticationMetric.java @@ -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() { diff --git a/services/credentials/java/com/android/server/credentials/metrics/CandidateAggregateMetric.java b/services/credentials/java/com/android/server/credentials/metrics/CandidateAggregateMetric.java index 5a2a07994e505..339c221b0cccb 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/CandidateAggregateMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/CandidateAggregateMetric.java @@ -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 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 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() { diff --git a/services/credentials/java/com/android/server/credentials/metrics/ProviderSessionMetric.java b/services/credentials/java/com/android/server/credentials/metrics/ProviderSessionMetric.java index da386fd762b1f..99181c80bbd4f 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/ProviderSessionMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/ProviderSessionMetric.java @@ -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()); diff --git a/services/credentials/java/com/android/server/credentials/metrics/RequestSessionMetric.java b/services/credentials/java/com/android/server/credentials/metrics/RequestSessionMetric.java index 009cfa852bf40..a9e241fc7fce9 100644 --- a/services/credentials/java/com/android/server/credentials/metrics/RequestSessionMetric.java +++ b/services/credentials/java/com/android/server/credentials/metrics/RequestSessionMetric.java @@ -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 providers) { try { mCandidateAggregateMetric.collectAverages(providers); + logApiCalledAggregateCandidate(mCandidateAggregateMetric, ++mSequenceCounter); } catch (Exception e) { Slog.i(TAG, "Unexpected error during aggregate candidate logging " + e); }