Skip to content

Commit 1f30e38

Browse files
authored
Support MySQL plugin tracing SQL parameters when useServerPrepStmts (#489)
1 parent c0b4447 commit 1f30e38

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Release Notes.
2323
* Support keep trace profiling when cross-thread.
2424
* Fix unexpected whitespace of the command catalogs in several Redis plugins.
2525
* Fix a thread leak in `SamplingService` when updated sampling policy in the runtime.
26+
* Support MySQL plugin tracing SQL parameters when useServerPrepStmts
2627

2728
#### Documentation
2829
* Update docs of Tracing APIs, reorganize the API docs into six parts.

apm-sniffer/apm-sdk-plugin/mysql-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v5/define/PreparedStatementInstrumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
package org.apache.skywalking.apm.plugin.jdbc.mysql.v5.define;
2020

2121
import static net.bytebuddy.matcher.ElementMatchers.named;
22-
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
2322

2423
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
2524
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
2625
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
26+
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
2727
import org.apache.skywalking.apm.plugin.jdbc.mysql.Constants;
2828

2929
import net.bytebuddy.description.method.MethodDescription;
@@ -38,6 +38,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
3838

3939
private static final String SERVICE_METHOD_INTERCEPTOR = Constants.PREPARED_STATEMENT_EXECUTE_METHODS_INTERCEPTOR;
4040
public static final String MYSQL_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.PreparedStatement";
41+
public static final String MYSQL_SERVER_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.ServerPreparedStatement";
4142

4243
@Override
4344
public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@@ -70,7 +71,7 @@ public boolean isOverrideArgs() {
7071

7172
@Override
7273
protected ClassMatch enhanceClass() {
73-
return byName(MYSQL_PREPARED_STATEMENT_CLASS_NAME);
74+
return MultiClassNameMatch.byMultiClassMatch(MYSQL_PREPARED_STATEMENT_CLASS_NAME, MYSQL_SERVER_PREPARED_STATEMENT_CLASS_NAME);
7475
}
7576

7677
}

apm-sniffer/apm-sdk-plugin/mysql-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/mysql/v6/define/PreparedStatementInstrumentation.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
2424
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
2525
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
26+
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
2627

2728
import static net.bytebuddy.matcher.ElementMatchers.named;
28-
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
2929

3030
/**
3131
* {@link PreparedStatementInstrumentation} define that the mysql-6.x plugin intercepts the following methods in the
@@ -36,6 +36,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
3636

3737
private static final String SERVICE_METHOD_INTERCEPTOR = org.apache.skywalking.apm.plugin.jdbc.mysql.Constants.PREPARED_STATEMENT_EXECUTE_METHODS_INTERCEPTOR;
3838
public static final String MYSQL6_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.PreparedStatement";
39+
public static final String MYSQL6_SERVER_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.ServerPreparedStatement";
3940

4041
@Override
4142
public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@@ -68,7 +69,7 @@ public boolean isOverrideArgs() {
6869

6970
@Override
7071
protected ClassMatch enhanceClass() {
71-
return byName(MYSQL6_PREPARED_STATEMENT_CLASS_NAME);
72+
return MultiClassNameMatch.byMultiClassMatch(MYSQL6_PREPARED_STATEMENT_CLASS_NAME, MYSQL6_SERVER_PREPARED_STATEMENT_CLASS_NAME);
7273
}
7374

7475
}

0 commit comments

Comments
 (0)