diff options
author | zachh <zachh@google.com> | 2018-05-07 17:31:16 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-09 16:55:34 -0700 |
commit | 4f2b93012de1c9092cd7b3cfc488e794b45cbdd7 (patch) | |
tree | 0a3a4cf0dfc3cfc207a92ee915842808f7b3f49b /java | |
parent | c0200c4d60cf662f5e6aa422a810646ff02928b8 (diff) |
Added getLoggingName() to CallLogDataSource and PhoneLookup interfaces.
Use it when logging performance metrics.
Unfortunately the class names returned by Class#getSimpleName() are obfuscated by proguard and make viewing the metrics difficult to impossible.
TEST=none
Test: none
PiperOrigin-RevId: 195749831
Change-Id: I40320f388d34e059c9a913e2b72a1acf1a727f60
Diffstat (limited to 'java')
14 files changed, 90 insertions, 23 deletions
diff --git a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java index 32c278838..fb3700efe 100644 --- a/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java +++ b/java/com/android/dialer/calllog/RefreshAnnotatedCallLogWorker.java @@ -156,8 +156,7 @@ public class RefreshAnnotatedCallLogWorker { for (CallLogDataSource dataSource : dataSources.getDataSourcesIncludingSystemCallLog()) { ListenableFuture<Boolean> dataSourceDirty = dataSource.isDirty(); isDirtyFutures.add(dataSourceDirty); - String eventName = - String.format(Metrics.IS_DIRTY_TEMPLATE, dataSource.getClass().getSimpleName()); + String eventName = String.format(Metrics.IS_DIRTY_TEMPLATE, dataSource.getLoggingName()); futureTimer.applyTiming(dataSourceDirty, eventName, LogCatMode.LOG_VALUES); } // Simultaneously invokes isDirty on all data sources, returning as soon as one returns true. @@ -242,7 +241,7 @@ public class RefreshAnnotatedCallLogWorker { private static String eventNameForFill(CallLogDataSource dataSource, boolean isBuilt) { return String.format( !isBuilt ? Metrics.INITIAL_FILL_TEMPLATE : Metrics.FILL_TEMPLATE, - dataSource.getClass().getSimpleName()); + dataSource.getLoggingName()); } private static String eventNameForOverallFill(boolean isBuilt) { @@ -255,7 +254,7 @@ public class RefreshAnnotatedCallLogWorker { !isBuilt ? Metrics.INITIAL_ON_SUCCESSFUL_FILL_TEMPLATE : Metrics.ON_SUCCESSFUL_FILL_TEMPLATE, - dataSource.getClass().getSimpleName()); + dataSource.getLoggingName()); } private static String eventNameForOverallOnSuccessfulFill(boolean isBuilt) { diff --git a/java/com/android/dialer/calllog/datasources/CallLogDataSource.java b/java/com/android/dialer/calllog/datasources/CallLogDataSource.java index f6796c767..75f06d5f6 100644 --- a/java/com/android/dialer/calllog/datasources/CallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/CallLogDataSource.java @@ -113,4 +113,11 @@ public interface CallLogDataSource { */ @MainThread ListenableFuture<Void> clearData(); + + /** + * The name of this daa source for logging purposes. This is generally the same as the class name + * (but should not use methods from {@link Class} because the class names are generally obfuscated + * by Proguard. + */ + String getLoggingName(); } diff --git a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java index 0de987308..66d29a7ef 100644 --- a/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java +++ b/java/com/android/dialer/calllog/datasources/phonelookup/PhoneLookupDataSource.java @@ -320,6 +320,11 @@ public final class PhoneLookupDataSource implements CallLogDataSource { MoreExecutors.directExecutor()); } + @Override + public String getLoggingName() { + return "PhoneLookupDataSource"; + } + private static ImmutableSet<DialerPhoneNumber> queryDistinctDialerPhoneNumbersFromAnnotatedCallLog(Context appContext) { ImmutableSet.Builder<DialerPhoneNumber> numbers = ImmutableSet.builder(); diff --git a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java index b5067daac..a08b50eb8 100644 --- a/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java +++ b/java/com/android/dialer/calllog/datasources/systemcalllog/SystemCallLogDataSource.java @@ -148,6 +148,11 @@ public class SystemCallLogDataSource implements CallLogDataSource { } @Override + public String getLoggingName() { + return "SystemCallLogDataSource"; + } + + @Override public ListenableFuture<Boolean> isDirty() { return backgroundExecutorService.submit(this::isDirtyInternal); } diff --git a/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java b/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java index ab9288a1e..7a230220e 100644 --- a/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java +++ b/java/com/android/dialer/calllog/datasources/voicemail/VoicemailDataSource.java @@ -121,4 +121,9 @@ public class VoicemailDataSource implements CallLogDataSource { public ListenableFuture<Void> clearData() { return Futures.immediateFuture(null); } + + @Override + public String getLoggingName() { + return "VoicemailDataSource"; + } } diff --git a/java/com/android/dialer/phonelookup/PhoneLookup.java b/java/com/android/dialer/phonelookup/PhoneLookup.java index 0b9cbf6eb..1043ee775 100644 --- a/java/com/android/dialer/phonelookup/PhoneLookup.java +++ b/java/com/android/dialer/phonelookup/PhoneLookup.java @@ -135,4 +135,11 @@ public interface PhoneLookup<T> { * disabled (because for example there was a problem with it). */ ListenableFuture<Void> clearData(); + + /** + * The name of this lookup for logging purposes. This is generally the same as the class name (but + * should not use methods from {@link Class} because the class names are generally obfuscated by + * Proguard. + */ + String getLoggingName(); } diff --git a/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java b/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java index fe6642eef..4192e7932 100644 --- a/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/blockednumber/SystemBlockedNumberPhoneLookup.java @@ -181,4 +181,9 @@ public class SystemBlockedNumberPhoneLookup implements PhoneLookup<SystemBlocked public ListenableFuture<Void> clearData() { return Futures.immediateFuture(null); } + + @Override + public String getLoggingName() { + return "SystemBlockedNumberPhoneLookup"; + } } diff --git a/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java b/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java index 36d0be40f..b045d0396 100644 --- a/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cequint/CequintPhoneLookup.java @@ -141,6 +141,11 @@ public class CequintPhoneLookup implements PhoneLookup<CequintInfo> { return Futures.immediateFuture(null); } + @Override + public String getLoggingName() { + return "CequintPhoneLookup"; + } + /** * Builds a {@link CequintInfo} proto based on the given {@link CequintCallerIdContact} returned * by {@link CequintCallerIdManager}. diff --git a/java/com/android/dialer/phonelookup/cnap/CnapPhoneLookup.java b/java/com/android/dialer/phonelookup/cnap/CnapPhoneLookup.java index db7c210fc..1b78a8e94 100644 --- a/java/com/android/dialer/phonelookup/cnap/CnapPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cnap/CnapPhoneLookup.java @@ -157,4 +157,9 @@ public final class CnapPhoneLookup implements PhoneLookup<CnapInfo> { public ListenableFuture<Void> clearData() { return Futures.immediateFuture(null); } + + @Override + public String getLoggingName() { + return "CnapPhoneLookup"; + } } diff --git a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java index 1ac13df33..83223295b 100644 --- a/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java +++ b/java/com/android/dialer/phonelookup/composite/CompositePhoneLookup.java @@ -89,13 +89,12 @@ public final class CompositePhoneLookup { for (PhoneLookup<?> phoneLookup : phoneLookups) { ListenableFuture<?> lookupFuture = phoneLookup.lookup(appContext, call); String eventName = - String.format(Metrics.LOOKUP_FOR_CALL_TEMPLATE, phoneLookup.getClass().getSimpleName()); + String.format(Metrics.LOOKUP_FOR_CALL_TEMPLATE, phoneLookup.getLoggingName()); futureTimer.applyTiming(lookupFuture, eventName); futures.add(lookupFuture); } ListenableFuture<PhoneLookupInfo> combinedFuture = combineSubMessageFutures(futures); - String eventName = - String.format(Metrics.LOOKUP_FOR_CALL_TEMPLATE, CompositePhoneLookup.class.getSimpleName()); + String eventName = String.format(Metrics.LOOKUP_FOR_CALL_TEMPLATE, getLoggingName()); futureTimer.applyTiming(combinedFuture, eventName); return combinedFuture; } @@ -114,14 +113,12 @@ public final class CompositePhoneLookup { for (PhoneLookup<?> phoneLookup : phoneLookups) { ListenableFuture<?> lookupFuture = phoneLookup.lookup(dialerPhoneNumber); String eventName = - String.format(Metrics.LOOKUP_FOR_NUMBER_TEMPLATE, phoneLookup.getClass().getSimpleName()); + String.format(Metrics.LOOKUP_FOR_NUMBER_TEMPLATE, phoneLookup.getLoggingName()); futureTimer.applyTiming(lookupFuture, eventName); futures.add(lookupFuture); } ListenableFuture<PhoneLookupInfo> combinedFuture = combineSubMessageFutures(futures); - String eventName = - String.format( - Metrics.LOOKUP_FOR_NUMBER_TEMPLATE, CompositePhoneLookup.class.getSimpleName()); + String eventName = String.format(Metrics.LOOKUP_FOR_NUMBER_TEMPLATE, getLoggingName()); futureTimer.applyTiming(combinedFuture, eventName); return combinedFuture; } @@ -133,6 +130,7 @@ public final class CompositePhoneLookup { return Futures.transform( Futures.allAsList(subMessageFutures), subMessages -> { + Preconditions.checkNotNull(subMessages); Builder mergedInfo = PhoneLookupInfo.newBuilder(); for (int i = 0; i < subMessages.size(); i++) { PhoneLookup phoneLookup = phoneLookups.get(i); @@ -152,16 +150,14 @@ public final class CompositePhoneLookup { for (PhoneLookup<?> phoneLookup : phoneLookups) { ListenableFuture<Boolean> isDirtyFuture = phoneLookup.isDirty(phoneNumbers); futures.add(isDirtyFuture); - String eventName = - String.format(Metrics.IS_DIRTY_TEMPLATE, phoneLookup.getClass().getSimpleName()); + String eventName = String.format(Metrics.IS_DIRTY_TEMPLATE, phoneLookup.getLoggingName()); futureTimer.applyTiming(isDirtyFuture, eventName, LogCatMode.LOG_VALUES); } // Executes all child lookups (possibly in parallel), completing when the first composite lookup // which returns "true" completes, and cancels the others. ListenableFuture<Boolean> firstMatching = DialerFutures.firstMatching(futures, Preconditions::checkNotNull, false /* defaultValue */); - String eventName = - String.format(Metrics.IS_DIRTY_TEMPLATE, CompositePhoneLookup.class.getSimpleName()); + String eventName = String.format(Metrics.IS_DIRTY_TEMPLATE, getLoggingName()); futureTimer.applyTiming(firstMatching, eventName, LogCatMode.LOG_VALUES); return firstMatching; } @@ -178,6 +174,7 @@ public final class CompositePhoneLookup { return Futures.transformAsync( callLogState.isBuilt(), isBuilt -> { + Preconditions.checkNotNull(isBuilt); List<ListenableFuture<ImmutableMap<DialerPhoneNumber, ?>>> futures = new ArrayList<>(); for (PhoneLookup phoneLookup : phoneLookups) { futures.add(buildSubmapAndGetMostRecentInfo(existingInfoMap, phoneLookup, isBuilt)); @@ -186,6 +183,7 @@ public final class CompositePhoneLookup { Futures.transform( Futures.allAsList(futures), (allMaps) -> { + Preconditions.checkNotNull(allMaps); ImmutableMap.Builder<DialerPhoneNumber, PhoneLookupInfo> combinedMap = ImmutableMap.builder(); for (DialerPhoneNumber dialerPhoneNumber : existingInfoMap.keySet()) { @@ -206,7 +204,7 @@ public final class CompositePhoneLookup { return combinedMap.build(); }, lightweightExecutorService); - String eventName = getMostRecentInfoEventName(this, isBuilt); + String eventName = getMostRecentInfoEventName(getLoggingName(), isBuilt); futureTimer.applyTiming(combinedFuture, eventName); return combinedFuture; }, @@ -224,7 +222,7 @@ public final class CompositePhoneLookup { phoneLookup.getSubMessage(existingInfoMap.get(dialerPhoneNumber))); ListenableFuture<ImmutableMap<DialerPhoneNumber, T>> mostRecentInfoFuture = phoneLookup.getMostRecentInfo(ImmutableMap.copyOf(submap)); - String eventName = getMostRecentInfoEventName(phoneLookup, isBuilt); + String eventName = getMostRecentInfoEventName(phoneLookup.getLoggingName(), isBuilt); futureTimer.applyTiming(mostRecentInfoFuture, eventName); return mostRecentInfoFuture; } @@ -234,17 +232,19 @@ public final class CompositePhoneLookup { return Futures.transformAsync( callLogState.isBuilt(), isBuilt -> { + Preconditions.checkNotNull(isBuilt); List<ListenableFuture<Void>> futures = new ArrayList<>(); for (PhoneLookup<?> phoneLookup : phoneLookups) { ListenableFuture<Void> phoneLookupFuture = phoneLookup.onSuccessfulBulkUpdate(); futures.add(phoneLookupFuture); - String eventName = onSuccessfulBulkUpdatedEventName(phoneLookup, isBuilt); + String eventName = + onSuccessfulBulkUpdatedEventName(phoneLookup.getLoggingName(), isBuilt); futureTimer.applyTiming(phoneLookupFuture, eventName); } ListenableFuture<Void> combinedFuture = Futures.transform( Futures.allAsList(futures), unused -> null, lightweightExecutorService); - String eventName = onSuccessfulBulkUpdatedEventName(this, isBuilt); + String eventName = onSuccessfulBulkUpdatedEventName(getLoggingName(), isBuilt); futureTimer.applyTiming(combinedFuture, eventName); return combinedFuture; }, @@ -278,19 +278,23 @@ public final class CompositePhoneLookup { Futures.allAsList(futures), unused -> null, lightweightExecutorService); } - private static String getMostRecentInfoEventName(Object classNameSource, boolean isBuilt) { + private static String getMostRecentInfoEventName(String loggingName, boolean isBuilt) { return String.format( !isBuilt ? Metrics.INITIAL_GET_MOST_RECENT_INFO_TEMPLATE : Metrics.GET_MOST_RECENT_INFO_TEMPLATE, - classNameSource.getClass().getSimpleName()); + loggingName); } - private static String onSuccessfulBulkUpdatedEventName(Object classNameSource, boolean isBuilt) { + private static String onSuccessfulBulkUpdatedEventName(String loggingName, boolean isBuilt) { return String.format( !isBuilt ? Metrics.INITIAL_ON_SUCCESSFUL_BULK_UPDATE_TEMPLATE : Metrics.ON_SUCCESSFUL_BULK_UPDATE_TEMPLATE, - classNameSource.getClass().getSimpleName()); + loggingName); + } + + private String getLoggingName() { + return "CompositePhoneLookup"; } } diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2DefaultDirectoryPhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2DefaultDirectoryPhoneLookup.java index c5d4e53f2..1642f9b23 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2DefaultDirectoryPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2DefaultDirectoryPhoneLookup.java @@ -644,6 +644,11 @@ public final class Cp2DefaultDirectoryPhoneLookup implements PhoneLookup<Cp2Info }); } + @Override + public String getLoggingName() { + return "Cp2DefaultDirectoryPhoneLookup"; + } + /** * 1. get all contact ids. if the id is unset, add the number to the list of contacts to look up. * 2. reduce our list of contact ids to those that were updated after lastModified. 3. Now we have diff --git a/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java b/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java index 2b98f265c..77a95e79f 100644 --- a/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/cp2/Cp2ExtendedDirectoryPhoneLookup.java @@ -234,4 +234,9 @@ public final class Cp2ExtendedDirectoryPhoneLookup implements PhoneLookup<Cp2Inf public ListenableFuture<Void> clearData() { return Futures.immediateFuture(null); } + + @Override + public String getLoggingName() { + return "Cp2ExtendedDirectoryPhoneLookup"; + } } diff --git a/java/com/android/dialer/phonelookup/emergency/EmergencyPhoneLookup.java b/java/com/android/dialer/phonelookup/emergency/EmergencyPhoneLookup.java index 3f675d35f..d31614a12 100644 --- a/java/com/android/dialer/phonelookup/emergency/EmergencyPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/emergency/EmergencyPhoneLookup.java @@ -114,4 +114,9 @@ public class EmergencyPhoneLookup implements PhoneLookup<EmergencyInfo> { public ListenableFuture<Void> clearData() { return Futures.immediateFuture(null); } + + @Override + public String getLoggingName() { + return "EmergencyPhoneLookup"; + } } diff --git a/java/com/android/dialer/phonelookup/spam/SpamPhoneLookup.java b/java/com/android/dialer/phonelookup/spam/SpamPhoneLookup.java index 71341ba64..7e5c9734d 100644 --- a/java/com/android/dialer/phonelookup/spam/SpamPhoneLookup.java +++ b/java/com/android/dialer/phonelookup/spam/SpamPhoneLookup.java @@ -167,4 +167,9 @@ public final class SpamPhoneLookup implements PhoneLookup<SpamInfo> { return null; }); } + + @Override + public String getLoggingName() { + return "SpamPhoneLookup"; + } } |