Do not use advice class names in Lettuce instrumentation directly
Since this leads to Java8 code loaded into Java7 JVM in tests. Insted reference class names by string.
This commit is contained in:
parent
46428dc6a3
commit
7c62e10542
|
@ -12,6 +12,9 @@ import net.bytebuddy.matcher.ElementMatcher;
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {
|
public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
|
public static final String PACKAGE =
|
||||||
|
LettuceAsyncCommandsInstrumentation.class.getPackage().getName();
|
||||||
|
|
||||||
public LettuceAsyncCommandsInstrumentation() {
|
public LettuceAsyncCommandsInstrumentation() {
|
||||||
super("lettuce", "lettuce-5-async");
|
super("lettuce", "lettuce-5-async");
|
||||||
}
|
}
|
||||||
|
@ -29,9 +32,7 @@ public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {
|
||||||
@Override
|
@Override
|
||||||
public String[] helperClassNames() {
|
public String[] helperClassNames() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
LettuceAsyncCommandsInstrumentation.class.getPackage().getName() + ".LettuceAsyncBiFunction",
|
PACKAGE + ".LettuceAsyncBiFunction", PACKAGE + ".LettuceInstrumentationUtil"
|
||||||
LettuceAsyncCommandsInstrumentation.class.getPackage().getName()
|
|
||||||
+ ".LettuceInstrumentationUtil"
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +43,8 @@ public class LettuceAsyncCommandsInstrumentation extends Instrumenter.Default {
|
||||||
isMethod()
|
isMethod()
|
||||||
.and(named("dispatch"))
|
.and(named("dispatch"))
|
||||||
.and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand"))),
|
.and(takesArgument(0, named("io.lettuce.core.protocol.RedisCommand"))),
|
||||||
LettuceAsyncCommandsAdvice.class.getName());
|
// Cannot reference class directly here because this would lead to class load failure on Java7
|
||||||
|
PACKAGE + ".LettuceAsyncCommandsAdvice");
|
||||||
return transformers;
|
return transformers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,13 @@ import net.bytebuddy.matcher.ElementMatcher;
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public final class LettuceClientInstrumentation extends Instrumenter.Default {
|
public final class LettuceClientInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
|
public static final String PACKAGE = LettuceClientInstrumentation.class.getPackage().getName();
|
||||||
|
|
||||||
private static final String[] HELPER_CLASS_NAMES =
|
private static final String[] HELPER_CLASS_NAMES =
|
||||||
new String[] {
|
new String[] {
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
||||||
+ ".LettuceInstrumentationUtil",
|
+ ".LettuceInstrumentationUtil",
|
||||||
LettuceClientInstrumentation.class.getPackage().getName() + ".LettuceAsyncBiFunction"
|
PACKAGE + ".LettuceAsyncBiFunction"
|
||||||
};
|
};
|
||||||
|
|
||||||
public LettuceClientInstrumentation() {
|
public LettuceClientInstrumentation() {
|
||||||
|
@ -48,7 +50,8 @@ public final class LettuceClientInstrumentation extends Instrumenter.Default {
|
||||||
.and(nameStartsWith("connect"))
|
.and(nameStartsWith("connect"))
|
||||||
.and(nameEndsWith("Async"))
|
.and(nameEndsWith("Async"))
|
||||||
.and(takesArgument(1, named("io.lettuce.core.RedisURI"))),
|
.and(takesArgument(1, named("io.lettuce.core.RedisURI"))),
|
||||||
ConnectionFutureAdvice.class.getName());
|
// Cannot reference class directly here because this would lead to class load failure on Java7
|
||||||
|
PACKAGE + ".ConnectionFutureAdvice");
|
||||||
return transformers;
|
return transformers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import static net.bytebuddy.matcher.ElementMatchers.*;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
import datadog.trace.agent.tooling.Instrumenter;
|
import datadog.trace.agent.tooling.Instrumenter;
|
||||||
import datadog.trace.instrumentation.lettuce.rx.LettuceFluxCreationAdvice;
|
|
||||||
import datadog.trace.instrumentation.lettuce.rx.LettuceMonoCreationAdvice;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
|
@ -14,6 +12,9 @@ import net.bytebuddy.matcher.ElementMatcher;
|
||||||
@AutoService(Instrumenter.class)
|
@AutoService(Instrumenter.class)
|
||||||
public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default {
|
public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default {
|
||||||
|
|
||||||
|
public static final String PACKAGE =
|
||||||
|
LettuceReactiveCommandsInstrumentation.class.getPackage().getName();
|
||||||
|
|
||||||
public LettuceReactiveCommandsInstrumentation() {
|
public LettuceReactiveCommandsInstrumentation() {
|
||||||
super("lettuce", "lettuce-5-rx");
|
super("lettuce", "lettuce-5-rx");
|
||||||
}
|
}
|
||||||
|
@ -31,18 +32,12 @@ public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default
|
||||||
@Override
|
@Override
|
||||||
public String[] helperClassNames() {
|
public String[] helperClassNames() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
PACKAGE + ".LettuceInstrumentationUtil",
|
||||||
+ ".LettuceInstrumentationUtil",
|
PACKAGE + ".rx.LettuceMonoCreationAdvice",
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
PACKAGE + ".rx.LettuceMonoDualConsumer",
|
||||||
+ ".rx.LettuceMonoCreationAdvice",
|
PACKAGE + ".rx.LettuceFluxCreationAdvice",
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
PACKAGE + ".rx.LettuceFluxTerminationRunnable",
|
||||||
+ ".rx.LettuceMonoDualConsumer",
|
PACKAGE + ".rx.LettuceFluxTerminationRunnable$FluxOnSubscribeConsumer"
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
|
||||||
+ ".rx.LettuceFluxCreationAdvice",
|
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
|
||||||
+ ".rx.LettuceFluxTerminationRunnable",
|
|
||||||
LettuceReactiveCommandsInstrumentation.class.getPackage().getName()
|
|
||||||
+ ".rx.LettuceFluxTerminationRunnable$FluxOnSubscribeConsumer"
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,14 +49,16 @@ public class LettuceReactiveCommandsInstrumentation extends Instrumenter.Default
|
||||||
.and(named("createMono"))
|
.and(named("createMono"))
|
||||||
.and(takesArgument(0, named("java.util.function.Supplier")))
|
.and(takesArgument(0, named("java.util.function.Supplier")))
|
||||||
.and(returns(named("reactor.core.publisher.Mono"))),
|
.and(returns(named("reactor.core.publisher.Mono"))),
|
||||||
LettuceMonoCreationAdvice.class.getName());
|
// Cannot reference class directly here because this would lead to class load failure on Java7
|
||||||
|
PACKAGE + ".rx.LettuceMonoCreationAdvice");
|
||||||
transformers.put(
|
transformers.put(
|
||||||
isMethod()
|
isMethod()
|
||||||
.and(nameStartsWith("create"))
|
.and(nameStartsWith("create"))
|
||||||
.and(nameEndsWith("Flux"))
|
.and(nameEndsWith("Flux"))
|
||||||
.and(takesArgument(0, named("java.util.function.Supplier")))
|
.and(takesArgument(0, named("java.util.function.Supplier")))
|
||||||
.and(returns(named(("reactor.core.publisher.Flux")))),
|
.and(returns(named(("reactor.core.publisher.Flux")))),
|
||||||
LettuceFluxCreationAdvice.class.getName());
|
// Cannot reference class directly here because this would lead to class load failure on Java7
|
||||||
|
PACKAGE + ".rx.LettuceFluxCreationAdvice");
|
||||||
|
|
||||||
return transformers;
|
return transformers;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue