Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add separate metric for cluster manager service events and metrics #579

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading