Skip to content

Commit 6907d0e

Browse files
committed
logback-appender
1 parent f56c6d0 commit 6907d0e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

instrumentation/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackInstrumentation.java

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

4646
@Advice.OnMethodEnter(suppress = Throwable.class)
47-
public static void methodEnter(
48-
@Advice.Argument(0) ILoggingEvent event,
49-
@Advice.Local("otelCallDepth") CallDepth callDepth) {
47+
public static CallDepth methodEnter(@Advice.Argument(0) ILoggingEvent event) {
5048
// need to track call depth across all loggers in order to avoid double capture when one
5149
// logging framework delegates to another
52-
callDepth = CallDepth.forClass(LoggerProvider.class);
50+
CallDepth callDepth = CallDepth.forClass(LoggerProvider.class);
5351
if (callDepth.getAndIncrement() == 0) {
5452
mapper()
5553
.emit(GlobalOpenTelemetry.get().getLogsBridge(), event, Thread.currentThread().getId());
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/logback/logback-appender-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/logback/appender/v1_0/LogbackInstrumentationModule.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 LogbackInstrumentationModule extends InstrumentationModule {
17+
public class LogbackInstrumentationModule extends InstrumentationModule
18+
implements ExperimentalInstrumentationModule {
1719

1820
public LogbackInstrumentationModule() {
1921
super("logback-appender", "logback-appender-1.0");
@@ -23,4 +25,9 @@ public LogbackInstrumentationModule() {
2325
public List<TypeInstrumentation> typeInstrumentations() {
2426
return singletonList(new LogbackInstrumentation());
2527
}
28+
29+
@Override
30+
public boolean isIndyReady() {
31+
return true;
32+
}
2633
}

0 commit comments

Comments
 (0)