Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public class CSMMetrics {
private @Metric MutableCounterLong numStartTransactionVerifyFailures;
private @Metric MutableCounterLong numContainerNotOpenVerifyFailures;

private @Metric MutableRate applyTransactionLatency;

public CSMMetrics() {
int numCmdTypes = ContainerProtos.Type.values().length;
this.opsLatency = new MutableRate[numCmdTypes];
Expand Down Expand Up @@ -181,6 +183,11 @@ public long getNumBytesCommittedCount() {
return numBytesCommittedCount.value();
}

@VisibleForTesting
public MutableRate getApplyTransactionLatency() {
return applyTransactionLatency;
}

public void incPipelineLatency(ContainerProtos.Type type, long latencyNanos) {
opsLatency[type.ordinal()].add(latencyNanos);
transactionLatency.add(latencyNanos);
Expand All @@ -194,6 +201,9 @@ public void incNumContainerNotOpenVerifyFailures() {
numContainerNotOpenVerifyFailures.incr();
}

public void recordApplyTransactionLatency(long latencyNanos) {
applyTransactionLatency.add(latencyNanos);
}

public void unRegister() {
MetricsSystem ms = DefaultMetricsSystem.instance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
.setTerm(trx.getLogEntry().getTerm())
.setLogIndex(index);

long applyTxnStartTime = Time.monotonicNowNanos();
try {
applyTransactionSemaphore.acquire();
metrics.incNumApplyTransactionsOps();
Expand Down Expand Up @@ -732,7 +733,11 @@ public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
}
}
return applyTransactionFuture;
}).whenComplete((r, t) -> applyTransactionSemaphore.release());
}).whenComplete((r, t) -> {
applyTransactionSemaphore.release();
metrics.recordApplyTransactionLatency(
Time.monotonicNowNanos() - applyTxnStartTime);
});
return applyTransactionFuture;
} catch (IOException | InterruptedException e) {
metrics.incNumApplyTransactionsFails();
Expand Down