Skip to content

Commit

Permalink
use success metric instead of total metric
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Karajgikar <[email protected]>
  • Loading branch information
Rahul Karajgikar committed Sep 23, 2024
1 parent 065ba11 commit 48e9fa2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class ClusterManagerMetrics {
public final Counter leaderCheckFailureCounter;
public final Counter followerChecksFailureCounter;
public final Counter asyncFetchFailureCounter;
public final Counter asyncFetchTotalCounter;
public final Counter asyncFetchSuccessCounter;

public ClusterManagerMetrics(MetricsRegistry metricsRegistry) {
clusterStateAppliersHistogram = metricsRegistry.createHistogram(
Expand Down Expand Up @@ -78,8 +78,8 @@ public ClusterManagerMetrics(MetricsRegistry metricsRegistry) {
"Counter for number of failed async fetches",
COUNTER_METRICS_UNIT
);
asyncFetchTotalCounter = metricsRegistry.createCounter(
"async.fetch.total.count",
asyncFetchSuccessCounter = metricsRegistry.createCounter(
"async.fetch.success.count",
"Counter for total number of async fetches",
COUNTER_METRICS_UNIT
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ Map<DiscoveryNode, K> getCacheData(DiscoveryNodes nodes, Set<String> failedNodes
void processResponses(List<K> responses, long fetchingRound) {
for (K response : responses) {
BaseNodeEntry nodeEntry = getCache().get(response.getNode().getId());
clusterManagerMetrics.incrementCounter(clusterManagerMetrics.asyncFetchTotalCounter, 1.0);
clusterManagerMetrics.incrementCounter(clusterManagerMetrics.asyncFetchSuccessCounter, 1.0);
if (nodeEntry != null) {
if (validateNodeResponse(nodeEntry, fetchingRound)) {
// if the entry is there, for the right fetching round and not marked as failed already, process it
Expand Down Expand Up @@ -197,8 +197,6 @@ private boolean validateNodeResponse(BaseNodeEntry nodeEntry, long fetchingRound
}

private void handleNodeFailure(BaseNodeEntry nodeEntry, FailedNodeException failure, long fetchingRound) {
clusterManagerMetrics.incrementCounter(clusterManagerMetrics.asyncFetchTotalCounter, 1.0);
clusterManagerMetrics.incrementCounter(clusterManagerMetrics.asyncFetchFailureCounter, 1.0);
if (nodeEntry.getFetchingRound() != fetchingRound) {
assert nodeEntry.getFetchingRound() > fetchingRound : "node entries only replaced by newer rounds";
logger.trace(
Expand Down Expand Up @@ -230,6 +228,7 @@ boolean retryableException(Throwable unwrappedCause) {
void processFailures(List<FailedNodeException> failures, long fetchingRound) {
for (FailedNodeException failure : failures) {
logger.trace("processing failure {} for [{}]", failure, type);
clusterManagerMetrics.incrementCounter(clusterManagerMetrics.asyncFetchFailureCounter, 1.0);
BaseNodeEntry nodeEntry = getCache().get(failure.nodeId());
if (nodeEntry != null) {
handleNodeFailure(nodeEntry, failure, fetchingRound);
Expand Down
Loading

0 comments on commit 48e9fa2

Please sign in to comment.