HBASE-8725 Add total time RPC call metrics

Signed-off-by: Elliott Clark <eclark@apache.org>
This commit is contained in:
nke 2015-03-25 17:21:01 -07:00 committed by Elliott Clark
parent 69f6a2e7b4
commit 18256fc954
5 changed files with 25 additions and 3 deletions

View File

@ -42,6 +42,8 @@ public interface MetricsHBaseServerSource extends BaseSource {
String QUEUE_CALL_TIME_DESC = "Queue Call Time.";
String PROCESS_CALL_TIME_NAME = "processCallTime";
String PROCESS_CALL_TIME_DESC = "Processing call time.";
String TOTAL_CALL_TIME_NAME = "totalCallTime";
String TOTAL_CALL_TIME_DESC = "Total call time, including both queued and processing time.";
String QUEUE_SIZE_NAME = "queueSize";
String QUEUE_SIZE_DESC = "Number of bytes in the call queues.";
String GENERAL_QUEUE_NAME = "numCallsInGeneralQueue";
@ -71,4 +73,6 @@ public interface MetricsHBaseServerSource extends BaseSource {
void dequeuedCall(int qTime);
void processedCall(int processingTime);
}
void queuedAndProcessedCall(int totalTime);
}

View File

@ -40,6 +40,7 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl
private final MutableCounterLong receivedBytes;
private MutableHistogram queueCallTime;
private MutableHistogram processCallTime;
private MutableHistogram totalCallTime;
public MetricsHBaseServerSourceImpl(String metricsName,
String metricsDescription,
@ -66,6 +67,8 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl
QUEUE_CALL_TIME_DESC);
this.processCallTime = this.getMetricsRegistry().newHistogram(PROCESS_CALL_TIME_NAME,
PROCESS_CALL_TIME_DESC);
this.totalCallTime = this.getMetricsRegistry().newHistogram(TOTAL_CALL_TIME_NAME,
TOTAL_CALL_TIME_DESC);
}
@Override
@ -108,6 +111,11 @@ public class MetricsHBaseServerSourceImpl extends BaseSourceImpl
processCallTime.add(processingTime);
}
@Override
public void queuedAndProcessedCall(int totalTime) {
totalCallTime.add(totalTime);
}
@Override
public void getMetrics(MetricsCollector metricsCollector, boolean all) {
MetricsRecordBuilder mrb = metricsCollector.addRecord(metricsName);

View File

@ -63,6 +63,10 @@ public class MetricsHBaseServer {
source.processedCall(processingTime);
}
void totalCall(int totalTime) {
source.queuedAndProcessedCall(totalTime);
}
public MetricsHBaseServerSource getMetricsSource() {
return source;
}

View File

@ -2071,16 +2071,20 @@ public class RpcServer implements RpcServerInterface {
long startTime = System.currentTimeMillis();
PayloadCarryingRpcController controller = new PayloadCarryingRpcController(cellScanner);
Message result = service.callBlockingMethod(md, controller, param);
int processingTime = (int) (System.currentTimeMillis() - startTime);
long endTime = System.currentTimeMillis();
int processingTime = (int) (endTime - startTime);
int qTime = (int) (startTime - receiveTime);
int totalTime = (int) (endTime - receiveTime);
if (LOG.isTraceEnabled()) {
LOG.trace(CurCall.get().toString() +
", response " + TextFormat.shortDebugString(result) +
" queueTime: " + qTime +
" processingTime: " + processingTime);
" processingTime: " + processingTime +
" totalTime: " + totalTime);
}
metrics.dequeuedCall(qTime);
metrics.processedCall(processingTime);
metrics.totalCall(totalTime);
long responseSize = result.getSerializedSize();
// log any RPC responses that are slower than the configured warn
// response time or larger than configured warning size

View File

@ -99,8 +99,10 @@ public class TestRpcMetrics {
mrpc.dequeuedCall(100);
mrpc.processedCall(101);
mrpc.totalCall(102);
HELPER.assertCounter("queueCallTime_NumOps", 1, serverSource);
HELPER.assertCounter("processCallTime_NumOps", 1, serverSource);
HELPER.assertCounter("totalCallTime_NumOps", 1, serverSource);
mrpc.sentBytes(103);
mrpc.sentBytes(103);