Only instrument the actual Spring `TaskScheduler` implementations (#8676)

This commit is contained in:
Mateusz Rzeszutek 2023-06-12 10:01:29 +02:00 committed by GitHub
parent ebd31188af
commit 188d4c249a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -5,7 +5,6 @@
package io.opentelemetry.javaagent.instrumentation.spring.scheduling.v3_1;
import static io.opentelemetry.javaagent.extension.matcher.AgentElementMatchers.implementsInterface;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@ -20,7 +19,12 @@ import net.bytebuddy.matcher.ElementMatcher;
public class TaskSchedulerInstrumentation implements TypeInstrumentation {
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("org.springframework.scheduling.TaskScheduler"));
// we're only instrumenting the "real" scheduler implementations, and skipping all the decorator
// impls
return namedOneOf(
"org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler",
"org.springframework.scheduling.concurrent.ConcurrentTaskScheduler",
"org.springframework.scheduling.commonj.TimerManagerTaskScheduler");
}
@Override