Skip to content

Commit

Permalink
Add separate metric for cluster manager service events and metrics (#579
Browse files Browse the repository at this point in the history
) (#594)

Signed-off-by: Khushboo Rajput <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] authored Nov 14, 2023
1 parent d907f19 commit ab18594
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

package org.opensearch.performanceanalyzer.collectors;

import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode.CLUSTER_MANAGER_METRICS_ERROR;
import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode.CLUSTER_MANAGER_NODE_NOT_UP;
import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode.CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_ERROR;
import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatMetrics.CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_EXECUTION_TIME;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -51,7 +51,7 @@ public ClusterManagerServiceEventMetrics() {
SAMPLING_TIME_INTERVAL,
"ClusterManagerServiceEventMetrics",
CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_EXECUTION_TIME,
CLUSTER_MANAGER_METRICS_ERROR);
CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_ERROR);
clusterManagerServiceCurrentQueue = null;
clusterManagerServiceWorkers = null;
prioritizedOpenSearchThreadPoolExecutor = null;
Expand Down Expand Up @@ -163,7 +163,8 @@ public void collectMetrics(long startTime) {
"[ {} ] Exception raised while getting Cluster Manager throttling metrics: {} ",
this::getCollectorName,
e::getMessage);
StatsCollector.instance().logException(CLUSTER_MANAGER_METRICS_ERROR);
StatsCollector.instance()
.logException(CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

package org.opensearch.performanceanalyzer.collectors;

import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode.CLUSTER_MANAGER_METRICS_ERROR;
import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatExceptionCode.CLUSTER_MANAGER_SERVICE_METRICS_COLLECTOR_ERROR;
import static org.opensearch.performanceanalyzer.commons.stats.metrics.StatMetrics.CLUSTER_MANAGER_SERVICE_METRICS_COLLECTOR_EXECUTION_TIME;

import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down Expand Up @@ -39,7 +39,7 @@ public ClusterManagerServiceMetrics() {
SAMPLING_TIME_INTERVAL,
"ClusterManagerServiceMetrics",
CLUSTER_MANAGER_SERVICE_METRICS_COLLECTOR_EXECUTION_TIME,
CLUSTER_MANAGER_METRICS_ERROR);
CLUSTER_MANAGER_SERVICE_METRICS_COLLECTOR_ERROR);
value = new StringBuilder();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public void run() {

static Random RANDOM = new Random();
private static final int MAX_COUNT = 500;
private static final int CLUSTER_MANAGER_METRICS_ERRORS =
private static final int CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_ERROR =
Math.abs(RANDOM.nextInt() % MAX_COUNT);
private static final int REQUEST_REMOTE_ERRORS = Math.abs(RANDOM.nextInt() % MAX_COUNT);
private static final int READER_PARSER_ERRORS = Math.abs(RANDOM.nextInt() % MAX_COUNT);
private static final int READER_RESTART_PROCESSINGS = Math.abs(RANDOM.nextInt() % MAX_COUNT);
private static final int TOTAL_ERRORS =
CLUSTER_MANAGER_METRICS_ERRORS
CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_ERROR
+ REQUEST_REMOTE_ERRORS
+ READER_PARSER_ERRORS
+ READER_RESTART_PROCESSINGS;
Expand All @@ -63,8 +63,9 @@ public void testStats() throws Exception {

LinkedList<StatExceptionCode> exceptionCodeList = new LinkedList<>();

for (int i = 0; i < CLUSTER_MANAGER_METRICS_ERRORS; i++) {
exceptionCodeList.add(StatExceptionCode.CLUSTER_MANAGER_METRICS_ERROR);
for (int i = 0; i < CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_ERROR; i++) {
exceptionCodeList.add(
StatExceptionCode.CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_ERROR);
}

for (int i = 0; i < REQUEST_REMOTE_ERRORS; i++) {
Expand Down Expand Up @@ -101,10 +102,12 @@ private static void assertExpected(StatsCollector sc) {
assertEquals(
sc.getCounters()
.getOrDefault(
StatExceptionCode.CLUSTER_MANAGER_METRICS_ERROR.toString(),
StatExceptionCode
.CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_COLLECTOR_ERROR
.toString(),
DEFAULT_VAL)
.get(),
CLUSTER_MANAGER_METRICS_ERRORS);
CLUSTER_MANAGER_SERVICE_EVENTS_METRICS_ERROR);
assertEquals(
sc.getCounters()
.getOrDefault(
Expand Down

0 comments on commit ab18594

Please sign in to comment.