From 585036c9b0553c8a96653d9255c1e2dbd4bd93a3 Mon Sep 17 00:00:00 2001 From: Sourav Maji Date: Wed, 25 Oct 2023 19:22:14 -0700 Subject: [PATCH] [venice-thin-client][da-vinci-client] Do not emit system store client metrics (#708) The venice_system stores are internal to venice architecture and clients should not be looking into them. Also for DaVinci client each store per instance emits around 400 metrics, and 120 of them are for system-stores. This PR stops emission of system store client metrics which would reduce ~1/3 metrics in clients --------- Co-authored-by: Sourav Maji --- .../venice/stats/AbstractVeniceHttpStats.java | 5 +++- .../venice/stats/AbstractVeniceStatsTest.java | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/internal/venice-client-common/src/main/java/com/linkedin/venice/stats/AbstractVeniceHttpStats.java b/internal/venice-client-common/src/main/java/com/linkedin/venice/stats/AbstractVeniceHttpStats.java index 9e09ffb4e1..0d709bc7ef 100644 --- a/internal/venice-client-common/src/main/java/com/linkedin/venice/stats/AbstractVeniceHttpStats.java +++ b/internal/venice-client-common/src/main/java/com/linkedin/venice/stats/AbstractVeniceHttpStats.java @@ -7,10 +7,13 @@ public abstract class AbstractVeniceHttpStats extends AbstractVeniceStats { + private static final String SYSTEM_STORE_NAME_PREFIX = "venice_system_store_"; + private static final MetricsRepository dummySystemStoreMetricRepo = new MetricsRepository(); + private final RequestType requestType; public AbstractVeniceHttpStats(MetricsRepository metricsRepository, String storeName, RequestType requestType) { - super(metricsRepository, storeName); + super(storeName.startsWith(SYSTEM_STORE_NAME_PREFIX) ? dummySystemStoreMetricRepo : metricsRepository, storeName); this.requestType = requestType; } diff --git a/internal/venice-client-common/src/test/java/com/linkedin/venice/stats/AbstractVeniceStatsTest.java b/internal/venice-client-common/src/test/java/com/linkedin/venice/stats/AbstractVeniceStatsTest.java index 189b76ba4e..c687762e92 100644 --- a/internal/venice-client-common/src/test/java/com/linkedin/venice/stats/AbstractVeniceStatsTest.java +++ b/internal/venice-client-common/src/test/java/com/linkedin/venice/stats/AbstractVeniceStatsTest.java @@ -1,5 +1,11 @@ package com.linkedin.venice.stats; +import static org.testng.AssertJUnit.assertTrue; + +import com.linkedin.venice.client.stats.BasicClientStats; +import com.linkedin.venice.client.stats.ClientStats; +import com.linkedin.venice.client.store.ClientConfig; +import com.linkedin.venice.read.RequestType; import io.tehuti.Metric; import io.tehuti.metrics.MeasurableStat; import io.tehuti.metrics.MetricConfig; @@ -83,4 +89,22 @@ public void testRegisterSensorAttributeGauge() { Assert.assertEquals(metricsRepository.getMetric(".myMetric--foo.bar").value(), 1.0); Assert.assertEquals(metricsRepository.getMetric(".myMetric--foo.bar2").value(), 2.0); } + + @Test + public void testMetricPrefix() { + String storeName = "test_store"; + MetricsRepository metricsRepository1 = new MetricsRepository(); + // Without prefix + ClientConfig config1 = new ClientConfig(storeName); + BasicClientStats.getClientStats(metricsRepository1, storeName, RequestType.SINGLE_GET, config1); + // Check metric name + assertTrue(metricsRepository1.metrics().size() > 0); + + String prefix = "venice_system_store_meta_store_abc"; + ClientConfig config2 = new ClientConfig(storeName).setStatsPrefix(prefix); + ClientStats clientStats = + ClientStats.getClientStats(new MetricsRepository(), storeName, RequestType.SINGLE_GET, config2); + clientStats.recordRequestRetryCount(); + } + }