Fix startup performance issue in slf4j instrumentation
@@ -26,6 +26,7 @@ package co.elastic.apm.agent.error.logging;
import co.elastic.apm.agent.bci.ElasticApmInstrumentation;
import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
@@ -34,6 +35,7 @@ import java.util.Arrays;
import java.util.Collection;
import static net.bytebuddy.matcher.ElementMatchers.hasSuperType;
+import static net.bytebuddy.matcher.ElementMatchers.nameContains;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
@@ -55,6 +57,11 @@ public class Slf4jLoggingInstrumentation extends ElasticApmInstrumentation {
}
}
+ @Override
+ public ElementMatcher<? super NamedElement> getTypeMatcherPreFilter() {
+ return nameContains("Logger");
+ }
+
@Override
public ElementMatcher<? super TypeDescription> getTypeMatcher() {
return hasSuperType(named("org.slf4j.Logger"));
