Add missing classloader matchers for expensive matchers (DataDog/dd-trace-java#1617)
MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/ConnectionInstrumentation.java
package io.opentelemetry.auto.instrumentation.jdbc;
+import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.hasInterface;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static java.util.Collections.singletonMap;
@@ -40,6 +41,11 @@ public final class ConnectionInstrumentation extends Instrumenter.Default {
super("jdbc");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("java.sql.Connection");
+ }
+
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("java.sql.Connection"));

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/DriverInstrumentation.java
package io.opentelemetry.auto.instrumentation.jdbc;
+import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
@@ -42,6 +43,11 @@ public final class DriverInstrumentation extends Instrumenter.Default {
super("jdbc");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("java.sql.Driver");
+ }
+
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("java.sql.Driver"));

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/PreparedStatementInstrumentation.java
package io.opentelemetry.auto.instrumentation.jdbc;
import static io.opentelemetry.auto.instrumentation.jdbc.JdbcTracer.TRACER;
+import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@@ -43,6 +44,11 @@ public final class PreparedStatementInstrumentation extends Instrumenter.Default
super("jdbc");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("java.sql.PreparedStatement");
+ }
+
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("java.sql.PreparedStatement"));

MODIFY
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java
instrumentation/jdbc/src/main/java/io/opentelemetry/auto/instrumentation/jdbc/StatementInstrumentation.java
package io.opentelemetry.auto.instrumentation.jdbc;
import static io.opentelemetry.auto.instrumentation.jdbc.JdbcTracer.TRACER;
+import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.implementsInterface;
import static java.util.Collections.singletonMap;
import static net.bytebuddy.matcher.ElementMatchers.isPublic;
@@ -43,6 +44,11 @@ public final class StatementInstrumentation extends Instrumenter.Default {
super("jdbc");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("java.sql.Statement");
+ }
+
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return implementsInterface(named("java.sql.Statement"));

MODIFY
instrumentation/rediscala-1.8/src/main/java/io/opentelemetry/auto/instrumentation/rediscala/RediscalaInstrumentation.java
instrumentation/rediscala-1.8/src/main/java/io/opentelemetry/auto/instrumentation/rediscala/RediscalaInstrumentation.java
@@ -18,6 +18,7 @@ package io.opentelemetry.auto.instrumentation.rediscala;
import static io.opentelemetry.auto.instrumentation.rediscala.RediscalaClientDecorator.DECORATE;
import static io.opentelemetry.auto.instrumentation.rediscala.RediscalaClientDecorator.TRACER;
+import static io.opentelemetry.auto.tooling.ClassLoaderMatcher.hasClassesNamed;
import static io.opentelemetry.auto.tooling.bytebuddy.matcher.AgentElementMatchers.safeHasSuperType;
import static io.opentelemetry.auto.tooling.matcher.NameMatchers.namedOneOf;
import static io.opentelemetry.trace.Span.Kind.CLIENT;
@@ -51,6 +52,11 @@ public final class RediscalaInstrumentation extends Instrumenter.Default {
super("rediscala", "redis");
}
+ @Override
+ public ElementMatcher<ClassLoader> classLoaderMatcher() {
+ return hasClassesNamed("redis.Request");
+ }
+
@Override
public ElementMatcher<TypeDescription> typeMatcher() {
return safeHasSuperType(

Add missing classloader matchers for expensive matchers (DataDog/dd-trace-java#1617)