Skip to content

Commit

Permalink
Adding opensearch.internal annotation and marking methods non-static
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Garg <[email protected]>
  • Loading branch information
Harsh Garg committed May 16, 2024
1 parent 3f8acdd commit f2c4b85
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

/**
* Class containing metrics (counters/latency) specific to ClusterManager.
*
* @opensearch.internal
*/
public final class ClusterManagerMetrics {

Expand Down Expand Up @@ -56,11 +58,11 @@ public ClusterManagerMetrics(MetricsRegistry metricsRegistry) {
);
}

public static void recordLatency(Histogram histogram, Double value) {
public void recordLatency(Histogram histogram, Double value) {
histogram.record(value);
}

public static void recordLatency(Histogram histogram, Double value, Optional<Tags> tags) {
public void recordLatency(Histogram histogram, Double value, Optional<Tags> tags) {
if (Objects.isNull(tags) || tags.isEmpty()) {
histogram.record(value);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ private void reroute(RoutingAllocation allocation) {

allocateExistingUnassignedShards(allocation); // try to allocate existing shard copies first
shardsAllocator.allocate(allocation);
ClusterManagerMetrics.recordLatency(
clusterManagerMetrics.recordLatency(
clusterManagerMetrics.rerouteHistogram,
(double) Math.max(0, TimeValue.nsecToMSec(System.nanoTime() - rerouteStartTimeNS))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ private void callClusterStateAppliers(
try (TimingHandle ignored = stopWatch.timing("running applier [" + applier + "]")) {
long applierStartTimeNS = System.nanoTime();
applier.applyClusterState(clusterChangedEvent);
ClusterManagerMetrics.recordLatency(
clusterManagerMetrics.recordLatency(
clusterManagerMetrics.clusterStateAppliersHistogram,
(double) Math.max(0, TimeValue.nsecToMSec(System.nanoTime() - applierStartTimeNS)),
Optional.of(Tags.create().addTag("Operation", applier.getClass().getSimpleName()))
Expand All @@ -643,7 +643,7 @@ private void callClusterStateListener(
try (TimingHandle ignored = stopWatch.timing("notifying listener [" + listener + "]")) {
long listenerStartTimeNS = System.nanoTime();
listener.clusterChanged(clusterChangedEvent);
ClusterManagerMetrics.recordLatency(
clusterManagerMetrics.recordLatency(
clusterManagerMetrics.clusterStateListenersHistogram,
(double) Math.max(0, TimeValue.nsecToMSec(System.nanoTime() - listenerStartTimeNS)),
Optional.of(Tags.create().addTag("Operation", listener.getClass().getSimpleName()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void runTasks(TaskInputs taskInputs) {
final TimeValue computationTime = getTimeSince(computationStartTime);
logExecutionTime(computationTime, "compute cluster state update", summary);

ClusterManagerMetrics.recordLatency(
clusterManagerMetrics.recordLatency(
clusterManagerMetrics.clusterStateComputeHistogram,
(double) computationTime.getMillis(),
Optional.of(Tags.create().addTag("Operation", taskInputs.executor.getClass().getSimpleName()))
Expand Down Expand Up @@ -377,7 +377,7 @@ protected boolean blockingAllowed() {
final long durationMillis = getTimeSince(startTimeNanos).millis();
stateStats.stateUpdateTook(durationMillis);
stateStats.stateUpdated();
ClusterManagerMetrics.recordLatency(clusterManagerMetrics.clusterStatePublishHistogram, (double) durationMillis);
clusterManagerMetrics.recordLatency(clusterManagerMetrics.clusterStatePublishHistogram, (double) durationMillis);
} catch (Exception e) {
stateStats.stateUpdateFailed();
onPublicationFailed(clusterChangedEvent, taskOutputs, startTimeNanos, e);
Expand Down

0 comments on commit f2c4b85

Please sign in to comment.