Merge pull request #1258 from DataDog/tyler/fix-whitelist-logging

Apply matcher if debug logging enabled to avoid confusing log output.
This commit is contained in:
Tyler Benson 2020-02-26 08:57:17 -08:00 committed by GitHub
commit 2ec0c1acb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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