diff --git a/conf/log4j2.properties b/conf/log4j2.properties index 5ffcfda24176..90d52a2bea13 100644 --- a/conf/log4j2.properties +++ b/conf/log4j2.properties @@ -25,7 +25,7 @@ appender.console.type = Console appender.console.target = SYSTEM_ERR appender.console.name = console appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n +appender.console.layout.pattern = %d{ISO8601} %-5p [%t (%X)] %c{2}: %.1000m%n # Daily Rolling File Appender appender.DRFA.type = RollingFile diff --git a/hbase-logging/src/test/resources/log4j2.properties b/hbase-logging/src/test/resources/log4j2.properties index 56d67c85aa1b..4f29bb455624 100644 --- a/hbase-logging/src/test/resources/log4j2.properties +++ b/hbase-logging/src/test/resources/log4j2.properties @@ -26,7 +26,7 @@ appender.console.target = SYSTEM_ERR appender.console.name = Console appender.console.maxSize = 1G 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 diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java index ece244fda4fc..07c39ce7e444 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java @@ -27,6 +27,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; /** * Abstract base class for all HBase event handlers. Subclasses should implement the @@ -96,6 +97,10 @@ public EventHandler prepare() throws Exception { public void run() { Span span = TraceUtil.getGlobalTracer().spanBuilder(getClass().getSimpleName()) .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. + MDC.clear(); + MDC.put("event_type", eventType.toString()); try (Scope scope = span.makeCurrent()) { process(); } catch (Throwable t) { diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/RSProcedureHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/RSProcedureHandler.java index d4ddebe727d7..d3ecc8a51e22 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/RSProcedureHandler.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/RSProcedureHandler.java @@ -23,6 +23,7 @@ import org.apache.yetus.audience.InterfaceAudience; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.MDC; /** * A event handler for running procedure. @@ -46,6 +47,7 @@ public RSProcedureHandler(HRegionServer rs, long procId, RSProcedureCallable cal public void process() { Throwable error = null; try { + MDC.put("pid", Long.toString(procId)); callable.call(); } catch (Throwable t) { LOG.error("pid=" + this.procId, t);