Merge 31d3ac6b6d into 9f021ffdc5
This commit is contained in:
commit
de7754a6bc
|
|
@ -21,6 +21,7 @@ import io.opentelemetry.javaagent.bootstrap.CallDepth;
|
|||
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.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
|
@ -99,13 +100,15 @@ public class BootDelegationInstrumentation implements TypeInstrumentation {
|
|||
return null;
|
||||
}
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void onExit(
|
||||
@Advice.Return(readOnly = false) Class<?> result,
|
||||
@Advice.Enter Class<?> resultFromBootstrapLoader) {
|
||||
public static Class<?> onExit(
|
||||
@Advice.Return Class<?> originalResult, @Advice.Enter Class<?> resultFromBootstrapLoader) {
|
||||
Class<?> result = originalResult;
|
||||
if (resultFromBootstrapLoader != null) {
|
||||
result = resultFromBootstrapLoader;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,9 @@ public class ClassLoaderInstrumentationModule extends InstrumentationModule
|
|||
new ResourceInjectionInstrumentation(),
|
||||
new DefineClassInstrumentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndyReady() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import io.opentelemetry.javaagent.bootstrap.InjectedClassHelper;
|
|||
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.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
|
@ -63,16 +64,18 @@ public class LoadInjectedClassInstrumentation implements TypeInstrumentation {
|
|||
if (helperClass != null) {
|
||||
return helperClass;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||
public static void onExit(
|
||||
@Advice.Return(readOnly = false) Class<?> result, @Advice.Enter Class<?> loadedClass) {
|
||||
public static Class<?> onExit(
|
||||
@Advice.Return Class<?> originalResult, @Advice.Enter Class<?> loadedClass) {
|
||||
Class<?> result = originalResult;
|
||||
if (loadedClass != null) {
|
||||
result = loadedClass;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import io.opentelemetry.javaagent.bootstrap.internal.InClassLoaderMatcher;
|
|||
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.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
|
|
@ -52,13 +53,15 @@ class EclipseOsgiInstrumentation implements TypeInstrumentation {
|
|||
return InClassLoaderMatcher.get() && !packageName.startsWith("io.opentelemetry.");
|
||||
}
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void onExit(
|
||||
@Advice.Return(readOnly = false) boolean result,
|
||||
@Advice.Enter boolean inClassLoaderMatcher) {
|
||||
public static boolean onExit(
|
||||
@Advice.Return boolean originalResult, @Advice.Enter boolean inClassLoaderMatcher) {
|
||||
boolean result = originalResult;
|
||||
if (inClassLoaderMatcher) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ import static java.util.Collections.singletonList;
|
|||
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 io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
|
||||
import java.util.List;
|
||||
|
||||
@AutoService(InstrumentationModule.class)
|
||||
public class EclipseOsgiInstrumentationModule extends InstrumentationModule {
|
||||
public class EclipseOsgiInstrumentationModule extends InstrumentationModule
|
||||
implements ExperimentalInstrumentationModule {
|
||||
public EclipseOsgiInstrumentationModule() {
|
||||
super("internal-eclipse-osgi", "internal-eclipse-osgi-3.6");
|
||||
}
|
||||
|
|
@ -29,4 +31,9 @@ public class EclipseOsgiInstrumentationModule extends InstrumentationModule {
|
|||
public List<TypeInstrumentation> typeInstrumentations() {
|
||||
return singletonList(new EclipseOsgiInstrumentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndyReady() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.util.VirtualField;
|
|||
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.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
|
|
@ -32,21 +33,21 @@ public class TestTypeInstrumentation implements TypeInstrumentation {
|
|||
@SuppressWarnings("unused")
|
||||
public static class TestAdvice {
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit
|
||||
public static void methodExit(
|
||||
@Advice.This Runnable test, @Advice.Return(readOnly = false) String result) {
|
||||
public static String methodExit(@Advice.This Runnable test) {
|
||||
VirtualField.find(Runnable.class, String.class).set(test, "instrumented");
|
||||
result = "instrumented";
|
||||
return "instrumented";
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static class Test2Advice {
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit
|
||||
public static void methodExit(
|
||||
@Advice.This Runnable test, @Advice.Return(readOnly = false) String result) {
|
||||
result = VirtualField.find(Runnable.class, String.class).get(test);
|
||||
public static String methodExit(@Advice.This Runnable test) {
|
||||
return VirtualField.find(Runnable.class, String.class).get(test);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@ import static java.util.Collections.singletonList;
|
|||
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 TestInstrumentationModule extends InstrumentationModule {
|
||||
public class TestInstrumentationModule extends InstrumentationModule
|
||||
implements ExperimentalInstrumentationModule {
|
||||
public TestInstrumentationModule() {
|
||||
super("test-instrumentation");
|
||||
}
|
||||
|
|
@ -22,4 +24,9 @@ public class TestInstrumentationModule extends InstrumentationModule {
|
|||
public List<TypeInstrumentation> typeInstrumentations() {
|
||||
return singletonList(new TestTypeInstrumentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIndyReady() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
|||
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.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
|
|
@ -34,9 +35,10 @@ public class TestTypeInstrumentation implements TypeInstrumentation {
|
|||
@SuppressWarnings("unused")
|
||||
public static class GetHostNameAdvice {
|
||||
|
||||
@AssignReturned.ToReturned
|
||||
@Advice.OnMethodExit
|
||||
public static void methodExit(@Advice.Return(readOnly = false) String hostName) {
|
||||
hostName = "not-the-host-name";
|
||||
public static String methodExit() {
|
||||
return "not-the-host-name";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue