-
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 latency metrics for ClusterState Appliers and Listeners (#12333)
* Adds latency metrics for ClusterState Appliers and Listeners Signed-off-by: Harsh Garg <gkharsh@amazon.com> (cherry picked from commit a254aa9) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
cf20a61
commit 6d23c1d
Showing
48 changed files
with
495 additions
and
101 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
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
72 changes: 72 additions & 0 deletions
72
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,72 @@ | ||
/* | ||
* 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.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"; | ||
|
||
public final Histogram clusterStateAppliersHistogram; | ||
public final Histogram clusterStateListenersHistogram; | ||
public final Histogram rerouteHistogram; | ||
public final Histogram clusterStateComputeHistogram; | ||
public final Histogram clusterStatePublishHistogram; | ||
|
||
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 | ||
); | ||
} | ||
|
||
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()); | ||
} | ||
} |
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.