Support MySQL plugin tracing SQL parameters when useServerPrepStmts (#489)

This commit is contained in:
xu1009 2023-03-28 22:45:55 +08:00 committed by GitHub
parent c0b4447540
commit 1f30e38864
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -23,6 +23,7 @@ Release Notes.
* Support keep trace profiling when cross-thread.
* Fix unexpected whitespace of the command catalogs in several Redis plugins.
* Fix a thread leak in `SamplingService` when updated sampling policy in the runtime.
* Support MySQL plugin tracing SQL parameters when useServerPrepStmts
#### Documentation
* Update docs of Tracing APIs, reorganize the API docs into six parts.

View File

@ -19,11 +19,11 @@
package org.apache.skywalking.apm.plugin.jdbc.mysql.v5.define;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
import org.apache.skywalking.apm.plugin.jdbc.mysql.Constants;
import net.bytebuddy.description.method.MethodDescription;
@ -38,6 +38,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
private static final String SERVICE_METHOD_INTERCEPTOR = Constants.PREPARED_STATEMENT_EXECUTE_METHODS_INTERCEPTOR;
public static final String MYSQL_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.PreparedStatement";
public static final String MYSQL_SERVER_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.ServerPreparedStatement";
@Override
public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@ -70,7 +71,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
@Override
protected ClassMatch enhanceClass() {
return byName(MYSQL_PREPARED_STATEMENT_CLASS_NAME);
return MultiClassNameMatch.byMultiClassMatch(MYSQL_PREPARED_STATEMENT_CLASS_NAME, MYSQL_SERVER_PREPARED_STATEMENT_CLASS_NAME);
}
}

View File

@ -23,9 +23,9 @@ import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
* {@link PreparedStatementInstrumentation} define that the mysql-6.x plugin intercepts the following methods in the
@ -36,6 +36,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
private static final String SERVICE_METHOD_INTERCEPTOR = org.apache.skywalking.apm.plugin.jdbc.mysql.Constants.PREPARED_STATEMENT_EXECUTE_METHODS_INTERCEPTOR;
public static final String MYSQL6_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.PreparedStatement";
public static final String MYSQL6_SERVER_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.ServerPreparedStatement";
@Override
public final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@ -68,7 +69,7 @@ public class PreparedStatementInstrumentation extends AbstractMysqlInstrumentati
@Override
protected ClassMatch enhanceClass() {
return byName(MYSQL6_PREPARED_STATEMENT_CLASS_NAME);
return MultiClassNameMatch.byMultiClassMatch(MYSQL6_PREPARED_STATEMENT_CLASS_NAME, MYSQL6_SERVER_PREPARED_STATEMENT_CLASS_NAME);
}
}