Merge branch 'master' into mar-kolya/improve-hash-calclulation-cache-pool
This commit is contained in:
commit
41db97ea0f
|
@ -1,13 +1,11 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.skipClassLoader;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.GlobalIgnoresMatcher.globalIgnoresMatcher;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameContains;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.none;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
import datadog.trace.api.Config;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
|
@ -20,6 +18,7 @@ import java.util.ServiceLoader;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.agent.builder.ResettableClassFileTransformer;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.dynamic.DynamicType;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
@ -52,6 +51,8 @@ public class AgentInstaller {
|
|||
final Instrumentation inst, final AgentBuilder.Listener... listeners) {
|
||||
INSTRUMENTATION = inst;
|
||||
|
||||
addByteBuddyRawSetting();
|
||||
|
||||
AgentBuilder agentBuilder =
|
||||
new AgentBuilder.Default()
|
||||
.disableClassFormatChanges()
|
||||
|
@ -64,75 +65,7 @@ public class AgentInstaller {
|
|||
// https://github.com/raphw/byte-buddy/issues/558
|
||||
// .with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
|
||||
.ignore(any(), skipClassLoader())
|
||||
/**
|
||||
* Be very careful about the types of matchers used in this section as they are called
|
||||
* on every class load, so they must be fast. Generally speaking try to only use name
|
||||
* matchers as they don't have to load additional info.
|
||||
*/
|
||||
.or(
|
||||
nameStartsWith("datadog.trace.")
|
||||
// FIXME: We should remove this once
|
||||
// https://github.com/raphw/byte-buddy/issues/558 is fixed
|
||||
.and(
|
||||
not(
|
||||
named(
|
||||
"datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper")
|
||||
.or(
|
||||
named(
|
||||
"datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper")))))
|
||||
.or(nameStartsWith("datadog.opentracing."))
|
||||
.or(nameStartsWith("datadog.slf4j."))
|
||||
.or(nameStartsWith("net.bytebuddy."))
|
||||
.or(
|
||||
nameStartsWith("java.")
|
||||
.and(
|
||||
not(
|
||||
named("java.net.URL")
|
||||
.or(named("java.net.HttpURLConnection"))
|
||||
.or(nameStartsWith("java.rmi."))
|
||||
.or(nameStartsWith("java.util.concurrent."))
|
||||
.or(
|
||||
nameStartsWith("java.util.logging.")
|
||||
// Concurrent instrumentation modifies the strucutre of
|
||||
// Cleaner class incompaibly with java9+ modules.
|
||||
// Working around until a long-term fix for modules can be
|
||||
// put in place.
|
||||
.and(not(named("java.util.logging.LogManager$Cleaner")))))))
|
||||
.or(
|
||||
nameStartsWith("com.sun.")
|
||||
.and(
|
||||
not(
|
||||
nameStartsWith("com.sun.messaging.")
|
||||
.or(nameStartsWith("com.sun.jersey.api.client")))))
|
||||
.or(
|
||||
nameStartsWith("sun.")
|
||||
.and(
|
||||
not(
|
||||
nameStartsWith("sun.net.www.protocol.")
|
||||
.or(nameStartsWith("sun.rmi.server"))
|
||||
.or(nameStartsWith("sun.rmi.transport"))
|
||||
.or(named("sun.net.www.http.HttpClient")))))
|
||||
.or(nameStartsWith("jdk."))
|
||||
.or(nameStartsWith("org.aspectj."))
|
||||
.or(nameStartsWith("org.groovy."))
|
||||
.or(nameStartsWith("org.codehaus.groovy.macro."))
|
||||
.or(nameStartsWith("com.intellij.rt.debugger."))
|
||||
.or(nameStartsWith("com.p6spy."))
|
||||
.or(nameStartsWith("com.newrelic."))
|
||||
.or(nameStartsWith("com.dynatrace."))
|
||||
.or(nameStartsWith("com.jloadtrace."))
|
||||
.or(nameStartsWith("com.appdynamics."))
|
||||
.or(nameStartsWith("com.singularity."))
|
||||
.or(nameStartsWith("com.jinspired."))
|
||||
.or(nameStartsWith("org.jinspired."))
|
||||
.or(nameStartsWith("org.apache.log4j.").and(not(named("org.apache.log4j.MDC"))))
|
||||
.or(nameStartsWith("org.slf4j.").and(not(named("org.slf4j.MDC"))))
|
||||
.or(nameContains("$JaxbAccessor"))
|
||||
.or(nameContains("CGLIB$$"))
|
||||
.or(nameContains("javassist"))
|
||||
.or(nameContains(".asm."))
|
||||
.or(nameContains("$__sisu"))
|
||||
.or(nameMatches("com\\.mchange\\.v2\\.c3p0\\..*Proxy"))
|
||||
.or(globalIgnoresMatcher())
|
||||
.or(matchesConfiguredExcludes());
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
|
@ -163,6 +96,23 @@ public class AgentInstaller {
|
|||
return agentBuilder.installOn(inst);
|
||||
}
|
||||
|
||||
private static void addByteBuddyRawSetting() {
|
||||
final String savedPropertyValue = System.getProperty(TypeDefinition.RAW_TYPES_PROPERTY);
|
||||
try {
|
||||
System.setProperty(TypeDefinition.RAW_TYPES_PROPERTY, "true");
|
||||
final boolean rawTypes = TypeDescription.AbstractBase.RAW_TYPES;
|
||||
if (!rawTypes) {
|
||||
log.debug("Too late to enable {}", TypeDefinition.RAW_TYPES_PROPERTY);
|
||||
}
|
||||
} finally {
|
||||
if (savedPropertyValue == null) {
|
||||
System.clearProperty(TypeDefinition.RAW_TYPES_PROPERTY);
|
||||
} else {
|
||||
System.setProperty(TypeDefinition.RAW_TYPES_PROPERTY, savedPropertyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ElementMatcher.Junction<Object> matchesConfiguredExcludes() {
|
||||
final List<String> excludedClasses = Config.get().getExcludedClasses();
|
||||
ElementMatcher.Junction matcher = none();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.DDCachingPoolStrategy;
|
||||
import datadog.trace.agent.tooling.bytebuddy.DDLocationStrategy;
|
||||
import datadog.trace.bootstrap.WeakMap;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,393 +0,0 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.hasSignature;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.description.type.TypeList;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
/**
|
||||
* This class provides some custom ByteBuddy element matchers to use when applying instrumentation
|
||||
*/
|
||||
@Slf4j
|
||||
public class ByteBuddyElementMatchers {
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeExtendsClass(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher));
|
||||
}
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasInterface(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches any type description that declares a super type that matches the provided matcher.
|
||||
* Exceptions during matching process are logged and ignored.
|
||||
*
|
||||
* @param matcher The type to be checked for being a super type of the matched type.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that matches any type description that declares a super type that matches the
|
||||
* provided matcher.
|
||||
* @see ElementMatchers#hasSuperType(net.bytebuddy.matcher.ElementMatcher)
|
||||
*/
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasSuperType(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps another matcher to assure that an element is not matched in case that the matching causes
|
||||
* an {@link Exception}. Logs exception if it happens.
|
||||
*
|
||||
* @param matcher The element matcher that potentially throws an exception.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that returns {@code false} in case that the given matcher throws an
|
||||
* exception.
|
||||
*/
|
||||
public static <T> ElementMatcher.Junction<T> failSafe(
|
||||
final ElementMatcher<? super T> matcher, final String description) {
|
||||
return new SafeMatcher<>(matcher, false, description);
|
||||
}
|
||||
|
||||
private static TypeDescription safeAsErasure(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.asErasure();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get erasure for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An element matcher that matches a super type. This is different from {@link
|
||||
* net.bytebuddy.matcher.HasSuperTypeMatcher} in the following way:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Exceptions are logged
|
||||
* <li>When exception happens the rest of the inheritance subtree is discarded (since ByteBuddy
|
||||
* cannot load/parse type information for it) but search in other subtrees continues
|
||||
* </ul>
|
||||
*
|
||||
* <p>This is useful because this allows us to see when matcher's check is not complete (i.e. part
|
||||
* of it fails), at the same time it makes best effort instead of failing quickly (like {@code
|
||||
* failSafe(hasSuperType(...))} does) which means the code is more resilient to classpath
|
||||
* inconsistencies
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.HasSuperTypeMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
public static class SafeHasSuperTypeMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to any super type of the matched type. */
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
private final boolean interfacesOnly;
|
||||
/**
|
||||
* Creates a new matcher for a super type.
|
||||
*
|
||||
* @param matcher The matcher to apply to any super type of the matched type.
|
||||
*/
|
||||
public SafeHasSuperTypeMatcher(
|
||||
final ElementMatcher<? super TypeDescription.Generic> matcher,
|
||||
final boolean interfacesOnly) {
|
||||
this.matcher = matcher;
|
||||
this.interfacesOnly = interfacesOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final Set<TypeDescription> checkedInterfaces = new HashSet<>();
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (((!interfacesOnly || typeDefinition.isInterface())
|
||||
&& matcher.matches(typeDefinition.asGenericType()))
|
||||
|| hasInterface(typeDefinition, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a type's interfaces against the provided matcher.
|
||||
*
|
||||
* @param typeDefinition The type for which to check all implemented interfaces.
|
||||
* @param checkedInterfaces The interfaces that have already been checked.
|
||||
* @return {@code true} if any interface matches the supplied matcher.
|
||||
*/
|
||||
private boolean hasInterface(
|
||||
final TypeDefinition typeDefinition, final Set<TypeDescription> checkedInterfaces) {
|
||||
for (final TypeDefinition interfaceType : safeGetInterfaces(typeDefinition)) {
|
||||
final TypeDescription erasure = safeAsErasure(interfaceType);
|
||||
if (erasure != null) {
|
||||
if (checkedInterfaces.add(interfaceType.asErasure())
|
||||
&& (matcher.matches(interfaceType.asGenericType())
|
||||
|| hasInterface(interfaceType, checkedInterfaces))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeDefinition#getInterfaces() produces an interator which may throw an exception during
|
||||
* iteration if an interface is absent from the classpath.
|
||||
*
|
||||
* <p>This method exists to allow getting interfaces even if the lookup on one fails.
|
||||
*/
|
||||
private List<TypeDefinition> safeGetInterfaces(final TypeDefinition typeDefinition) {
|
||||
final List<TypeDefinition> interfaceTypes = new ArrayList<>();
|
||||
try {
|
||||
final Iterator<TypeDescription.Generic> interfaceIter =
|
||||
typeDefinition.getInterfaces().iterator();
|
||||
while (interfaceIter.hasNext()) {
|
||||
interfaceTypes.add(interfaceIter.next());
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get interfaces for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
}
|
||||
return interfaceTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeHasSuperType(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An element matcher that matches its argument's {@link TypeDescription.Generic} raw type against
|
||||
* the given matcher for a {@link TypeDescription}. As a wildcard does not define an erasure, a
|
||||
* runtime exception is thrown when this matcher is applied to a wildcard.
|
||||
*
|
||||
* <p>Catches and logs exception if it was thrown when getting erasure, returning false.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.ErasureMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
public static class SafeErasureMatcher<T extends TypeDefinition>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to the raw type of the matched element. */
|
||||
private final ElementMatcher<? super TypeDescription> matcher;
|
||||
|
||||
/**
|
||||
* Creates a new erasure matcher.
|
||||
*
|
||||
* @param matcher The matcher to apply to the raw type.
|
||||
*/
|
||||
public SafeErasureMatcher(final ElementMatcher<? super TypeDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final TypeDescription erasure = safeAsErasure(target);
|
||||
if (erasure == null) {
|
||||
return false;
|
||||
} else {
|
||||
// We would like matcher exceptions to propagate
|
||||
return matcher.matches(erasure);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeErasure(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A fail-safe matcher catches exceptions that are thrown by a delegate matcher and returns an
|
||||
* alternative value.
|
||||
*
|
||||
* <p>Logs exception if it was thrown.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.FailSafeMatcher
|
||||
*/
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
public static class SafeMatcher<T> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The delegate matcher that might throw an exception. */
|
||||
private final ElementMatcher<? super T> matcher;
|
||||
|
||||
/** The fallback value in case of an exception. */
|
||||
private final boolean fallback;
|
||||
|
||||
/** The text description to log if exception happens. */
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Creates a new fail-safe element matcher.
|
||||
*
|
||||
* @param matcher The delegate matcher that might throw an exception.
|
||||
* @param fallback The fallback value in case of an exception.
|
||||
* @param description Descriptive string to log along with exception.
|
||||
*/
|
||||
public SafeMatcher(
|
||||
final ElementMatcher<? super T> matcher, final boolean fallback, final String description) {
|
||||
this.matcher = matcher;
|
||||
this.fallback = fallback;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
try {
|
||||
return matcher.matches(target);
|
||||
} catch (final Exception e) {
|
||||
log.debug(description, e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeMatcher(try(" + matcher + ") or " + fallback + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private static String safeTypeDefinitionName(final TypeDefinition td) {
|
||||
try {
|
||||
return td.getTypeName();
|
||||
} catch (final IllegalStateException ex) {
|
||||
final String message = ex.getMessage();
|
||||
if (message.startsWith("Cannot resolve type description for ")) {
|
||||
return message.replace("Cannot resolve type description for ", "");
|
||||
} else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: add javadoc
|
||||
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasSuperMethod(
|
||||
final ElementMatcher<? super MethodDescription> matcher) {
|
||||
return new HasSuperMethodMatcher<>(matcher);
|
||||
}
|
||||
|
||||
// TODO: add javadoc
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
public static class HasSuperMethodMatcher<T extends MethodDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super MethodDescription> matcher;
|
||||
|
||||
public HasSuperMethodMatcher(final ElementMatcher<? super MethodDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final MethodDescription target) {
|
||||
if (target.isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
final Junction<MethodDescription> signatureMatcher = hasSignature(target.asSignatureToken());
|
||||
TypeDefinition declaringType = target.getDeclaringType();
|
||||
final Set<TypeDefinition> checkedInterfaces = new HashSet<>();
|
||||
|
||||
while (declaringType != null) {
|
||||
for (final MethodDescription methodDescription : declaringType.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(declaringType.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
declaringType = safeGetSuperClass(declaringType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesInterface(
|
||||
final TypeList.Generic interfaces,
|
||||
final Junction<MethodDescription> signatureMatcher,
|
||||
final Set<TypeDefinition> checkedInterfaces) {
|
||||
for (final TypeDefinition type : interfaces) {
|
||||
if (!checkedInterfaces.contains(type)) {
|
||||
checkedInterfaces.add(type);
|
||||
for (final MethodDescription methodDescription : type.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(type.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hasSuperMethodMatcher(" + matcher + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private static TypeDefinition safeGetSuperClass(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.getSuperClass();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get super class for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SafeExtendsClassMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
public SafeExtendsClassMatcher(final ElementMatcher<? super TypeDescription.Generic> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (matcher.matches(typeDefinition.asGenericType())) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.failSafe;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.failSafe;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.DDTransformers;
|
||||
import datadog.trace.agent.tooling.bytebuddy.ExceptionHandlers;
|
||||
import datadog.trace.agent.tooling.context.FieldBackedProvider;
|
||||
import datadog.trace.agent.tooling.context.InstrumentationContextProvider;
|
||||
import datadog.trace.agent.tooling.context.NoopContextProvider;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
package datadog.trace.agent.tooling.bytebuddy;
|
||||
|
||||
import static net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
package datadog.trace.agent.tooling.bytebuddy;
|
||||
|
||||
import datadog.trace.agent.tooling.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
package datadog.trace.agent.tooling.bytebuddy;
|
||||
|
||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||
import net.bytebuddy.asm.TypeConstantAdjustment;
|
||||
|
@ -12,10 +12,10 @@ public class DDTransformers {
|
|||
new AgentBuilder.Transformer() {
|
||||
@Override
|
||||
public DynamicType.Builder<?> transform(
|
||||
DynamicType.Builder<?> builder,
|
||||
TypeDescription typeDescription,
|
||||
ClassLoader classLoader,
|
||||
JavaModule javaModule) {
|
||||
final DynamicType.Builder<?> builder,
|
||||
final TypeDescription typeDescription,
|
||||
final ClassLoader classLoader,
|
||||
final JavaModule javaModule) {
|
||||
return builder.visit(TypeConstantAdjustment.INSTANCE);
|
||||
}
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
package datadog.trace.agent.tooling;
|
||||
package datadog.trace.agent.tooling.bytebuddy;
|
||||
|
||||
import datadog.trace.bootstrap.ExceptionLogger;
|
||||
import net.bytebuddy.ClassFileVersion;
|
|
@ -0,0 +1,127 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
public class GlobalIgnoresMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private static final Pattern COM_MCHANGE_PROXY =
|
||||
Pattern.compile("com\\.mchange\\.v2\\.c3p0\\..*Proxy");
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> globalIgnoresMatcher() {
|
||||
return new GlobalIgnoresMatcher<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Be very careful about the types of matchers used in this section as they are called on every
|
||||
* class load, so they must be fast. Generally speaking try to only use name matchers as they
|
||||
* don't have to load additional info.
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final String name = target.getActualName();
|
||||
|
||||
if (name.startsWith("datadog.opentracing.")
|
||||
|| name.startsWith("datadog.slf4j.")
|
||||
|| name.startsWith("net.bytebuddy.")
|
||||
|| name.startsWith("jdk.")
|
||||
|| name.startsWith("org.aspectj.")
|
||||
|| name.startsWith("org.groovy.")
|
||||
|| name.startsWith("org.codehaus.groovy.macro.")
|
||||
|| name.startsWith("com.intellij.rt.debugger.")
|
||||
|| name.startsWith("com.p6spy.")
|
||||
|| name.startsWith("com.newrelic.")
|
||||
|| name.startsWith("com.dynatrace.")
|
||||
|| name.startsWith("com.jloadtrace.")
|
||||
|| name.startsWith("com.appdynamics.")
|
||||
|| name.startsWith("com.singularity.")
|
||||
|| name.startsWith("com.jinspired.")
|
||||
|| name.startsWith("org.jinspired.")
|
||||
|| name.startsWith("org.springframework.cglib.")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("datadog.trace.")) {
|
||||
// FIXME: We should remove this once
|
||||
// https://github.com/raphw/byte-buddy/issues/558 is fixed
|
||||
if (name.equals("datadog.trace.bootstrap.instrumentation.java.concurrent.RunnableWrapper")
|
||||
|| name.equals(
|
||||
"datadog.trace.bootstrap.instrumentation.java.concurrent.CallableWrapper")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("java.")) {
|
||||
if (name.equals("java.net.URL") || name.equals("java.net.HttpURLConnection")) {
|
||||
return false;
|
||||
}
|
||||
if (name.startsWith("java.rmi.") || name.startsWith("java.util.concurrent.")) {
|
||||
return false;
|
||||
}
|
||||
// Concurrent instrumentation modifies the structure of
|
||||
// Cleaner class incompatibly with java9+ modules.
|
||||
// Working around until a long-term fix for modules can be
|
||||
// put in place.
|
||||
if (name.startsWith("java.util.logging.")
|
||||
&& !name.equals("java.util.logging.LogManager$Cleaner")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("com.sun.")) {
|
||||
if (name.startsWith("com.sun.messaging.") || name.startsWith("com.sun.jersey.api.client")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("sun.")) {
|
||||
if (name.startsWith("sun.net.www.protocol.")
|
||||
|| name.startsWith("sun.rmi.server")
|
||||
|| name.startsWith("sun.rmi.transport")
|
||||
|| name.equals("sun.net.www.http.HttpClient")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("org.apache.log4j.")) {
|
||||
if (name.equals("org.apache.log4j.MDC")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.startsWith("org.slf4j.")) {
|
||||
if (name.equals("org.slf4j.MDC")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (name.contains("$JaxbAccessor")
|
||||
|| name.contains("CGLIB$$")
|
||||
|| name.contains("javassist")
|
||||
|| name.contains(".asm.")
|
||||
|| name.contains("$__sisu")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (COM_MCHANGE_PROXY.matcher(name).matches()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
/**
|
||||
* This class provides some custom ByteBuddy element matchers to use when applying instrumentation
|
||||
*/
|
||||
@Slf4j
|
||||
public class DDElementMatchers {
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> extendsClass(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeExtendsClassMatcher<>(new SafeErasureMatcher<>(matcher));
|
||||
}
|
||||
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> hasInterface(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches any type description that declares a super type that matches the provided matcher.
|
||||
* Exceptions during matching process are logged and ignored.
|
||||
*
|
||||
* @param matcher The type to be checked for being a super type of the matched type.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that matches any type description that declares a super type that matches the
|
||||
* provided matcher.
|
||||
* @see ElementMatchers#hasSuperType(net.bytebuddy.matcher.ElementMatcher)
|
||||
*/
|
||||
public static <T extends TypeDescription> ElementMatcher.Junction<T> safeHasSuperType(
|
||||
final ElementMatcher<? super TypeDescription> matcher) {
|
||||
return new SafeHasSuperTypeMatcher<>(new SafeErasureMatcher<>(matcher), false);
|
||||
}
|
||||
// TODO: add javadoc
|
||||
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasSuperMethod(
|
||||
final ElementMatcher<? super MethodDescription> matcher) {
|
||||
return new HasSuperMethodMatcher<>(matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps another matcher to assure that an element is not matched in case that the matching causes
|
||||
* an {@link Exception}. Logs exception if it happens.
|
||||
*
|
||||
* @param matcher The element matcher that potentially throws an exception.
|
||||
* @param <T> The type of the matched object.
|
||||
* @return A matcher that returns {@code false} in case that the given matcher throws an
|
||||
* exception.
|
||||
*/
|
||||
public static <T> ElementMatcher.Junction<T> failSafe(
|
||||
final ElementMatcher<? super T> matcher, final String description) {
|
||||
return new LoggingFailSafeMatcher<>(matcher, false, description);
|
||||
}
|
||||
|
||||
static String safeTypeDefinitionName(final TypeDefinition td) {
|
||||
try {
|
||||
return td.getTypeName();
|
||||
} catch (final IllegalStateException ex) {
|
||||
final String message = ex.getMessage();
|
||||
if (message.startsWith("Cannot resolve type description for ")) {
|
||||
return message.replace("Cannot resolve type description for ", "");
|
||||
} else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.SafeHasSuperTypeMatcher.safeGetSuperClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.hasSignature;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeList;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
// TODO: add javadoc
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class HasSuperMethodMatcher<T extends MethodDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super MethodDescription> matcher;
|
||||
|
||||
public HasSuperMethodMatcher(final ElementMatcher<? super MethodDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final MethodDescription target) {
|
||||
if (target.isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
final Junction<MethodDescription> signatureMatcher = hasSignature(target.asSignatureToken());
|
||||
TypeDefinition declaringType = target.getDeclaringType();
|
||||
final Set<TypeDefinition> checkedInterfaces = new HashSet<>();
|
||||
|
||||
while (declaringType != null) {
|
||||
for (final MethodDescription methodDescription : declaringType.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(declaringType.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
declaringType = safeGetSuperClass(declaringType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean matchesInterface(
|
||||
final TypeList.Generic interfaces,
|
||||
final Junction<MethodDescription> signatureMatcher,
|
||||
final Set<TypeDefinition> checkedInterfaces) {
|
||||
for (final TypeDefinition type : interfaces) {
|
||||
if (!checkedInterfaces.contains(type)) {
|
||||
checkedInterfaces.add(type);
|
||||
for (final MethodDescription methodDescription : type.getDeclaredMethods()) {
|
||||
if (signatureMatcher.matches(methodDescription) && matcher.matches(methodDescription)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (matchesInterface(type.getInterfaces(), signatureMatcher, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "hasSuperMethodMatcher(" + matcher + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* A fail-safe matcher catches exceptions that are thrown by a delegate matcher and returns an
|
||||
* alternative value.
|
||||
*
|
||||
* <p>Logs exception if it was thrown.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.FailSafeMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class LoggingFailSafeMatcher<T> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The delegate matcher that might throw an exception. */
|
||||
private final ElementMatcher<? super T> matcher;
|
||||
|
||||
/** The fallback value in case of an exception. */
|
||||
private final boolean fallback;
|
||||
|
||||
/** The text description to log if exception happens. */
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* Creates a new fail-safe element matcher.
|
||||
*
|
||||
* @param matcher The delegate matcher that might throw an exception.
|
||||
* @param fallback The fallback value in case of an exception.
|
||||
* @param description Descriptive string to log along with exception.
|
||||
*/
|
||||
public LoggingFailSafeMatcher(
|
||||
final ElementMatcher<? super T> matcher, final boolean fallback, final String description) {
|
||||
this.matcher = matcher;
|
||||
this.fallback = fallback;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
try {
|
||||
return matcher.matches(target);
|
||||
} catch (final Exception e) {
|
||||
log.debug(description, e);
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeMatcher(try(" + matcher + ") or " + fallback + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeTypeDefinitionName;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* An element matcher that matches its argument's {@link TypeDescription.Generic} raw type against
|
||||
* the given matcher for a {@link TypeDescription}. As a wildcard does not define an erasure, a
|
||||
* runtime exception is thrown when this matcher is applied to a wildcard.
|
||||
*
|
||||
* <p>Catches and logs exception if it was thrown when getting erasure, returning false.
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.ErasureMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class SafeErasureMatcher<T extends TypeDefinition> extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to the raw type of the matched element. */
|
||||
private final ElementMatcher<? super TypeDescription> matcher;
|
||||
|
||||
/**
|
||||
* Creates a new erasure matcher.
|
||||
*
|
||||
* @param matcher The matcher to apply to the raw type.
|
||||
*/
|
||||
public SafeErasureMatcher(final ElementMatcher<? super TypeDescription> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final TypeDescription erasure = safeAsErasure(target);
|
||||
if (erasure == null) {
|
||||
return false;
|
||||
} else {
|
||||
// We would like matcher exceptions to propagate
|
||||
return matcher.matches(erasure);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeErasure(" + matcher + ")";
|
||||
}
|
||||
|
||||
static TypeDescription safeAsErasure(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.asErasure();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get erasure for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.SafeHasSuperTypeMatcher.safeGetSuperClass;
|
||||
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
class SafeExtendsClassMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
public SafeExtendsClassMatcher(final ElementMatcher<? super TypeDescription.Generic> matcher) {
|
||||
this.matcher = matcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (matcher.matches(typeDefinition.asGenericType())) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher;
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeTypeDefinitionName;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.SafeErasureMatcher.safeAsErasure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.bytebuddy.build.HashCodeAndEqualsPlugin;
|
||||
import net.bytebuddy.description.type.TypeDefinition;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
|
||||
/**
|
||||
* An element matcher that matches a super type. This is different from {@link
|
||||
* net.bytebuddy.matcher.HasSuperTypeMatcher} in the following way:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Exceptions are logged
|
||||
* <li>When exception happens the rest of the inheritance subtree is discarded (since ByteBuddy
|
||||
* cannot load/parse type information for it) but search in other subtrees continues
|
||||
* </ul>
|
||||
*
|
||||
* <p>This is useful because this allows us to see when matcher's check is not complete (i.e. part
|
||||
* of it fails), at the same time it makes best effort instead of failing quickly (like {@code
|
||||
* failSafe(hasSuperType(...))} does) which means the code is more resilient to classpath
|
||||
* inconsistencies
|
||||
*
|
||||
* @param <T> The type of the matched entity.
|
||||
* @see net.bytebuddy.matcher.HasSuperTypeMatcher
|
||||
*/
|
||||
@Slf4j
|
||||
@HashCodeAndEqualsPlugin.Enhance
|
||||
class SafeHasSuperTypeMatcher<T extends TypeDescription>
|
||||
extends ElementMatcher.Junction.AbstractBase<T> {
|
||||
|
||||
/** The matcher to apply to any super type of the matched type. */
|
||||
private final ElementMatcher<? super TypeDescription.Generic> matcher;
|
||||
|
||||
private final boolean interfacesOnly;
|
||||
/**
|
||||
* Creates a new matcher for a super type.
|
||||
*
|
||||
* @param matcher The matcher to apply to any super type of the matched type.
|
||||
*/
|
||||
public SafeHasSuperTypeMatcher(
|
||||
final ElementMatcher<? super TypeDescription.Generic> matcher, final boolean interfacesOnly) {
|
||||
this.matcher = matcher;
|
||||
this.interfacesOnly = interfacesOnly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final T target) {
|
||||
final Set<TypeDescription> checkedInterfaces = new HashSet<>();
|
||||
// We do not use foreach loop and iterator interface here because we need to catch exceptions
|
||||
// in {@code getSuperClass} calls
|
||||
TypeDefinition typeDefinition = target;
|
||||
while (typeDefinition != null) {
|
||||
if (((!interfacesOnly || typeDefinition.isInterface())
|
||||
&& matcher.matches(typeDefinition.asGenericType()))
|
||||
|| hasInterface(typeDefinition, checkedInterfaces)) {
|
||||
return true;
|
||||
}
|
||||
typeDefinition = safeGetSuperClass(typeDefinition);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a type's interfaces against the provided matcher.
|
||||
*
|
||||
* @param typeDefinition The type for which to check all implemented interfaces.
|
||||
* @param checkedInterfaces The interfaces that have already been checked.
|
||||
* @return {@code true} if any interface matches the supplied matcher.
|
||||
*/
|
||||
private boolean hasInterface(
|
||||
final TypeDefinition typeDefinition, final Set<TypeDescription> checkedInterfaces) {
|
||||
for (final TypeDefinition interfaceType : safeGetInterfaces(typeDefinition)) {
|
||||
final TypeDescription erasure = safeAsErasure(interfaceType);
|
||||
if (erasure != null) {
|
||||
if (checkedInterfaces.add(interfaceType.asErasure())
|
||||
&& (matcher.matches(interfaceType.asGenericType())
|
||||
|| hasInterface(interfaceType, checkedInterfaces))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* TypeDefinition#getInterfaces() produces an interator which may throw an exception during
|
||||
* iteration if an interface is absent from the classpath.
|
||||
*
|
||||
* <p>This method exists to allow getting interfaces even if the lookup on one fails.
|
||||
*/
|
||||
private List<TypeDefinition> safeGetInterfaces(final TypeDefinition typeDefinition) {
|
||||
final List<TypeDefinition> interfaceTypes = new ArrayList<>();
|
||||
try {
|
||||
final Iterator<TypeDescription.Generic> interfaceIter =
|
||||
typeDefinition.getInterfaces().iterator();
|
||||
while (interfaceIter.hasNext()) {
|
||||
interfaceTypes.add(interfaceIter.next());
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get interfaces for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
}
|
||||
return interfaceTypes;
|
||||
}
|
||||
|
||||
static TypeDefinition safeGetSuperClass(final TypeDefinition typeDefinition) {
|
||||
try {
|
||||
return typeDefinition.getSuperClass();
|
||||
} catch (final Exception e) {
|
||||
log.debug(
|
||||
"{} trying to get super class for target {}: {}",
|
||||
e.getClass().getSimpleName(),
|
||||
safeTypeDefinitionName(typeDefinition),
|
||||
e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "safeHasSuperType(" + matcher + ")";
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package datadog.trace.agent.tooling.context;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
|
|
@ -3,7 +3,7 @@ package datadog.trace.agent.test
|
|||
import ch.qos.logback.classic.Level
|
||||
import ch.qos.logback.classic.Logger
|
||||
import ch.qos.logback.core.read.ListAppender
|
||||
import datadog.trace.agent.tooling.ExceptionHandlers
|
||||
import datadog.trace.agent.tooling.bytebuddy.ExceptionHandlers
|
||||
import datadog.trace.bootstrap.ExceptionLogger
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.agent.ByteBuddyAgent
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.agent.test
|
||||
|
||||
import datadog.trace.agent.tooling.DDLocationStrategy
|
||||
import datadog.trace.agent.tooling.bytebuddy.DDLocationStrategy
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.agent.builder.AgentBuilder
|
||||
import spock.lang.Shared
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package datadog.trace.agent.tooling
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.DDCachingPoolStrategy
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
import net.bytebuddy.dynamic.ClassFileLocator
|
||||
|
@ -204,7 +205,7 @@ class CacheProviderTest extends DDSpecification {
|
|||
}
|
||||
|
||||
static newClassLoader() {
|
||||
return new URLClassLoader([] as URL[], (ClassLoader)null)
|
||||
return new URLClassLoader([] as URL[], (ClassLoader) null)
|
||||
}
|
||||
|
||||
static newLocator() {
|
||||
|
@ -215,7 +216,8 @@ class CacheProviderTest extends DDSpecification {
|
|||
}
|
||||
|
||||
@Override
|
||||
void close() throws IOException {}
|
||||
void close() throws IOException {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.A
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.B
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.C
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.F
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.G
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.TracedClass
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.UntracedClass
|
||||
import datadog.trace.api.Trace
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.description.method.MethodDescription
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasSuperMethod
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith
|
||||
import static net.bytebuddy.matcher.ElementMatchers.none
|
||||
|
||||
class HasSuperMethodMatcherTest extends DDSpecification {
|
||||
|
||||
def "test matcher #type.simpleName #method"() {
|
||||
expect:
|
||||
hasSuperMethod(isAnnotatedWith(Trace)).matches(argument) == result
|
||||
|
||||
where:
|
||||
type | method | result
|
||||
A | "a" | false
|
||||
B | "b" | true
|
||||
C | "c" | false
|
||||
F | "f" | true
|
||||
G | "g" | false
|
||||
TracedClass | "a" | true
|
||||
UntracedClass | "a" | false
|
||||
UntracedClass | "b" | true
|
||||
|
||||
argument = new MethodDescription.ForLoadedMethod(type.getDeclaredMethod(method))
|
||||
}
|
||||
|
||||
def "test constructor never matches"() {
|
||||
setup:
|
||||
def method = Mock(MethodDescription)
|
||||
def matcher = hasSuperMethod(none())
|
||||
|
||||
when:
|
||||
def result = matcher.matches(method)
|
||||
|
||||
then:
|
||||
!result
|
||||
1 * method.isConstructor() >> true
|
||||
0 * _
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def method = Mock(MethodDescription)
|
||||
def matcher = hasSuperMethod(none())
|
||||
def sigToken = new MethodDescription.ForLoadedMethod(A.getDeclaredMethod("a")).asSignatureToken()
|
||||
|
||||
when:
|
||||
def result = matcher.matches(method)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
1 * method.isConstructor() >> false
|
||||
1 * method.asSignatureToken() >> sigToken
|
||||
1 * method.getDeclaringType() >> null
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.A
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.B
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.F
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.G
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeExtendsClassMatcherTest extends DDSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
extendsClass(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | B | false
|
||||
A | F | false
|
||||
G | F | false
|
||||
F | F | true
|
||||
F | G | true
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = extendsClass(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * type.getTypeName() >> "type-name"
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.A
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.B
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.E
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.F
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.G
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeHasInterfaceMatcherTest extends DDSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
hasInterface(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | A | true
|
||||
A | B | true
|
||||
B | A | false
|
||||
A | E | true
|
||||
A | F | true
|
||||
F | A | false
|
||||
F | F | false
|
||||
F | G | false
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = hasInterface(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.isInterface() >> true
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getInterfaces() >> { throw new Exception("getInterfaces exception") }
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
2 * type.getTypeName() >> "type-name"
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher
|
||||
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.A
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.B
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.E
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.F
|
||||
import datadog.trace.agent.tooling.bytebuddy.matcher.testclasses.G
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.description.type.TypeDescription
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named
|
||||
|
||||
class SafeHasSuperTypeMatcherTest extends DDSpecification {
|
||||
|
||||
def "test matcher #matcherClass.simpleName -> #type.simpleName"() {
|
||||
expect:
|
||||
safeHasSuperType(matcher).matches(argument) == result
|
||||
|
||||
where:
|
||||
matcherClass | type | result
|
||||
A | A | true
|
||||
A | B | true
|
||||
B | A | false
|
||||
A | E | true
|
||||
A | F | true
|
||||
F | A | false
|
||||
F | F | true
|
||||
F | G | true
|
||||
|
||||
matcher = named(matcherClass.name)
|
||||
argument = TypeDescription.ForLoadedType.of(type)
|
||||
}
|
||||
|
||||
def "test traversal exceptions"() {
|
||||
setup:
|
||||
def type = Mock(TypeDescription)
|
||||
def typeGeneric = Mock(TypeDescription.Generic)
|
||||
def matcher = safeHasSuperType(named(Object.name))
|
||||
|
||||
when:
|
||||
def result = matcher.matches(type)
|
||||
|
||||
then:
|
||||
!result // default to false
|
||||
noExceptionThrown()
|
||||
1 * type.asGenericType() >> typeGeneric
|
||||
1 * typeGeneric.asErasure() >> { throw new Exception("asErasure exception") }
|
||||
1 * typeGeneric.getTypeName() >> "typeGeneric-name"
|
||||
1 * type.getInterfaces() >> { throw new Exception("getInterfaces exception") }
|
||||
1 * type.getSuperClass() >> { throw new Exception("getSuperClass exception") }
|
||||
2 * type.getTypeName() >> "type-name"
|
||||
0 * _
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher
|
||||
|
||||
import datadog.trace.util.test.DDSpecification
|
||||
import net.bytebuddy.matcher.ElementMatcher
|
||||
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.failSafe
|
||||
|
||||
class SafeMatcherTest extends DDSpecification {
|
||||
|
||||
def mockMatcher = Mock(ElementMatcher)
|
||||
|
||||
def "test matcher"() {
|
||||
setup:
|
||||
def matcher = failSafe(mockMatcher, "test")
|
||||
|
||||
when:
|
||||
def result = matcher.matches(new Object())
|
||||
|
||||
then:
|
||||
1 * mockMatcher.matches(_) >> match
|
||||
result == match
|
||||
|
||||
where:
|
||||
match << [true, false]
|
||||
}
|
||||
|
||||
def "test matcher exception"() {
|
||||
setup:
|
||||
def matcher = failSafe(mockMatcher, "test")
|
||||
|
||||
when:
|
||||
def result = matcher.matches(new Object())
|
||||
|
||||
then:
|
||||
1 * mockMatcher.matches(_) >> { throw new Exception("matcher exception") }
|
||||
0 * _
|
||||
noExceptionThrown()
|
||||
!result // default to false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface A {
|
||||
void a();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
import datadog.trace.api.Trace;
|
||||
|
||||
public interface B extends A {
|
||||
@Trace
|
||||
void b();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface C extends A, B {
|
||||
void c();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
import datadog.trace.api.Trace;
|
||||
|
||||
public interface D extends A, B, C {
|
||||
@Trace
|
||||
void d();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public interface E extends B, C, D {
|
||||
void e();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
import datadog.trace.api.Trace;
|
||||
|
||||
public abstract class F implements E {
|
||||
@Trace
|
||||
public abstract void f();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public abstract class G extends F {
|
||||
public void g() {}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
import datadog.trace.api.Trace;
|
||||
|
||||
public class TracedClass extends UntracedClass {
|
||||
@Trace
|
||||
@Override
|
||||
public void g() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void f() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void e() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void d() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void c() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void b() {}
|
||||
|
||||
@Trace
|
||||
@Override
|
||||
public void a() {}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package datadog.trace.agent.tooling.bytebuddy.matcher.testclasses;
|
||||
|
||||
public class UntracedClass extends G {
|
||||
@Override
|
||||
public void g() {}
|
||||
|
||||
@Override
|
||||
public void f() {}
|
||||
|
||||
@Override
|
||||
public void e() {}
|
||||
|
||||
@Override
|
||||
public void d() {}
|
||||
|
||||
@Override
|
||||
public void c() {}
|
||||
|
||||
@Override
|
||||
public void b() {}
|
||||
|
||||
@Override
|
||||
public void a() {}
|
||||
}
|
|
@ -6,68 +6,44 @@ apply from: "${rootDir}/gradle/java.gradle"
|
|||
|
||||
dependencies {
|
||||
jmh project(':dd-trace-api')
|
||||
jmh group: 'net.bytebuddy', name: 'byte-buddy-agent', version: '1.7.6'
|
||||
|
||||
// Add a bunch of dependencies so instrumentation is not disabled.
|
||||
jmh group: 'javax.jms', name: 'javax.jms-api', version: '2.0.1'
|
||||
jmh group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
|
||||
jmh group: 'org.mongodb', name: 'mongo-java-driver', version: '3.4.2'
|
||||
jmh group: 'org.mongodb', name: 'mongodb-driver-async', version: '3.4.2'
|
||||
jmh(group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.119') {
|
||||
exclude(module: 'httpclient')
|
||||
exclude(module: 'jackson-databind')
|
||||
exclude(module: 'jackson-dataformat-cbor')
|
||||
}
|
||||
jmh group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.6.0'
|
||||
jmh group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'
|
||||
jmh(group: 'com.datastax.cassandra', name: 'cassandra-driver-core', version: '3.2.0')
|
||||
jmh deps.bytebuddyagent
|
||||
}
|
||||
|
||||
configurations.testRuntimeClasspath.dependencies.clear()
|
||||
|
||||
|
||||
jmh {
|
||||
timeUnit = 'us' // Output time unit. Available time units are: [m, s, ms, us, ns].
|
||||
benchmarkMode = ['thrpt', 'avgt']
|
||||
// timeOnIteration = '5s'
|
||||
iterations = 5 // Number of measurement iterations to do.
|
||||
benchmarkMode = ['avgt']
|
||||
timeOnIteration = '20s'
|
||||
iterations = 1 // Number of measurement iterations to do.
|
||||
fork = 1 // How many times to forks a single benchmark. Use 0 to disable forking altogether
|
||||
// jvmArgs = ["-Dasdf=123"]
|
||||
// jvmArgs = ["-javaagent:${project(':dd-java-agent').shadowJar.archivePath}"]
|
||||
jvmArgs = ["-Ddd.jmxfetch.enabled=false", "-Ddd.writer.type=LoggingWriter"]
|
||||
// jvmArgs += ["-XX:+UnlockDiagnosticVMOptions", "-XX:+DebugNonSafepoints", "-XX:StartFlightRecording=delay=5s,dumponexit=true,name=jmh-benchmark,filename=${rootDir}/dd-java-agent/benchmark/build/reports/jmh/jmh-benchmark.jfr"]
|
||||
// jvmArgs += ["-agentpath:${rootDir}/dd-java-agent/benchmark/src/jmh/resources/libasyncProfiler.so=start,collapsed,file=${rootDir}/dd-java-agent/benchmark/build/reports/jmh/profiler.txt"]
|
||||
failOnError = true // Should JMH fail immediately if any benchmark had experienced the unrecoverable error?
|
||||
// warmup = '2s' // Time to spend at each warmup iteration.
|
||||
// warmupIterations = 2 // Number of warmup iterations to do.
|
||||
// warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
|
||||
warmup = '5s' // Time to spend at each warmup iteration.
|
||||
// warmupBatchSize = 10 // Warmup batch size: number of benchmark method calls per operation.
|
||||
warmupForks = 0 // How many warmup forks to make for a single benchmark. 0 to disable warmup forks.
|
||||
warmupIterations = 1 // Number of warmup iterations to do.
|
||||
|
||||
// profilers = ['stack']
|
||||
// profilers = ['stack:lines=5;detailLine=true;period=5;excludePackages=true']
|
||||
// Use profilers to collect additional data. Supported profilers: [cl, comp, gc, stack, perf, perfnorm, perfasm, xperf, xperfasm, hs_cl, hs_comp, hs_gc, hs_rt, hs_thr]
|
||||
|
||||
// humanOutputFile = project.file("${project.buildDir}/reports/jmh/human.txt") // human-readable output file
|
||||
// operationsPerInvocation = 10 // Operations per invocation.
|
||||
// synchronizeIterations = false // Synchronize iterations?
|
||||
timeout = '1s' // Timeout for benchmark iteration.
|
||||
includeTests = false
|
||||
timeout = '5s' // Timeout for benchmark iteration.
|
||||
// includeTests = false
|
||||
// Allows to include test sources into generate JMH jar, i.e. use it when benchmarks depend on the test classes.
|
||||
|
||||
duplicateClassesStrategy = 'fail'
|
||||
jmhVersion = '1.20' // Specifies JMH version
|
||||
duplicateClassesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
jmhVersion = '1.23' // Specifies JMH version
|
||||
}
|
||||
|
||||
// configured as a separate task since the 'jmh' task did not like adding a javaagent argument.
|
||||
tasks.register("jmhAgent", JavaExec) {
|
||||
classpath = files(project.jmhCompileGeneratedClasses.destinationDir)
|
||||
classpath += sourceSets.jmh.runtimeClasspath
|
||||
main = "org.openjdk.jmh.Main"
|
||||
args += ["-tu", "us"]
|
||||
args += ["-bm", "avgt"]
|
||||
// args += ["-prof", "stack:lines=5;detailLine=true;period=5;excludePackages=true"]
|
||||
args += ["-f", "1"]
|
||||
args += ["-foe", "true"]
|
||||
tasks.jmh.dependsOn project(':dd-java-agent').shadowJar
|
||||
|
||||
// args += ["-wi", "2"]
|
||||
// args += ["-i", "5"]
|
||||
dependsOn project.tasks.jmhCompileGeneratedClasses
|
||||
}
|
||||
|
||||
tasks.jmhAgent.dependsOn project(':dd-java-agent').shadowJar
|
||||
/*
|
||||
If using libasyncProfiler, use the following to generate nice svg flamegraphs.
|
||||
sed '/unknown/d' dd-java-agent/benchmark/build/reports/jmh/profiler.txt | sed '/^thread_start/d' | sed '/not_walkable/d' > dd-java-agent/benchmark/build/reports/jmh/profiler-cleaned.txt
|
||||
(using https://github.com/brendangregg/FlameGraph)
|
||||
./flamegraph.pl --color=java dd-java-agent/benchmark/build/reports/jmh/profiler-cleaned.txt > dd-java-agent/benchmark/build/reports/jmh/jmh-master.svg
|
||||
*/
|
||||
|
||||
|
|
|
@ -4,49 +4,17 @@ import datadog.benchmark.classes.TracedClass;
|
|||
import datadog.benchmark.classes.UntracedClass;
|
||||
import java.lang.instrument.Instrumentation;
|
||||
import java.lang.instrument.UnmodifiableClassException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Paths;
|
||||
import net.bytebuddy.agent.ByteBuddyAgent;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.Fork;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.TearDown;
|
||||
|
||||
public class ClassRetransformingBenchmark {
|
||||
public static final String BENCHMARK_HOME =
|
||||
Paths.get(".").toAbsolutePath().normalize().toString();
|
||||
|
||||
static {
|
||||
if (!BENCHMARK_HOME.endsWith("benchmark")) {
|
||||
throw new IllegalArgumentException("Invalid Home directory: " + BENCHMARK_HOME);
|
||||
}
|
||||
}
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public static class BenchmarkState {
|
||||
private final Instrumentation inst = ByteBuddyAgent.install();
|
||||
|
||||
@Setup
|
||||
public void initializeInstrumentation() {
|
||||
// loading TracedClass will initialize helper injection
|
||||
TracedClass.class.getName();
|
||||
}
|
||||
|
||||
@TearDown
|
||||
public void stopAgent() {
|
||||
try {
|
||||
final Class<?> gt = Class.forName("io.opentracing.util.GlobalTracer");
|
||||
final Field tracerField = gt.getDeclaredField("tracer");
|
||||
tracerField.setAccessible(true);
|
||||
final Object tracer = tracerField.get(null);
|
||||
final Method close = tracer.getClass().getMethod("close");
|
||||
close.invoke(tracer);
|
||||
} catch (final Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
|
@ -60,54 +28,11 @@ public class ClassRetransformingBenchmark {
|
|||
state.inst.retransformClasses(TracedClass.class);
|
||||
}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.2.jar")
|
||||
public static class WithAgent022 extends ClassRetransformingBenchmark {}
|
||||
@Fork(jvmArgsAppend = "-javaagent:/path/to/dd-java-agent-master.jar")
|
||||
public static class WithAgentMaster extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.4.jar")
|
||||
public static class WithAgent024 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.6.jar")
|
||||
public static class WithAgent026 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.7.jar")
|
||||
public static class WithAgent027 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.8.jar")
|
||||
public static class WithAgent028 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.9.jar")
|
||||
public static class WithAgent029 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.10.jar")
|
||||
public static class WithAgent0210 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.11.jar")
|
||||
public static class WithAgent0211 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.2.12.jar")
|
||||
public static class WithAgent0212 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.3.0.jar")
|
||||
public static class WithAgent030 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.3.1.jar")
|
||||
public static class WithAgent031 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.3.2.jar")
|
||||
public static class WithAgent032 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.3.3.jar")
|
||||
public static class WithAgent033 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.4.0.jar")
|
||||
public static class WithAgent040 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.4.1.jar")
|
||||
public static class WithAgent041 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:releases/dd-java-agent-0.5.0.jar")
|
||||
public static class WithAgent050 extends ClassRetransformingBenchmark {}
|
||||
|
||||
@Fork(jvmArgsAppend = "-javaagent:../build/libs/dd-java-agent.jar")
|
||||
@Fork(
|
||||
jvmArgsAppend =
|
||||
"-javaagent:/path/to/dd-trace-java/dd-java-agent/build/libs/dd-java-agent.jar")
|
||||
public static class WithAgent extends ClassRetransformingBenchmark {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package datadog.benchmark.classes;
|
||||
|
||||
public interface C extends B {
|
||||
public interface C extends A, B {
|
||||
void c();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package datadog.benchmark.classes;
|
||||
|
||||
public interface D extends C {
|
||||
public interface D extends A, B, C {
|
||||
void d();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package datadog.benchmark.classes;
|
||||
|
||||
public interface E extends D {
|
||||
public interface E extends B, C, D {
|
||||
void e();
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
enableCustomAnnotationTracingOver: ["datadog.benchmark"]
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.apachehttpasyncclient;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -40,7 +40,7 @@ public class ApacheHttpAsyncClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("org.apache.http.nio.client.HttpAsyncClient"));
|
||||
return hasInterface(named("org.apache.http.nio.client.HttpAsyncClient"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.apachehttpasyncclient;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -31,7 +31,7 @@ public class ApacheHttpClientRedirectInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("org.apache.http.client.RedirectStrategy"));
|
||||
return hasInterface(named("org.apache.http.client.RedirectStrategy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.apachehttpclient;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -44,7 +44,7 @@ public class ApacheHttpClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.apache.http.client.HttpClient")));
|
||||
return not(isInterface()).and(hasInterface(named("org.apache.http.client.HttpClient")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package datadog.trace.instrumentation.aws.v0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
||||
|
@ -26,7 +27,8 @@ public final class RequestInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(named("com.amazonaws.AmazonWebServiceRequest"));
|
||||
return nameStartsWith("com.amazonaws.")
|
||||
.and(extendsClass(named("com.amazonaws.AmazonWebServiceRequest")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package datadog.trace.instrumentation.aws.v2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
|
@ -23,9 +24,9 @@ public final class AwsClientInstrumentation extends AbstractAwsClientInstrumenta
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(
|
||||
safeHasInterface(named("software.amazon.awssdk.core.client.builder.SdkClientBuilder")));
|
||||
return nameStartsWith("software.amazon.awssdk.")
|
||||
.and(not(isInterface()))
|
||||
.and(hasInterface(named("software.amazon.awssdk.core.client.builder.SdkClientBuilder")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package datadog.trace.instrumentation.aws.v2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
|
@ -28,11 +29,14 @@ public final class AwsHttpClientInstrumentation extends AbstractAwsClientInstrum
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(
|
||||
named("software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage")
|
||||
.or(
|
||||
named(
|
||||
"software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage")))
|
||||
return nameStartsWith("software.amazon.awssdk.")
|
||||
.and(
|
||||
extendsClass(
|
||||
named(
|
||||
"software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage")
|
||||
.or(
|
||||
named(
|
||||
"software.amazon.awssdk.core.internal.http.pipeline.stages.MakeAsyncHttpRequestStage"))))
|
||||
.and(not(isInterface()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.classloading;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isProtected;
|
||||
|
@ -44,7 +44,7 @@ public final class ClassloadingInstrumentation extends Instrumenter.Default {
|
|||
return not(named("java.lang.ClassLoader"))
|
||||
.and(not(named("com.ibm.oti.vm.BootstrapClassLoader")))
|
||||
.and(not(named("datadog.trace.bootstrap.AgentClassLoader")))
|
||||
.and(safeExtendsClass(named("java.lang.ClassLoader")));
|
||||
.and(extendsClass(named("java.lang.ClassLoader")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -64,7 +64,7 @@ public class CouchbaseBucketInstrumentation extends Instrumenter.Default {
|
|||
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||
public static void subscribeResult(
|
||||
@Advice.Enter final int callDepth,
|
||||
@Advice.Origin final Method method,
|
||||
|
|
|
@ -64,7 +64,7 @@ public class CouchbaseClusterInstrumentation extends Instrumenter.Default {
|
|||
return CallDepthThreadLocalMap.incrementCallDepth(CouchbaseCluster.class);
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class)
|
||||
public static void subscribeResult(
|
||||
@Advice.Enter final int callDepth,
|
||||
@Advice.Origin final Method method,
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package datadog.trace.instrumentation.couchbase.client;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
||||
|
@ -31,7 +32,9 @@ public class CouchbaseNetworkInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// Exact class because private fields are used
|
||||
return safeExtendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler"));
|
||||
return nameStartsWith("com.couchbase.client.")
|
||||
.<TypeDescription>and(
|
||||
extendsClass(named("com.couchbase.client.core.endpoint.AbstractGenericHandler")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.dropwizard.view;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -34,7 +34,7 @@ public final class DropwizardViewInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.dropwizard.views.ViewRenderer")));
|
||||
return not(isInterface()).and(hasInterface(named("io.dropwizard.views.ViewRenderer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.finatra;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -8,6 +8,7 @@ import static datadog.trace.instrumentation.finatra.FinatraDecorator.DECORATE;
|
|||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
@ -51,8 +52,9 @@ public class FinatraInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeExtendsClass(named("com.twitter.finatra.http.internal.routing.Route")));
|
||||
return nameStartsWith("com.twitter.finatra.")
|
||||
.and(not(isInterface()))
|
||||
.and(extendsClass(named("com.twitter.finatra.http.internal.routing.Route")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -31,7 +31,7 @@ public class CriteriaInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -33,7 +33,7 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Query")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
@ -40,7 +40,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SessionFactory")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SessionFactory")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
returns(
|
||||
named("org.hibernate.Session")
|
||||
.or(named("org.hibernate.StatelessSession"))
|
||||
.or(safeHasInterface(named("org.hibernate.Session"))))),
|
||||
.or(hasInterface(named("org.hibernate.Session"))))),
|
||||
SessionFactoryInstrumentation.class.getName() + "$SessionFactoryAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static datadog.trace.instrumentation.hibernate.SessionMethodUtils.SCOPE_ONLY_METHODS;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -50,7 +50,7 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(
|
||||
safeHasInterface(
|
||||
hasInterface(
|
||||
named("org.hibernate.Session").or(named("org.hibernate.StatelessSession"))));
|
||||
}
|
||||
|
||||
|
@ -99,11 +99,11 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
SessionInstrumentation.class.getName() + "$GetTransactionAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Query")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Query")))),
|
||||
SessionInstrumentation.class.getName() + "$GetQueryAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Criteria")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Criteria")))),
|
||||
SessionInstrumentation.class.getName() + "$GetCriteriaAdvice");
|
||||
|
||||
return transformers;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v3_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -31,7 +31,7 @@ public class TransactionInstrumentation extends AbstractHibernateInstrumentation
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -31,7 +31,7 @@ public class CriteriaInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Criteria")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Criteria")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -33,7 +33,7 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Query")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Query")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
@ -34,7 +34,7 @@ public class SessionFactoryInstrumentation extends AbstractHibernateInstrumentat
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SessionFactory")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SessionFactory")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.instrumentation.hibernate.HibernateDecorator.DECORATOR;
|
||||
import static datadog.trace.instrumentation.hibernate.SessionMethodUtils.SCOPE_ONLY_METHODS;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -46,7 +46,7 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,11 +93,11 @@ public class SessionInstrumentation extends AbstractHibernateInstrumentation {
|
|||
SessionInstrumentation.class.getName() + "$GetTransactionAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Query")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Query")))),
|
||||
SessionInstrumentation.class.getName() + "$GetQueryAdvice");
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.Criteria")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.Criteria")))),
|
||||
SessionInstrumentation.class.getName() + "$GetCriteriaAdvice");
|
||||
|
||||
return transformers;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_0;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -31,7 +31,7 @@ public class TransactionInstrumentation extends AbstractHibernateInstrumentation
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.Transaction")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.Transaction")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -47,7 +47,7 @@ public class ProcedureCallInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.procedure.ProcedureCall")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.procedure.ProcedureCall")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hibernate.core.v4_3;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -53,7 +53,7 @@ public class SessionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
return not(isInterface()).and(hasInterface(named("org.hibernate.SharedSessionContract")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class SessionInstrumentation extends Instrumenter.Default {
|
|||
final Map<ElementMatcher<? super MethodDescription>, String> transformers = new HashMap<>();
|
||||
|
||||
transformers.put(
|
||||
isMethod().and(returns(safeHasInterface(named("org.hibernate.procedure.ProcedureCall")))),
|
||||
isMethod().and(returns(hasInterface(named("org.hibernate.procedure.ProcedureCall")))),
|
||||
SessionInstrumentation.class.getName() + "$GetProcedureCallAdvice");
|
||||
|
||||
return transformers;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.http_url_connection;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -9,6 +9,7 @@ import static datadog.trace.instrumentation.http_url_connection.HttpUrlConnectio
|
|||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
|
@ -25,6 +26,7 @@ import net.bytebuddy.asm.Advice;
|
|||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.description.type.TypeDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import net.bytebuddy.matcher.ElementMatchers;
|
||||
|
||||
@AutoService(Instrumenter.class)
|
||||
public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
||||
|
@ -35,9 +37,11 @@ public class HttpUrlConnectionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
// This class is a simple delegator. Skip because it does not update its `connected` field.
|
||||
return not(named("sun.net.www.protocol.https.HttpsURLConnectionImpl"))
|
||||
.and(safeExtendsClass(named("java.net.HttpURLConnection")));
|
||||
return nameStartsWith("java.net.")
|
||||
.or(ElementMatchers.<TypeDescription>nameStartsWith("sun.net"))
|
||||
// This class is a simple delegator. Skip because it does not update its `connected` field.
|
||||
.and(not(named("sun.net.www.protocol.https.HttpsURLConnectionImpl")))
|
||||
.and(extendsClass(named("java.net.HttpURLConnection")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,7 +3,10 @@ package datadog.trace.instrumentation.http_url_connection;
|
|||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.*;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.is;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import datadog.trace.agent.tooling.Instrumenter;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.hystrix;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.instrumentation.hystrix.HystrixDecorator.DECORATE;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -29,7 +29,7 @@ public class HystrixInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(
|
||||
return extendsClass(
|
||||
named("com.netflix.hystrix.HystrixCommand")
|
||||
.or(named("com.netflix.hystrix.HystrixObservableCommand")));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
@ -129,7 +129,7 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
|
|||
});
|
||||
}
|
||||
return matcher.and(
|
||||
safeHasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
|
||||
hasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
|
@ -44,7 +44,7 @@ public final class AkkaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME)));
|
||||
return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan;
|
||||
|
@ -36,7 +36,7 @@ public final class AsyncPropagatingDisableInstrumentation implements Instrumente
|
|||
new ImmutableMap.Builder<
|
||||
ElementMatcher<? super TypeDescription>,
|
||||
ElementMatcher<? super MethodDescription>>()
|
||||
.put(safeExtendsClass(named("rx.Scheduler$Worker")), named("schedulePeriodically"))
|
||||
.put(extendsClass(named("rx.Scheduler$Worker")), named("schedulePeriodically"))
|
||||
.build();
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -90,7 +90,7 @@ public final class FutureInstrumentation extends Instrumenter.Default {
|
|||
return whitelisted;
|
||||
}
|
||||
})
|
||||
.and(safeHasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
|
||||
.and(hasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -41,7 +41,7 @@ public final class JavaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(ForkJoinTask.class.getName())));
|
||||
return not(isInterface()).and(extendsClass(named(ForkJoinTask.class.getName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -35,7 +35,7 @@ public final class RunnableCallableInstrumentation extends Instrumenter.Default
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named(Runnable.class.getName()).or(named(Callable.class.getName()))));
|
||||
.and(hasInterface(named(Runnable.class.getName()).or(named(Callable.class.getName()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.java.concurrent;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isAbstract;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -43,7 +43,7 @@ public final class ScalaForkJoinTaskInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeExtendsClass(named(TASK_CLASS_NAME)));
|
||||
return not(isInterface()).and(extendsClass(named(TASK_CLASS_NAME)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package datadog.trace.instrumentation.jaxrs1;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.hasSuperMethod;
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.classLoaderHasClasses;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasSuperMethod;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -44,7 +44,7 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(
|
||||
isAnnotatedWith(named("javax.ws.rs.Path"))
|
||||
.or(declaresMethod(isAnnotatedWith(named("javax.ws.rs.Path")))));
|
||||
.<TypeDescription>or(declaresMethod(isAnnotatedWith(named("javax.ws.rs.Path")))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jaxrs2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -31,7 +31,7 @@ public abstract class AbstractRequestContextInstrumentation extends Instrumenter
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestContext")));
|
||||
.and(hasInterface(named("javax.ws.rs.container.ContainerRequestContext")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jaxrs2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -33,7 +33,7 @@ public class ContainerRequestFilterInstrumentation extends Instrumenter.Default
|
|||
@Override
|
||||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("javax.ws.rs.container.ContainerRequestFilter")));
|
||||
.and(hasInterface(named("javax.ws.rs.container.ContainerRequestFilter")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package datadog.trace.instrumentation.jaxrs2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.hasSuperMethod;
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasSuperMethod;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -43,7 +43,7 @@ public final class JaxRsAnnotationsInstrumentation extends Instrumenter.Default
|
|||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasSuperType(
|
||||
isAnnotatedWith(named("javax.ws.rs.Path"))
|
||||
.or(declaresMethod(isAnnotatedWith(named("javax.ws.rs.Path")))));
|
||||
.<TypeDescription>or(declaresMethod(isAnnotatedWith(named("javax.ws.rs.Path")))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jaxrs2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.instrumentation.jaxrs2.JaxRsAnnotationsDecorator.DECORATE;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
@ -35,7 +35,7 @@ public final class JaxRsAsyncResponseInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("javax.ws.rs.container.AsyncResponse"));
|
||||
return hasInterface(named("javax.ws.rs.container.AsyncResponse"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package datadog.trace.instrumentation.jaxrs.v1;
|
||||
|
||||
import static datadog.trace.agent.decorator.HttpServerDecorator.DD_SPAN_ATTRIBUTE;
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -36,7 +36,7 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("com.sun.jersey.api.client.ClientHandler"));
|
||||
return hasInterface(named("com.sun.jersey.api.client.ClientHandler"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,10 +54,8 @@ public final class JaxRsClientV1Instrumentation extends Instrumenter.Default {
|
|||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
named("handle")
|
||||
.and(
|
||||
takesArgument(
|
||||
0, safeExtendsClass(named("com.sun.jersey.api.client.ClientRequest"))))
|
||||
.and(returns(safeExtendsClass(named("com.sun.jersey.api.client.ClientResponse")))),
|
||||
.and(takesArgument(0, extendsClass(named("com.sun.jersey.api.client.ClientRequest"))))
|
||||
.and(returns(extendsClass(named("com.sun.jersey.api.client.ClientResponse")))),
|
||||
JaxRsClientV1Instrumentation.class.getName() + "$HandleAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package datadog.trace.instrumentation.jaxrs;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeExtendsClass;
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.extendsClass;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -25,7 +25,7 @@ public final class JaxRsClientInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeExtendsClass(named("javax.ws.rs.client.ClientBuilder"));
|
||||
return extendsClass(named("javax.ws.rs.client.ClientBuilder"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,7 +44,7 @@ public final class JaxRsClientInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public Map<? extends ElementMatcher<? super MethodDescription>, String> transformers() {
|
||||
return singletonMap(
|
||||
named("build").and(returns(safeHasInterface(named("javax.ws.rs.client.Client")))),
|
||||
named("build").and(returns(hasInterface(named("javax.ws.rs.client.Client")))),
|
||||
JaxRsClientInstrumentation.class.getName() + "$ClientBuilderAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jdbc;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -27,7 +27,7 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Connection")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Connection")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -43,7 +43,7 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
|
|||
nameStartsWith("prepare")
|
||||
.and(takesArgument(0, String.class))
|
||||
// Also include CallableStatement, which is a sub type of PreparedStatement
|
||||
.and(returns(safeHasInterface(named("java.sql.PreparedStatement")))),
|
||||
.and(returns(hasInterface(named("java.sql.PreparedStatement")))),
|
||||
ConnectionInstrumentation.class.getName() + "$ConnectionPrepareAdvice");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jdbc;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -42,7 +42,7 @@ public final class DataSourceInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.sql.DataSource")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.sql.DataSource")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jdbc;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
|
@ -30,7 +30,7 @@ public final class DriverInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Driver")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Driver")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jdbc;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.jdbc.JDBCDecorator.DECORATE;
|
||||
|
@ -35,7 +35,7 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.PreparedStatement")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.PreparedStatement")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,13 +61,13 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
|
|||
|
||||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static AgentScope onEnter(@Advice.This final PreparedStatement statement) {
|
||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(PreparedStatement.class);
|
||||
if (callDepth > 0) {
|
||||
final Connection connection = connectionFromStatement(statement);
|
||||
if (connection == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Connection connection = connectionFromStatement(statement);
|
||||
if (connection == null) {
|
||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(PreparedStatement.class);
|
||||
if (callDepth > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jdbc;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.jdbc.JDBCDecorator.DECORATE;
|
||||
|
@ -35,7 +35,7 @@ public final class StatementInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("java.sql.Statement")));
|
||||
return not(isInterface()).and(hasInterface(named("java.sql.Statement")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,13 +62,13 @@ public final class StatementInstrumentation extends Instrumenter.Default {
|
|||
@Advice.OnMethodEnter(suppress = Throwable.class)
|
||||
public static AgentScope onEnter(
|
||||
@Advice.Argument(0) final String sql, @Advice.This final Statement statement) {
|
||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(Statement.class);
|
||||
if (callDepth > 0) {
|
||||
final Connection connection = connectionFromStatement(statement);
|
||||
if (connection == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final Connection connection = connectionFromStatement(statement);
|
||||
if (connection == null) {
|
||||
final int callDepth = CallDepthThreadLocalMap.incrementCallDepth(Statement.class);
|
||||
if (callDepth > 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jetty8;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||
|
@ -30,7 +30,7 @@ public final class JettyHandlerInstrumentation extends Instrumenter.Default {
|
|||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("org.eclipse.jetty.server.Handler")))
|
||||
.and(hasInterface(named("org.eclipse.jetty.server.Handler")))
|
||||
.and(not(named("org.eclipse.jetty.server.handler.HandlerWrapper")));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jms;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -37,7 +37,7 @@ public final class JMSMessageConsumerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageConsumer")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageConsumer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jms;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -35,7 +35,7 @@ public final class JMSMessageListenerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageListener")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jms;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
|
@ -37,7 +37,7 @@ public final class JMSMessageProducerInstrumentation extends Instrumenter.Defaul
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.jms.MessageProducer")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.jms.MessageProducer")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.jsp;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.jsp.JSPDecorator.DECORATE;
|
||||
|
@ -31,7 +31,7 @@ public final class JSPInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("javax.servlet.jsp.HttpJspPage")));
|
||||
return not(isInterface()).and(hasInterface(named("javax.servlet.jsp.HttpJspPage")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.netty40;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
@ -35,8 +35,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.netty40;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,7 +101,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
return CallDepthThreadLocalMap.incrementCallDepth(ChannelPipeline.class);
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void addHandler(
|
||||
@Advice.Enter final int depth,
|
||||
@Advice.This final ChannelPipeline pipeline,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.netty41;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static java.util.Collections.singletonMap;
|
||||
|
@ -35,8 +35,7 @@ public class ChannelFutureListenerInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface())
|
||||
.and(safeHasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelFutureListener")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.netty41;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeScope;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
|
@ -48,7 +48,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
return not(isInterface()).and(hasInterface(named("io.netty.channel.ChannelPipeline")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -110,7 +110,7 @@ public class NettyChannelPipelineInstrumentation extends Instrumenter.Default {
|
|||
return CallDepthThreadLocalMap.incrementCallDepth(handler.getClass());
|
||||
}
|
||||
|
||||
@Advice.OnMethodExit(suppress = Throwable.class)
|
||||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
|
||||
public static void addHandler(
|
||||
@Advice.Enter final int depth,
|
||||
@Advice.This final ChannelPipeline pipeline,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.play24;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -22,7 +22,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("play.api.mvc.Action"));
|
||||
return hasInterface(named("play.api.mvc.Action"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.play26;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.returns;
|
||||
|
@ -22,7 +22,7 @@ public final class PlayInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return safeHasInterface(named("play.api.mvc.Action"));
|
||||
return hasInterface(named("play.api.mvc.Action"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package datadog.trace.instrumentation.playws1;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.playws1.HeadersInjectAdapter.SETTER;
|
||||
import static datadog.trace.instrumentation.playws1.PlayWSClientDecorator.DECORATE;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.isMethod;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
|
@ -33,8 +34,10 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// CachingAsyncHttpClient rejects overrides to AsyncHandler
|
||||
// It also delegates to another AsyncHttpClient
|
||||
return safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient")));
|
||||
return nameStartsWith("play.")
|
||||
.<TypeDescription>and(
|
||||
hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient"))));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.playws21;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.playws21.HeadersInjectAdapter.SETTER;
|
||||
|
@ -33,7 +33,7 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// CachingAsyncHttpClient rejects overrides to AsyncHandler
|
||||
// It also delegates to another AsyncHttpClient
|
||||
return safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
return hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient")));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.playws2;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.propagate;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.startSpan;
|
||||
import static datadog.trace.instrumentation.playws2.HeadersInjectAdapter.SETTER;
|
||||
|
@ -33,7 +33,7 @@ public class PlayWSClientInstrumentation extends Instrumenter.Default {
|
|||
public ElementMatcher<? super TypeDescription> typeMatcher() {
|
||||
// CachingAsyncHttpClient rejects overrides to AsyncHandler
|
||||
// It also delegates to another AsyncHttpClient
|
||||
return safeHasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
return hasInterface(named("play.shaded.ahc.org.asynchttpclient.AsyncHttpClient"))
|
||||
.and(not(named("play.api.libs.ws.ahc.cache.CachingAsyncHttpClient")));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package datadog.trace.instrumentation.rabbitmq.amqp;
|
||||
|
||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasInterface;
|
||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.hasInterface;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activeSpan;
|
||||
import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.noopSpan;
|
||||
|
@ -56,7 +56,7 @@ public class RabbitChannelInstrumentation extends Instrumenter.Default {
|
|||
|
||||
@Override
|
||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||
return not(isInterface()).and(safeHasInterface(named("com.rabbitmq.client.Channel")));
|
||||
return not(isInterface()).and(hasInterface(named("com.rabbitmq.client.Channel")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue