diff --git a/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentation.java b/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentation.java index 205b7419f18c..c612fe395f24 100644 --- a/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentation.java +++ b/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentation.java @@ -44,20 +44,19 @@ public void transform(TypeTransformer transformer) { public static class LogAdvice { @Advice.OnMethodEnter(suppress = Throwable.class) - public static void methodEnter( - @Advice.This Logger logger, - @Advice.Argument(0) LogRecord logRecord, - @Advice.Local("otelCallDepth") CallDepth callDepth) { + public static CallDepth methodEnter( + @Advice.This Logger logger, @Advice.Argument(0) LogRecord logRecord) { // need to track call depth across all loggers in order to avoid double capture when one // logging framework delegates to another - callDepth = CallDepth.forClass(LoggerProvider.class); + CallDepth callDepth = CallDepth.forClass(LoggerProvider.class); if (callDepth.getAndIncrement() == 0) { JavaUtilLoggingHelper.capture(logger, logRecord); } + return callDepth; } @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) - public static void methodExit(@Advice.Local("otelCallDepth") CallDepth callDepth) { + public static void methodExit(@Advice.Enter CallDepth callDepth) { callDepth.decrementAndGet(); } } diff --git a/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentationModule.java b/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentationModule.java index b5e69f36c2ff..9eeba3dcfea5 100644 --- a/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentationModule.java +++ b/instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentationModule.java @@ -10,10 +10,12 @@ import com.google.auto.service.AutoService; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; import java.util.List; @AutoService(InstrumentationModule.class) -public class JavaUtilLoggingInstrumentationModule extends InstrumentationModule { +public class JavaUtilLoggingInstrumentationModule extends InstrumentationModule + implements ExperimentalInstrumentationModule { public JavaUtilLoggingInstrumentationModule() { super("java-util-logging"); @@ -23,4 +25,9 @@ public JavaUtilLoggingInstrumentationModule() { public List typeInstrumentations() { return singletonList(new JavaUtilLoggingInstrumentation()); } + + @Override + public boolean isIndyReady() { + return true; + } }