From 695bc9d0bfa7a22d3360ca8a9a068eb810c8d12c Mon Sep 17 00:00:00 2001 From: Mateusz Rzeszutek Date: Thu, 17 Sep 2020 10:04:58 +0200 Subject: [PATCH] Implement MDC auto-instrumentation for log4j1 --- .../auto/log4j/v2_13_2/Log4j2MdcInstrumentation.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/instrumentation/log4j/log4j-2.13.2/auto/src/main/java/io/opentelemetry/instrumentation/auto/log4j/v2_13_2/Log4j2MdcInstrumentation.java b/instrumentation/log4j/log4j-2.13.2/auto/src/main/java/io/opentelemetry/instrumentation/auto/log4j/v2_13_2/Log4j2MdcInstrumentation.java index 4654f8178288..ddfd88e27a0a 100644 --- a/instrumentation/log4j/log4j-2.13.2/auto/src/main/java/io/opentelemetry/instrumentation/auto/log4j/v2_13_2/Log4j2MdcInstrumentation.java +++ b/instrumentation/log4j/log4j-2.13.2/auto/src/main/java/io/opentelemetry/instrumentation/auto/log4j/v2_13_2/Log4j2MdcInstrumentation.java @@ -40,8 +40,10 @@ public ElementMatcher classLoaderMatcher() { @Override public ElementMatcher typeMatcher() { - // need to match a class, not an interface (ContextDataProvider) - otherwise helper classes - // and resources are not injected + // we cannot use ContextDataProvider here because one of the classes that we inject implements + // this interface, causing the interface to be loaded while it's being transformed, which leads + // to duplicate class definition error after the interface is transformed and the triggering + // class loader tries to load it. return named("org.apache.logging.log4j.core.impl.ThreadContextDataInjector"); }