From 39d1271add1a2eee1af0c4338f8ad436c4308b57 Mon Sep 17 00:00:00 2001 From: gjoranv Date: Wed, 21 Jun 2023 17:43:15 +0200 Subject: Replace metrics strings with the corresponding enum constants. - Add 'metrics' as provided dep for clustercontroller-core --- .../src/main/java/com/yahoo/search/handler/SearchHandler.java | 3 ++- .../main/java/com/yahoo/search/searchers/ContainerLatencySearcher.java | 3 ++- .../src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java | 3 ++- .../java/com/yahoo/search/searchers/test/RateLimitingBenchmark.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'container-search') diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index c9e125ab55f..ecce5ddd740 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.handler; +import ai.vespa.metrics.ContainerMetrics; import ai.vespa.cloud.ZoneInfo; import ai.vespa.metrics.ContainerMetrics; import com.yahoo.collections.Tuple2; @@ -81,7 +82,7 @@ public class SearchHandler extends LoggingRequestHandler { private static final CompoundName FORCE_TIMESTAMPS = CompoundName.from("trace.timestamps"); /** Event name for number of connections to the search subsystem */ - private static final String SEARCH_CONNECTIONS = "search_connections"; + private static final String SEARCH_CONNECTIONS = ContainerMetrics.SEARCH_CONNECTIONS.baseName(); static final String RENDER_LATENCY_METRIC = ContainerMetrics.JDISC_RENDER_LATENCY.baseName(); static final String MIME_DIMENSION = "mime"; static final String RENDERER_DIMENSION = "renderer"; diff --git a/container-search/src/main/java/com/yahoo/search/searchers/ContainerLatencySearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/ContainerLatencySearcher.java index 742f4b0f889..f510d68d32e 100644 --- a/container-search/src/main/java/com/yahoo/search/searchers/ContainerLatencySearcher.java +++ b/container-search/src/main/java/com/yahoo/search/searchers/ContainerLatencySearcher.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchers; +import ai.vespa.metrics.ContainerMetrics; import com.yahoo.component.chain.dependencies.After; import com.yahoo.metrics.simple.Gauge; import com.yahoo.metrics.simple.Point; @@ -21,7 +22,7 @@ public class ContainerLatencySearcher extends Searcher { private final Gauge latencyGauge; public ContainerLatencySearcher(MetricReceiver metrics) { - latencyGauge = metrics.declareGauge("query_container_latency"); + latencyGauge = metrics.declareGauge(ContainerMetrics.QUERY_CONTAINER_LATENCY.baseName()); } @Override diff --git a/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java index 35a3c86f763..846b8881cef 100755 --- a/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/searchers/RateLimitingSearcher.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchers; +import ai.vespa.metrics.ContainerMetrics; import com.yahoo.component.annotation.Inject; import com.yahoo.cloud.config.ClusterInfoConfig; @@ -60,7 +61,7 @@ public class RateLimitingSearcher extends Searcher { public static final CompoundName idDimensionKey = CompoundName.from("rate.idDimension"); public static final CompoundName dryRunKey = CompoundName.from("rate.dryRun"); - private static final String requestsOverQuotaMetricName = "requestsOverQuota"; + private static final String requestsOverQuotaMetricName = ContainerMetrics.REQUESTS_OVER_QUOTA.baseName(); /** Used to divide quota by nodes. Assumption: All nodes get the same share of traffic. */ private final int nodeCount; diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingBenchmark.java b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingBenchmark.java index 5537528d36b..76da6407166 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingBenchmark.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/test/RateLimitingBenchmark.java @@ -1,6 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchers.test; +import ai.vespa.metrics.ContainerMetrics; import com.yahoo.cloud.config.ClusterInfoConfig; import com.yahoo.component.chain.Chain; import com.yahoo.metrics.simple.Bucket; @@ -114,7 +115,7 @@ public class RateLimitingBenchmark { private int rejectedRequests(int id) { Point context = metric.pointBuilder().set("id", toClientId(id)).build(); - UntypedMetric rejectedRequestsMetric = metricSnapshot.getMapForMetric("requestsOverQuota").get(context); + UntypedMetric rejectedRequestsMetric = metricSnapshot.getMapForMetric(ContainerMetrics.REQUESTS_OVER_QUOTA.baseName()).get(context); if (rejectedRequestsMetric == null) return 0; return (int)rejectedRequestsMetric.getCount(); } -- cgit v1.2.3