Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -23,4 +25,9 @@ public JavaUtilLoggingInstrumentationModule() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new JavaUtilLoggingInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Loading