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 @@ -13,6 +13,8 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -38,11 +40,10 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class StopContextPropagationAdvice {

@AssignReturned.ToArguments(@ToArgument(1))
@Advice.OnMethodEnter
public static void enter(@Advice.Argument(value = 1, readOnly = false) Runnable runnable) {
if (runnable != null) {
runnable = RunnableWrapper.stopPropagation(runnable);
}
public static Runnable enter(@Advice.Argument(1) Runnable runnable) {
return runnable == null ? null : RunnableWrapper.stopPropagation(runnable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import kotlin.coroutines.CoroutineContext;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.asm.Advice.AssignReturned.ToArguments.ToArgument;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -33,13 +35,12 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class ContextAdvice {

@AssignReturned.ToArguments(@ToArgument(1))
@Advice.OnMethodEnter
public static void enter(
@Advice.Argument(value = 1, readOnly = false) CoroutineContext coroutineContext) {
if (coroutineContext != null) {
coroutineContext =
KotlinCoroutinesInstrumentationHelper.addOpenTelemetryContext(coroutineContext);
}
public static CoroutineContext enter(@Advice.Argument(1) CoroutineContext coroutineContext) {
return coroutineContext == null
? null
: KotlinCoroutinesInstrumentationHelper.addOpenTelemetryContext(coroutineContext);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
return asList(
new KotlinCoroutinesInstrumentation(), new KotlinCoroutineDispatcherInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@ public void injectClasses(ClassInjector injector) {
"io.opentelemetry.javaagent.instrumentation.kotlinxcoroutines.instrumentationannotations.AnnotationInstrumentationHelper")
.inject(InjectionMode.CLASS_ONLY);
}

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