Apply matcher if debug logging enabled to avoid confusing log output.

Otherwise it was "Skipping" every unrelated class.
This commit is contained in:
Tyler Benson 2020-02-25 18:04:27 -08:00
parent 39e577ad97
commit eb8de0d3ab
2 changed files with 12 additions and 5 deletions

View File

@ -103,6 +103,8 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
ElementMatcher.Junction<TypeDescription> matcher = not(isInterface());
final ElementMatcher.Junction<TypeDescription> hasExecutorInterfaceMatcher =
hasInterface(named(Executor.class.getName()));
if (!TRACE_ALL_EXECUTORS) {
matcher =
matcher.and(
@ -121,15 +123,16 @@ public abstract class AbstractExecutorInstrumentation extends Instrumenter.Defau
}
}
if (!whitelisted) {
if (!whitelisted
&& log.isDebugEnabled()
&& hasExecutorInterfaceMatcher.matches(target)) {
log.debug("Skipping executor instrumentation for {}", target.getName());
}
return whitelisted;
}
});
}
return matcher.and(
hasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
return matcher.and(hasExecutorInterfaceMatcher); // Apply expensive matcher last.
}
@Override

View File

@ -78,19 +78,23 @@ public final class FutureInstrumentation extends Instrumenter.Default {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
final ElementMatcher.Junction<TypeDescription> hasFutureInterfaceMatcher =
hasInterface(named(Future.class.getName()));
return not(isInterface())
.and(
new ElementMatcher<TypeDescription>() {
@Override
public boolean matches(final TypeDescription target) {
final boolean whitelisted = WHITELISTED_FUTURES.contains(target.getName());
if (!whitelisted) {
if (!whitelisted
&& log.isDebugEnabled()
&& hasFutureInterfaceMatcher.matches(target)) {
log.debug("Skipping future instrumentation for {}", target.getName());
}
return whitelisted;
}
})
.and(hasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
.and(hasFutureInterfaceMatcher); // Apply expensive matcher last.
}
@Override