Skip to content

Commit d56ec91

Browse files
authored
make java-util-logging indy-ready (#15110)
1 parent a8dc8e4 commit d56ec91

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentation.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,19 @@ public void transform(TypeTransformer transformer) {
4444
public static class LogAdvice {
4545

4646
@Advice.OnMethodEnter(suppress = Throwable.class)
47-
public static void methodEnter(
48-
@Advice.This Logger logger,
49-
@Advice.Argument(0) LogRecord logRecord,
50-
@Advice.Local("otelCallDepth") CallDepth callDepth) {
47+
public static CallDepth methodEnter(
48+
@Advice.This Logger logger, @Advice.Argument(0) LogRecord logRecord) {
5149
// need to track call depth across all loggers in order to avoid double capture when one
5250
// logging framework delegates to another
53-
callDepth = CallDepth.forClass(LoggerProvider.class);
51+
CallDepth callDepth = CallDepth.forClass(LoggerProvider.class);
5452
if (callDepth.getAndIncrement() == 0) {
5553
JavaUtilLoggingHelper.capture(logger, logRecord);
5654
}
55+
return callDepth;
5756
}
5857

5958
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
60-
public static void methodExit(@Advice.Local("otelCallDepth") CallDepth callDepth) {
59+
public static void methodExit(@Advice.Enter CallDepth callDepth) {
6160
callDepth.decrementAndGet();
6261
}
6362
}

instrumentation/java-util-logging/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jul/JavaUtilLoggingInstrumentationModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
import com.google.auto.service.AutoService;
1111
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1212
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
13+
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
1314
import java.util.List;
1415

1516
@AutoService(InstrumentationModule.class)
16-
public class JavaUtilLoggingInstrumentationModule extends InstrumentationModule {
17+
public class JavaUtilLoggingInstrumentationModule extends InstrumentationModule
18+
implements ExperimentalInstrumentationModule {
1719

1820
public JavaUtilLoggingInstrumentationModule() {
1921
super("java-util-logging");
@@ -23,4 +25,9 @@ public JavaUtilLoggingInstrumentationModule() {
2325
public List<TypeInstrumentation> typeInstrumentations() {
2426
return singletonList(new JavaUtilLoggingInstrumentation());
2527
}
28+
29+
@Override
30+
public boolean isIndyReady() {
31+
return true;
32+
}
2633
}

0 commit comments

Comments
 (0)