-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds counter metrics for leader and follower check failures (#12439)
* Adds counter metrics for leader and follower check failures Signed-off-by: Harsh Garg <gkharsh@amazon.com>
- Loading branch information
1 parent
9d11dbb
commit 6d78faa
Showing
16 changed files
with
404 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
server/src/main/java/org/opensearch/cluster/ClusterManagerMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cluster; | ||
|
||
import org.opensearch.telemetry.metrics.Counter; | ||
import org.opensearch.telemetry.metrics.Histogram; | ||
import org.opensearch.telemetry.metrics.MetricsRegistry; | ||
import org.opensearch.telemetry.metrics.tags.Tags; | ||
|
||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Class containing metrics (counters/latency) specific to ClusterManager. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public final class ClusterManagerMetrics { | ||
|
||
private static final String LATENCY_METRIC_UNIT_MS = "ms"; | ||
private static final String COUNTER_METRICS_UNIT = "1"; | ||
|
||
public final Histogram clusterStateAppliersHistogram; | ||
public final Histogram clusterStateListenersHistogram; | ||
public final Histogram rerouteHistogram; | ||
public final Histogram clusterStateComputeHistogram; | ||
public final Histogram clusterStatePublishHistogram; | ||
|
||
public final Counter leaderCheckFailureCounter; | ||
public final Counter followerChecksFailureCounter; | ||
|
||
public ClusterManagerMetrics(MetricsRegistry metricsRegistry) { | ||
clusterStateAppliersHistogram = metricsRegistry.createHistogram( | ||
"cluster.state.appliers.latency", | ||
"Histogram for tracking the latency of cluster state appliers", | ||
LATENCY_METRIC_UNIT_MS | ||
); | ||
clusterStateListenersHistogram = metricsRegistry.createHistogram( | ||
"cluster.state.listeners.latency", | ||
"Histogram for tracking the latency of cluster state listeners", | ||
LATENCY_METRIC_UNIT_MS | ||
); | ||
rerouteHistogram = metricsRegistry.createHistogram( | ||
"allocation.reroute.latency", | ||
"Histogram for recording latency of shard re-routing", | ||
LATENCY_METRIC_UNIT_MS | ||
); | ||
clusterStateComputeHistogram = metricsRegistry.createHistogram( | ||
"cluster.state.new.compute.latency", | ||
"Histogram for recording time taken to compute new cluster state", | ||
LATENCY_METRIC_UNIT_MS | ||
); | ||
clusterStatePublishHistogram = metricsRegistry.createHistogram( | ||
"cluster.state.publish.success.latency", | ||
"Histogram for recording time taken to publish a new cluster state", | ||
LATENCY_METRIC_UNIT_MS | ||
); | ||
followerChecksFailureCounter = metricsRegistry.createCounter( | ||
"followers.checker.failure.count", | ||
"Counter for number of failed follower checks", | ||
COUNTER_METRICS_UNIT | ||
); | ||
leaderCheckFailureCounter = metricsRegistry.createCounter( | ||
"leader.checker.failure.count", | ||
"Counter for number of failed leader checks", | ||
COUNTER_METRICS_UNIT | ||
); | ||
} | ||
|
||
public void recordLatency(Histogram histogram, Double value) { | ||
histogram.record(value); | ||
} | ||
|
||
public void recordLatency(Histogram histogram, Double value, Optional<Tags> tags) { | ||
if (Objects.isNull(tags) || tags.isEmpty()) { | ||
histogram.record(value); | ||
return; | ||
} | ||
histogram.record(value, tags.get()); | ||
} | ||
|
||
public void incrementCounter(Counter counter, Double value) { | ||
incrementCounter(counter, value, Optional.empty()); | ||
} | ||
|
||
public void incrementCounter(Counter counter, Double value, Optional<Tags> tags) { | ||
if (Objects.isNull(tags) || tags.isEmpty()) { | ||
counter.add(value); | ||
return; | ||
} | ||
counter.add(value, tags.get()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.