HBASE-27762 Include EventType and ProcedureV2 pid in logging via MDC (#5145)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
b50022d6cf
commit
07bdc09ee5
|
@ -26,7 +26,7 @@ appender.console.target = SYSTEM_ERR
|
||||||
appender.console.name = Console
|
appender.console.name = Console
|
||||||
appender.console.maxSize = 1G
|
appender.console.maxSize = 1G
|
||||||
appender.console.layout.type = PatternLayout
|
appender.console.layout.type = PatternLayout
|
||||||
appender.console.layout.pattern = %d{ISO8601} %-5p [%t] %C{2}(%L): %m%n
|
appender.console.layout.pattern = %d{ISO8601} %-5p [%t (%X)] %C{2}(%L): %m%n
|
||||||
|
|
||||||
rootLogger = INFO,Console
|
rootLogger = INFO,Console
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.trace.TraceUtil;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for all HBase event handlers. Subclasses should implement the
|
* Abstract base class for all HBase event handlers. Subclasses should implement the
|
||||||
|
@ -96,12 +97,16 @@ public abstract class EventHandler implements Runnable, Comparable<EventHandler>
|
||||||
public void run() {
|
public void run() {
|
||||||
Span span = TraceUtil.getGlobalTracer().spanBuilder(getClass().getSimpleName())
|
Span span = TraceUtil.getGlobalTracer().spanBuilder(getClass().getSimpleName())
|
||||||
.setParent(Context.current().with(parent)).startSpan();
|
.setParent(Context.current().with(parent)).startSpan();
|
||||||
|
// assume that this is the top of an execution on a new or reused thread, that we're safe to
|
||||||
|
// blast any existing MDC state.
|
||||||
try (Scope scope = span.makeCurrent()) {
|
try (Scope scope = span.makeCurrent()) {
|
||||||
|
MDC.put("event_type", eventType.toString());
|
||||||
process();
|
process();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
handleException(t);
|
handleException(t);
|
||||||
} finally {
|
} finally {
|
||||||
span.end();
|
span.end();
|
||||||
|
MDC.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
|
||||||
|
|
||||||
|
@ -93,6 +94,7 @@ public class AssignRegionHandler extends EventHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() throws IOException {
|
public void process() throws IOException {
|
||||||
|
MDC.put("pid", Long.toString(openProcId));
|
||||||
HRegionServer rs = getServer();
|
HRegionServer rs = getServer();
|
||||||
String encodedName = regionInfo.getEncodedName();
|
String encodedName = regionInfo.getEncodedName();
|
||||||
byte[] encodedNameBytes = regionInfo.getEncodedNameAsBytes();
|
byte[] encodedNameBytes = regionInfo.getEncodedNameAsBytes();
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A event handler for running procedure.
|
* A event handler for running procedure.
|
||||||
|
@ -46,6 +47,7 @@ public class RSProcedureHandler extends EventHandler {
|
||||||
public void process() {
|
public void process() {
|
||||||
Throwable error = null;
|
Throwable error = null;
|
||||||
try {
|
try {
|
||||||
|
MDC.put("pid", Long.toString(procId));
|
||||||
callable.call();
|
callable.call();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
LOG.error("pid=" + this.procId, t);
|
LOG.error("pid=" + this.procId, t);
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
|
||||||
import org.apache.yetus.audience.InterfaceAudience;
|
import org.apache.yetus.audience.InterfaceAudience;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
|
import org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode;
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ public class UnassignRegionHandler extends EventHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process() throws IOException {
|
public void process() throws IOException {
|
||||||
|
MDC.put("pid", Long.toString(closeProcId));
|
||||||
HRegionServer rs = getServer();
|
HRegionServer rs = getServer();
|
||||||
byte[] encodedNameBytes = Bytes.toBytes(encodedName);
|
byte[] encodedNameBytes = Bytes.toBytes(encodedName);
|
||||||
Boolean previous = rs.getRegionsInTransitionInRS().putIfAbsent(encodedNameBytes, Boolean.FALSE);
|
Boolean previous = rs.getRegionsInTransitionInRS().putIfAbsent(encodedNameBytes, Boolean.FALSE);
|
||||||
|
|
Loading…
Reference in New Issue