From 5775a0aac3ad109f12762a774a4fe83f496acd2f Mon Sep 17 00:00:00 2001 From: Louis Chu Date: Mon, 29 Jan 2024 14:36:23 -0800 Subject: [PATCH] Address comment from Peng Signed-off-by: Louis Chu --- .../opensearch/flint/core/RestHighLevelClientWrapper.java | 2 +- .../org/opensearch/flint/core/metrics/MetricsUtil.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flint-core/src/main/java/org/opensearch/flint/core/RestHighLevelClientWrapper.java b/flint-core/src/main/java/org/opensearch/flint/core/RestHighLevelClientWrapper.java index 1ab72ad98..3556c7e24 100644 --- a/flint-core/src/main/java/org/opensearch/flint/core/RestHighLevelClientWrapper.java +++ b/flint-core/src/main/java/org/opensearch/flint/core/RestHighLevelClientWrapper.java @@ -138,7 +138,7 @@ private T execute(String metricNamePrefix, IOCallable operation) throws I * @param metricNamePrefix the prefix for the metric name which is used to construct the full metric name for success */ private void recordOperationSuccess(String metricNamePrefix) { - String successMetricName = metricNamePrefix + ".200.count"; + String successMetricName = metricNamePrefix + ".2xx.count"; MetricsUtil.incrementCounter(successMetricName); } diff --git a/flint-core/src/main/java/org/opensearch/flint/core/metrics/MetricsUtil.java b/flint-core/src/main/java/org/opensearch/flint/core/metrics/MetricsUtil.java index 11b5327eb..0edce3e36 100644 --- a/flint-core/src/main/java/org/opensearch/flint/core/metrics/MetricsUtil.java +++ b/flint-core/src/main/java/org/opensearch/flint/core/metrics/MetricsUtil.java @@ -24,6 +24,13 @@ public final class MetricsUtil { private MetricsUtil() { } + /** + * Increments the Counter metric associated with the given metric name. + * If the counter does not exist, it is created before being incremented. + * + * @param metricName The name of the metric for which the counter is incremented. + * This name is used to retrieve or create the counter. + */ public static void incrementCounter(String metricName) { Counter counter = getOrCreateCounter(metricName); if (counter != null) {