From f2c148e003c39fe14c7b1fa1e4e78dfa2d1a2b7f Mon Sep 17 00:00:00 2001 From: Simeon Widdis Date: Thu, 14 Nov 2024 19:59:18 +0000 Subject: [PATCH] Apply PR feedback Signed-off-by: Simeon Widdis --- .../core/storage/FlintOpenSearchClient.java | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java b/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java index d1e49a64b..2bc097bba 100644 --- a/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java +++ b/flint-core/src/main/scala/org/opensearch/flint/core/storage/FlintOpenSearchClient.java @@ -132,31 +132,23 @@ private String sanitizeIndexName(String indexName) { } private void emitIndexCreationSuccessMetric(String indexKind) { - switch (indexKind) { - case "skipping": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_SKIPPING_INDICES, "success"), 1); - break; - case "covering": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_COVERING_INDICES, "success"), 1); - break; - case "mv": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_MV_INDICES, "success"), 1); - break; - default: - break; - } + emitIndexCreationMetric(indexKind, "success"); } private void emitIndexCreationFailureMetric(String indexKind) { + emitIndexCreationMetric(indexKind, "failed"); + } + + private void emitIndexCreationMetric(String indexKind, String status) { switch (indexKind) { case "skipping": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_SKIPPING_INDICES, "failed"), 1); + MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_SKIPPING_INDICES, status), 1); break; case "covering": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_COVERING_INDICES, "failed"), 1); + MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_COVERING_INDICES, status), 1); break; case "mv": - MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_MV_INDICES, "failed"), 1); + MetricsUtil.addHistoricGauge(String.format("%s.%s.count", MetricConstants.CREATE_MV_INDICES, status), 1); break; default: break;