Skip to content

Commit

Permalink
RATIS-1885. Incorrect clientWriteRequest timer usage (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
jojochuang authored Sep 9, 2023
1 parent 9a12804 commit c013bb5
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,7 @@ public CompletableFuture<RaftClientReply> submitClientRequestAsync(
assertLifeCycleState(LifeCycle.States.RUNNING);
LOG.debug("{}: receive client request({})", getMemberId(), request);
final Optional<Timer> timer = Optional.ofNullable(raftServerMetrics.getClientRequestTimer(request.getType()));
final Optional<Timer.Context> timerContext = timer.map(Timer::time);

final CompletableFuture<RaftClientReply> replyFuture;

Expand Down Expand Up @@ -897,7 +898,7 @@ public CompletableFuture<RaftClientReply> submitClientRequestAsync(

final RaftClientRequest.Type type = request.getType();
replyFuture.whenComplete((clientReply, exception) -> {
timer.map(Timer::time).ifPresent(Timer.Context::stop);
timerContext.ifPresent(Timer.Context::stop);
if (exception != null || clientReply.getException() != null) {
raftServerMetrics.incFailedRequestCount(type);
}
Expand Down

0 comments on commit c013bb5

Please sign in to comment.