diff --git a/services/venice-router/src/main/java/com/linkedin/venice/router/MetaDataHandler.java b/services/venice-router/src/main/java/com/linkedin/venice/router/MetaDataHandler.java index 975c4f25de..576ab385f6 100644 --- a/services/venice-router/src/main/java/com/linkedin/venice/router/MetaDataHandler.java +++ b/services/venice-router/src/main/java/com/linkedin/venice/router/MetaDataHandler.java @@ -484,9 +484,12 @@ private void handleD2ServiceLookup(ChannelHandlerContext ctx, VenicePathParserHe } // Only create metrics for valid stores - String d2DiscoveryMetricName = "venice.router.d2_discovery." + storeName; - Sensor d2DiscoverySensor = metricsRepository.sensor(d2DiscoveryMetricName); - d2DiscoverySensor.add(d2DiscoveryMetricName + ".request.count", new Count()); + Sensor d2DiscoverySensor = metricsRepository.sensor("venice.router.d2_discovery." + storeName); + String d2DiscoveryRequestCountMetric = "venice.router.d2_discovery." + storeName + ".request.count"; + // Check if metric already exists before adding + if (!metricsRepository.metrics().containsKey(d2DiscoveryRequestCountMetric)) { + d2DiscoverySensor.add(d2DiscoveryRequestCountMetric, new Count()); + } d2DiscoverySensor.record(); String clusterName = config.get().getCluster();