@@ -129,6 +129,16 @@ public class DiscoveryClient implements EurekaClient {
129129 private final Timer FETCH_REGISTRY_TIMER = SpectatorUtil .timer (PREFIX + "FetchRegistry" , DiscoveryClient .class );
130130 private final Counter REREGISTER_COUNTER = SpectatorUtil .counter (PREFIX + "Reregister" , DiscoveryClient .class );
131131
132+ // Lookup counters
133+ private final Counter LOOKUP_GET_APPLICATION = SpectatorUtil .counter (PREFIX + "Lookup" , "getApplication" , DiscoveryClient .class );
134+ private final Counter LOOKUP_GET_APPLICATIONS = SpectatorUtil .counter (PREFIX + "Lookup" , "getApplications" , DiscoveryClient .class );
135+ private final Counter LOOKUP_GET_APPLICATIONS_FOR_A_REGION = SpectatorUtil .counter (PREFIX + "Lookup" , "getApplicationsForARegion" , DiscoveryClient .class );
136+ private final Counter LOOKUP_GET_INSTANCES_BY_ID = SpectatorUtil .counter (PREFIX + "Lookup" , "getInstancesById" , DiscoveryClient .class );
137+ private final Counter LOOKUP_GET_INSTANCES_BY_VIP = SpectatorUtil .counter (PREFIX + "Lookup" , "getInstancesByVipAddress" , DiscoveryClient .class );
138+ private final Counter LOOKUP_GET_INSTANCES_BY_VIP_AND_APP = SpectatorUtil .counter (PREFIX + "Lookup" , "getInstancesByVipAddressAndAppName" , DiscoveryClient .class );
139+ private final Counter LOOKUP_GET_NEXT_SERVER = SpectatorUtil .counter (PREFIX + "Lookup" , "getNextServerFromEureka" , DiscoveryClient .class );
140+ private final Counter LOOKUP_GET_APPLICATIONS_SERVICE_URL = SpectatorUtil .counter (PREFIX + "Lookup" , "getApplicationsServiceUrl" , DiscoveryClient .class );
141+
132142 // instance variables
133143 /**
134144 * A scheduler to be used for the following 3 tasks:
@@ -459,7 +469,7 @@ public Thread newThread(Runnable r) {
459469 private void scheduleServerEndpointTask (EurekaTransport eurekaTransport ,
460470 AbstractDiscoveryClientOptionalArgs args ) {
461471
462-
472+
463473 Collection <?> additionalFilters = args == null
464474 ? Collections .emptyList ()
465475 : args .additionalFilters ;
@@ -560,6 +570,7 @@ public ApplicationInfoManager getApplicationInfoManager() {
560570 */
561571 @ Override
562572 public Application getApplication (String appName ) {
573+ LOOKUP_GET_APPLICATION .increment ();
563574 return getApplications ().getRegisteredApplications (appName );
564575 }
565576
@@ -570,11 +581,13 @@ public Application getApplication(String appName) {
570581 */
571582 @ Override
572583 public Applications getApplications () {
584+ LOOKUP_GET_APPLICATIONS .increment ();
573585 return localRegionApps .get ();
574586 }
575587
576588 @ Override
577589 public Applications getApplicationsForARegion (@ Nullable String region ) {
590+ LOOKUP_GET_APPLICATIONS_FOR_A_REGION .increment ();
578591 if (instanceRegionChecker .isLocalRegion (region )) {
579592 return localRegionApps .get ();
580593 } else {
@@ -600,6 +613,7 @@ public Set<String> getAllKnownRegions() {
600613 */
601614 @ Override
602615 public List <InstanceInfo > getInstancesById (String id ) {
616+ LOOKUP_GET_INSTANCES_BY_ID .increment ();
603617 List <InstanceInfo > instancesList = new ArrayList <>();
604618 for (Application app : this .getApplications ()
605619 .getRegisteredApplications ()) {
@@ -684,6 +698,7 @@ public List<InstanceInfo> getInstancesByVipAddress(String vipAddress, boolean se
684698 @ Override
685699 public List <InstanceInfo > getInstancesByVipAddress (String vipAddress , boolean secure ,
686700 @ Nullable String region ) {
701+ LOOKUP_GET_INSTANCES_BY_VIP .increment ();
687702 if (vipAddress == null ) {
688703 throw new IllegalArgumentException (
689704 "Supplied VIP Address cannot be null" );
@@ -704,9 +719,7 @@ public List<InstanceInfo> getInstancesByVipAddress(String vipAddress, boolean se
704719 return applications .getInstancesByVirtualHostName (vipAddress );
705720 } else {
706721 return applications .getInstancesBySecureVirtualHostName (vipAddress );
707-
708722 }
709-
710723 }
711724
712725 /**
@@ -725,6 +738,7 @@ public List<InstanceInfo> getInstancesByVipAddress(String vipAddress, boolean se
725738 @ Override
726739 public List <InstanceInfo > getInstancesByVipAddressAndAppName (
727740 String vipAddress , String appName , boolean secure ) {
741+ LOOKUP_GET_INSTANCES_BY_VIP_AND_APP .increment ();
728742
729743 List <InstanceInfo > result = new ArrayList <>();
730744 if (vipAddress == null && appName == null ) {
@@ -779,6 +793,7 @@ public List<InstanceInfo> getInstancesByVipAddressAndAppName(
779793 */
780794 @ Override
781795 public InstanceInfo getNextServerFromEureka (String virtualHostname , boolean secure ) {
796+ LOOKUP_GET_NEXT_SERVER .increment ();
782797 List <InstanceInfo > instanceInfoList = this .getInstancesByVipAddress (
783798 virtualHostname , secure );
784799 if (instanceInfoList == null || instanceInfoList .isEmpty ()) {
@@ -800,6 +815,7 @@ public InstanceInfo getNextServerFromEureka(String virtualHostname, boolean secu
800815 */
801816 @ Override
802817 public Applications getApplications (String serviceUrl ) {
818+ LOOKUP_GET_APPLICATIONS_SERVICE_URL .increment ();
803819 try {
804820 EurekaHttpResponse <Applications > response = clientConfig .getRegistryRefreshSingleVipAddress () == null
805821 ? eurekaTransport .queryClient .getApplications ()
0 commit comments