Merge pull request #1240 from DataDog/tyler/executor-matcher-reorder
Reorder java-concurrent matchers
This commit is contained in:
commit
5e37ca02f1
|
@ -102,33 +102,34 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||||
final ElementMatcher.Junction<TypeDescription> matcher =
|
ElementMatcher.Junction<TypeDescription> matcher = not(isInterface());
|
||||||
not(isInterface()).and(safeHasInterface(named(Executor.class.getName())));
|
if (!TRACE_ALL_EXECUTORS) {
|
||||||
if (TRACE_ALL_EXECUTORS) {
|
matcher =
|
||||||
return matcher;
|
matcher.and(
|
||||||
|
new ElementMatcher<TypeDescription>() {
|
||||||
|
@Override
|
||||||
|
public boolean matches(final TypeDescription target) {
|
||||||
|
boolean whitelisted = WHITELISTED_EXECUTORS.contains(target.getName());
|
||||||
|
|
||||||
|
// Check for possible prefixes match only if not whitelisted already
|
||||||
|
if (!whitelisted) {
|
||||||
|
for (final String name : WHITELISTED_EXECUTORS_PREFIXES) {
|
||||||
|
if (target.getName().startsWith(name)) {
|
||||||
|
whitelisted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!whitelisted) {
|
||||||
|
log.debug("Skipping executor instrumentation for {}", target.getName());
|
||||||
|
}
|
||||||
|
return whitelisted;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return matcher.and(
|
return matcher.and(
|
||||||
new ElementMatcher<TypeDescription>() {
|
safeHasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
|
||||||
@Override
|
|
||||||
public boolean matches(final TypeDescription target) {
|
|
||||||
boolean whitelisted = WHITELISTED_EXECUTORS.contains(target.getName());
|
|
||||||
|
|
||||||
// Check for possible prefixes match only if not whitelisted already
|
|
||||||
if (!whitelisted) {
|
|
||||||
for (final String name : WHITELISTED_EXECUTORS_PREFIXES) {
|
|
||||||
if (target.getName().startsWith(name)) {
|
|
||||||
whitelisted = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!whitelisted) {
|
|
||||||
log.debug("Skipping executor instrumentation for {}", target.getName());
|
|
||||||
}
|
|
||||||
return whitelisted;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -79,7 +79,6 @@ public final class FutureInstrumentation extends Instrumenter.Default {
|
||||||
@Override
|
@Override
|
||||||
public ElementMatcher<TypeDescription> typeMatcher() {
|
public ElementMatcher<TypeDescription> typeMatcher() {
|
||||||
return not(isInterface())
|
return not(isInterface())
|
||||||
.and(safeHasInterface(named(Future.class.getName())))
|
|
||||||
.and(
|
.and(
|
||||||
new ElementMatcher<TypeDescription>() {
|
new ElementMatcher<TypeDescription>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -90,7 +89,8 @@ public final class FutureInstrumentation extends Instrumenter.Default {
|
||||||
}
|
}
|
||||||
return whitelisted;
|
return whitelisted;
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
.and(safeHasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue