HBASE-26175 MetricsHBaseServer should record all kinds of Exceptions (#4248)

Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
This commit is contained in:
Xiaolin Ha 2022-03-24 19:03:22 +08:00 committed by GitHub
parent ab4351a155
commit ec7141720f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 7 deletions

View File

@ -45,6 +45,8 @@ public interface ExceptionTrackingSource extends BaseSource {
String EXCEPTIONS_RPC_THROTTLING = "exceptions.rpcThrottling";
String EXCEPTIONS_CALL_DROPPED = "exceptions.callDropped";
String EXCEPTIONS_CALL_TIMED_OUT = "exceptions.callTimedOut";
String EXCEPTIONS_REQUEST_TOO_BIG = "exceptions.requestTooBig";
String OTHER_EXCEPTIONS = "exceptions.otherExceptions";
void exception();
@ -64,4 +66,6 @@ public interface ExceptionTrackingSource extends BaseSource {
void rpcThrottlingException();
void callDroppedException();
void callTimedOut();
void requestTooBigException();
void otherExceptions();
}

View File

@ -42,6 +42,8 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
protected MutableFastCounter exceptionsRpcThrottling;
protected MutableFastCounter exceptionsCallDropped;
protected MutableFastCounter exceptionsCallTimedOut;
protected MutableFastCounter exceptionRequestTooBig;
protected MutableFastCounter otherExceptions;
public ExceptionTrackingSourceImpl(String metricsName, String metricsDescription,
String metricsContext, String metricsJmxContext) {
@ -78,6 +80,10 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
.newCounter(EXCEPTIONS_CALL_DROPPED, EXCEPTIONS_TYPE_DESC, 0L);
this.exceptionsCallTimedOut = this.getMetricsRegistry()
.newCounter(EXCEPTIONS_CALL_TIMED_OUT, EXCEPTIONS_TYPE_DESC, 0L);
this.exceptionRequestTooBig = this.getMetricsRegistry()
.newCounter(EXCEPTIONS_REQUEST_TOO_BIG, EXCEPTIONS_TYPE_DESC, 0L);
this.otherExceptions = this.getMetricsRegistry()
.newCounter(OTHER_EXCEPTIONS, EXCEPTIONS_TYPE_DESC, 0L);
}
@Override
@ -149,4 +155,14 @@ public class ExceptionTrackingSourceImpl extends BaseSourceImpl
public void callTimedOut() {
exceptionsCallTimedOut.incr();
}
@Override
public void requestTooBigException() {
exceptionRequestTooBig.incr();
}
@Override
public void otherExceptions() {
otherExceptions.incr();
}
}

View File

@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.MultiActionResultTooLarge;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.UnknownScannerException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
import org.apache.yetus.audience.InterfaceAudience;
@ -129,8 +130,13 @@ public class MetricsHBaseServer {
source.rpcThrottlingException();
} else if (throwable instanceof CallDroppedException) {
source.callDroppedException();
} else if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
} else if (throwable instanceof RequestTooBigException) {
source.requestTooBigException();
} else {
source.otherExceptions();
if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
}
}
}
}

View File

@ -17,16 +17,17 @@
*/
package org.apache.hadoop.hbase.ipc;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import org.apache.hadoop.hbase.CallDroppedException;
import org.apache.hadoop.hbase.CompatibilityFactory;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.NotServingRegionException;
import org.apache.hadoop.hbase.RegionTooBusyException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.RPCTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@ -145,12 +146,23 @@ public class TestRpcMetrics {
mrpc.exception(new OutOfOrderScannerNextException());
mrpc.exception(new NotServingRegionException());
mrpc.exception(new CallDroppedException());
mrpc.exception(new RequestTooBigException());
mrpc.exception(new FakeException());
HELPER.assertCounter("exceptions.RegionMovedException", 1, serverSource);
HELPER.assertCounter("exceptions.RegionTooBusyException", 1, serverSource);
HELPER.assertCounter("exceptions.OutOfOrderScannerNextException", 1, serverSource);
HELPER.assertCounter("exceptions.NotServingRegionException", 1, serverSource);
HELPER.assertCounter("exceptions.callDropped", 1, serverSource);
HELPER.assertCounter("exceptions", 6, serverSource);
HELPER.assertCounter("exceptions.requestTooBig", 1, serverSource);
HELPER.assertCounter("exceptions.otherExceptions", 1, serverSource);
HELPER.assertCounter("exceptions", 8, serverSource);
}
private class FakeException extends DoNotRetryIOException {
public FakeException() {
super();
}
}
@Test

View File

@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.exceptions.ClientExceptionsUtil;
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.exceptions.ScannerResetException;
import org.apache.hadoop.hbase.quotas.QuotaExceededException;
import org.apache.hadoop.hbase.quotas.RpcThrottlingException;
@ -157,8 +158,13 @@ public class ThriftMetrics {
source.rpcThrottlingException();
} else if (throwable instanceof CallDroppedException) {
source.callDroppedException();
} else if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
} else if (throwable instanceof RequestTooBigException) {
source.requestTooBigException();
} else {
source.otherExceptions();
if (LOG.isDebugEnabled()) {
LOG.debug("Unknown exception type", throwable);
}
}
}
}