Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,34 @@ public AbstractExecutorInstrumentation(final String... additionalNames) {

@Override
public ElementMatcher<TypeDescription> typeMatcher() {
final ElementMatcher.Junction<TypeDescription> matcher =
not(isInterface()).and(safeHasInterface(named(Executor.class.getName())));
if (TRACE_ALL_EXECUTORS) {
return matcher;
ElementMatcher.Junction<TypeDescription> matcher = not(isInterface());
if (!TRACE_ALL_EXECUTORS) {
matcher =
matcher.and(
new ElementMatcher<TypeDescription>() {
@Override
public boolean matches(final TypeDescription target) {
boolean whitelisted = WHITELISTED_EXECUTORS.contains(target.getName());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might get a bit more from turning this into a string switch, but I suspect we've probably reached a point of diminishing returns.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's consider that in the future.


// 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(
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;
}
});
safeHasInterface(named(Executor.class.getName()))); // Apply expensive matcher last.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public FutureInstrumentation() {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return not(isInterface())
.and(safeHasInterface(named(Future.class.getName())))
.and(
new ElementMatcher<TypeDescription>() {
@Override
Expand All @@ -90,7 +89,8 @@ public boolean matches(final TypeDescription target) {
}
return whitelisted;
}
});
})
.and(safeHasInterface(named(Future.class.getName()))); // Apply expensive matcher last.
}

@Override
Expand Down