Remove costly matchers from ignore list (#1233)
Remove costly matchers from ignore list
This commit is contained in:
commit
660921517c
|
@ -2,7 +2,6 @@ package datadog.trace.agent.tooling;
|
||||||
|
|
||||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.skipClassLoader;
|
import static datadog.trace.agent.tooling.ClassLoaderMatcher.skipClassLoader;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
import static net.bytebuddy.matcher.ElementMatchers.any;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.nameContains;
|
import static net.bytebuddy.matcher.ElementMatchers.nameContains;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
|
import static net.bytebuddy.matcher.ElementMatchers.nameMatches;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||||
|
@ -24,7 +23,6 @@ import net.bytebuddy.agent.builder.ResettableClassFileTransformer;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.dynamic.DynamicType;
|
import net.bytebuddy.dynamic.DynamicType;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
import net.bytebuddy.matcher.ElementMatchers;
|
|
||||||
import net.bytebuddy.utility.JavaModule;
|
import net.bytebuddy.utility.JavaModule;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@ -66,10 +64,11 @@ public class AgentInstaller {
|
||||||
// https://github.com/raphw/byte-buddy/issues/558
|
// https://github.com/raphw/byte-buddy/issues/558
|
||||||
// .with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
|
// .with(AgentBuilder.LambdaInstrumentationStrategy.ENABLED)
|
||||||
.ignore(any(), skipClassLoader())
|
.ignore(any(), skipClassLoader())
|
||||||
// Unlikely to ever need to instrument an annotation:
|
/**
|
||||||
.or(ElementMatchers.<TypeDescription>isAnnotation())
|
* Be very careful about the types of matchers used in this section as they are called
|
||||||
// Unlikely to ever need to instrument an enum:
|
* on every class load, so they must be fast. Generally speaking try to only use name
|
||||||
.or(ElementMatchers.<TypeDescription>isEnum())
|
* matchers as they don't have to load additional info.
|
||||||
|
*/
|
||||||
.or(
|
.or(
|
||||||
nameStartsWith("datadog.trace.")
|
nameStartsWith("datadog.trace.")
|
||||||
// FIXME: We should remove this once
|
// FIXME: We should remove this once
|
||||||
|
@ -134,7 +133,6 @@ public class AgentInstaller {
|
||||||
.or(nameContains(".asm."))
|
.or(nameContains(".asm."))
|
||||||
.or(nameContains("$__sisu"))
|
.or(nameContains("$__sisu"))
|
||||||
.or(nameMatches("com\\.mchange\\.v2\\.c3p0\\..*Proxy"))
|
.or(nameMatches("com\\.mchange\\.v2\\.c3p0\\..*Proxy"))
|
||||||
.or(isAnnotatedWith(named("javax.decorator.Decorator")))
|
|
||||||
.or(matchesConfiguredExcludes());
|
.or(matchesConfiguredExcludes());
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
|
|
@ -2,6 +2,9 @@ package datadog.trace.agent.tooling;
|
||||||
|
|
||||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.failSafe;
|
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.failSafe;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.any;
|
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.context.FieldBackedProvider;
|
import datadog.trace.agent.tooling.context.FieldBackedProvider;
|
||||||
import datadog.trace.agent.tooling.context.InstrumentationContextProvider;
|
import datadog.trace.agent.tooling.context.InstrumentationContextProvider;
|
||||||
|
@ -78,6 +81,9 @@ public interface Instrumenter {
|
||||||
classLoaderMatcher(),
|
classLoaderMatcher(),
|
||||||
"Instrumentation class loader matcher unexpected exception: "
|
"Instrumentation class loader matcher unexpected exception: "
|
||||||
+ getClass().getName()))
|
+ getClass().getName()))
|
||||||
|
// Added here instead of AgentInstaller's ignores because it's relatively
|
||||||
|
// expensive. https://github.com/DataDog/dd-trace-java/pull/1045
|
||||||
|
.and(not(isAnnotatedWith(named("javax.decorator.Decorator"))))
|
||||||
.and(new MuzzleMatcher())
|
.and(new MuzzleMatcher())
|
||||||
.and(new PostMatchHook())
|
.and(new PostMatchHook())
|
||||||
.transform(DDTransformers.defaultTransformers());
|
.transform(DDTransformers.defaultTransformers());
|
||||||
|
|
|
@ -2,6 +2,7 @@ package datadog.trace.agent.tooling.context;
|
||||||
|
|
||||||
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
import static datadog.trace.agent.tooling.ByteBuddyElementMatchers.safeHasSuperType;
|
||||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
||||||
|
import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||||
|
@ -354,9 +355,12 @@ public class FieldBackedProvider implements InstrumentationContextProvider {
|
||||||
builder =
|
builder =
|
||||||
builder
|
builder
|
||||||
.type(
|
.type(
|
||||||
safeHasSuperType(named(entry.getKey())).and(not(isInterface())),
|
not(isInterface()).and(safeHasSuperType(named(entry.getKey()))),
|
||||||
instrumenter.classLoaderMatcher())
|
instrumenter.classLoaderMatcher())
|
||||||
.and(safeToInjectFieldsMatcher())
|
.and(safeToInjectFieldsMatcher())
|
||||||
|
// Added here instead of AgentInstaller's ignores because it's relatively
|
||||||
|
// expensive. https://github.com/DataDog/dd-trace-java/pull/1045
|
||||||
|
.and(not(isAnnotatedWith(named("javax.decorator.Decorator"))))
|
||||||
.transform(AgentBuilder.Transformer.NoOp.INSTANCE);
|
.transform(AgentBuilder.Transformer.NoOp.INSTANCE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import datadog.trace.agent.test.AgentTestRunner
|
import datadog.trace.agent.test.AgentTestRunner
|
||||||
import datadog.trace.instrumentation.TestBean
|
|
||||||
import org.jboss.weld.environment.se.Weld
|
import org.jboss.weld.environment.se.Weld
|
||||||
import org.jboss.weld.environment.se.WeldContainer
|
import org.jboss.weld.environment.se.WeldContainer
|
||||||
import org.jboss.weld.environment.se.threading.RunnableDecorator
|
import org.jboss.weld.environment.se.threading.RunnableDecorator
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
package datadog.trace.instrumentation;
|
|
||||||
|
|
||||||
public class TestBean {
|
public class TestBean {
|
||||||
|
|
||||||
private String someField;
|
private String someField;
|
Loading…
Reference in New Issue