-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Harsh Garg <[email protected]>
- Loading branch information
Harsh Garg
committed
Mar 26, 2024
1 parent
63eba93
commit 48e38b0
Showing
15 changed files
with
308 additions
and
105 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
server/src/main/java/org/opensearch/cluster/coordination/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,52 @@ | ||
/* | ||
* 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.coordination; | ||
|
||
import org.opensearch.telemetry.metrics.Counter; | ||
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. | ||
*/ | ||
public final class ClusterManagerMetrics { | ||
|
||
private static final String COUNTER_METRICS_UNIT = "1"; | ||
|
||
public final Counter leaderCheckFailureCounter; | ||
public final Counter followerChecksFailureCounter; | ||
|
||
public ClusterManagerMetrics(MetricsRegistry metricsRegistry) { | ||
this.followerChecksFailureCounter = metricsRegistry.createCounter( | ||
"followers.checker.failure.count", | ||
"Counter for number of failed follower checks", | ||
COUNTER_METRICS_UNIT | ||
); | ||
this.leaderCheckFailureCounter = metricsRegistry.createCounter( | ||
"leader.checker.failure.count", | ||
"Counter for number of failed leader checks", | ||
COUNTER_METRICS_UNIT | ||
); | ||
} | ||
|
||
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.