Skip to content

Commit

Permalink
Update metric creation to happen only once per store
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sutton-Gee committed Dec 20, 2024
1 parent d4a02d3 commit 150ca55
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 150ca55

Please sign in to comment.