Merge pull request #1267 from DataDog/mar-kolya/constantify-decorator-matcher
Constantify non decorator matcher
This commit is contained in:
commit
5c4cd95796
|
@ -23,9 +23,11 @@ import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.bytebuddy.agent.builder.AgentBuilder;
|
import net.bytebuddy.agent.builder.AgentBuilder;
|
||||||
|
import net.bytebuddy.description.annotation.AnnotationSource;
|
||||||
import net.bytebuddy.description.method.MethodDescription;
|
import net.bytebuddy.description.method.MethodDescription;
|
||||||
import net.bytebuddy.description.type.TypeDescription;
|
import net.bytebuddy.description.type.TypeDescription;
|
||||||
import net.bytebuddy.matcher.ElementMatcher;
|
import net.bytebuddy.matcher.ElementMatcher;
|
||||||
|
import net.bytebuddy.matcher.ElementMatcher.Junction;
|
||||||
import net.bytebuddy.utility.JavaModule;
|
import net.bytebuddy.utility.JavaModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +47,12 @@ public interface Instrumenter {
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
abstract class Default implements Instrumenter {
|
abstract class Default implements Instrumenter {
|
||||||
|
|
||||||
|
// Added here instead of AgentInstaller's ignores because it's relatively
|
||||||
|
// expensive. https://github.com/DataDog/dd-trace-java/pull/1045
|
||||||
|
public static final Junction<AnnotationSource> NOT_DECORATOR_MATCHER =
|
||||||
|
not(isAnnotatedWith(named("javax.decorator.Decorator")));
|
||||||
|
|
||||||
private final SortedSet<String> instrumentationNames;
|
private final SortedSet<String> instrumentationNames;
|
||||||
private final String instrumentationPrimaryName;
|
private final String instrumentationPrimaryName;
|
||||||
private final InstrumentationContextProvider contextProvider;
|
private final InstrumentationContextProvider contextProvider;
|
||||||
|
@ -83,9 +91,7 @@ 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
|
.and(NOT_DECORATOR_MATCHER)
|
||||||
// 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,12 +2,12 @@ package datadog.trace.agent.tooling.context;
|
||||||
|
|
||||||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
import static datadog.trace.agent.tooling.ClassLoaderMatcher.BOOTSTRAP_CLASSLOADER;
|
||||||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType;
|
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;
|
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
|
||||||
|
|
||||||
import datadog.trace.agent.tooling.HelperInjector;
|
import datadog.trace.agent.tooling.HelperInjector;
|
||||||
import datadog.trace.agent.tooling.Instrumenter;
|
import datadog.trace.agent.tooling.Instrumenter;
|
||||||
|
import datadog.trace.agent.tooling.Instrumenter.Default;
|
||||||
import datadog.trace.agent.tooling.Utils;
|
import datadog.trace.agent.tooling.Utils;
|
||||||
import datadog.trace.api.Config;
|
import datadog.trace.api.Config;
|
||||||
import datadog.trace.bootstrap.ContextStore;
|
import datadog.trace.bootstrap.ContextStore;
|
||||||
|
@ -355,9 +355,7 @@ public class FieldBackedProvider implements InstrumentationContextProvider {
|
||||||
builder
|
builder
|
||||||
.type(safeHasSuperType(named(entry.getKey())), instrumenter.classLoaderMatcher())
|
.type(safeHasSuperType(named(entry.getKey())), instrumenter.classLoaderMatcher())
|
||||||
.and(safeToInjectFieldsMatcher())
|
.and(safeToInjectFieldsMatcher())
|
||||||
// Added here instead of AgentInstaller's ignores because it's relatively
|
.and(Default.NOT_DECORATOR_MATCHER)
|
||||||
// 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);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -5,7 +5,6 @@ import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.sa
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
|
||||||
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.takesArgument;
|
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
|
|
Loading…
Reference in New Issue