Skip to content

Commit

Permalink
change mysql plugin module name
Browse files Browse the repository at this point in the history
  • Loading branch information
ascrutae committed Nov 1, 2017
1 parent 1d1c81f commit 9946a71
Show file tree
Hide file tree
Showing 22 changed files with 52 additions and 104 deletions.
Expand Up @@ -29,8 +29,11 @@
import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;

/**
* {@link ConnectionServiceMethodInterceptor} create an exit span when the client call the following methods in the
* class that extend {@link java.sql.Connection}. 1. close 2. rollback 3. releaseSavepoint 4. commit
* {@link ConnectionServiceMethodInterceptor} create an exit span when the following methods execute:
* 1. close
* 2. rollback
* 3. releaseSavepoint
* 4. commit
*
* @author zhangxin
*/
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -25,10 +25,10 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-mysql-2.x-plugin</artifactId>
<artifactId>apm-mysql-5.x-plugin</artifactId>
<packaging>jar</packaging>

<name>mysql-2.x-plugin</name>
<name>mysql-5.x-plugin</name>
<url>http://maven.apache.org</url>

<properties>
Expand All @@ -45,7 +45,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>[2.0.14,6.0.6]</version>
<version>[5.1.22,6.0.6]</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Expand Up @@ -41,6 +41,13 @@ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[]
MethodInterceptResult result) throws Throwable {
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
/**
* To protected the code occur NullPointException. because mysql execute system sql when constructor method in
* {@link com.mysql.jdbc.ConnectionImpl} class executed. but the interceptor set the connection Info after
* the constructor method executed.
*
* @see org.skywalking.apm.plugin.jdbc.JDBCDriverInterceptor#afterMethod(EnhancedInstance, Method, Object[], Class[], Object)
*/
if (connectInfo != null) {

AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
Expand Down
Expand Up @@ -26,12 +26,14 @@
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;

/**
* {@link CallableInstrumentation} define that the mysql-2.x plugin intercepts the following methods in the {@link
* com.mysql.jdbc.CallableStatement} by {@link org.skywalking.apm.plugin.jdbc.mysql.CallableStatementInterceptor}. 1.
* execute <br/> 2. executeQuery <br/> 3. executeUpdate <br/>
* com.mysql.jdbc.CallableStatement} by {@link org.skywalking.apm.plugin.jdbc.mysql.CallableStatementInterceptor}:
* 1. execute <br/>
* 2. executeQuery <br/>
* 3. executeUpdate <br/>
*
* @author zhangxin
*/
Expand Down Expand Up @@ -64,6 +66,6 @@ public class CallableInstrumentation extends ClassInstanceMethodsEnhancePluginDe
}

@Override protected ClassMatch enhanceClass() {
return byMultiClassMath(ENHANCE_CLASS, "com.mysql.jdbc.cj.CallableStatement");
return byMultiClassMatch(ENHANCE_CLASS, "com.mysql.jdbc.cj.CallableStatement");
}
}
Expand Up @@ -35,7 +35,7 @@
import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;

/**
* {@link ConnectionInstrumentation} intercepts the following methods that the class which extend {@link
Expand Down Expand Up @@ -115,6 +115,6 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
}

@Override protected ClassMatch enhanceClass() {
return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.ConnectionImpl");
return byMultiClassMatch(ENHANCE_CLASS, "com.mysql.cj.jdbc.ConnectionImpl");
}
}
Expand Up @@ -21,7 +21,7 @@
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;

import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;

/**
* {@link DriverInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
Expand All @@ -31,6 +31,6 @@
public class DriverInstrumentation extends AbstractDriverInstrumentation {
@Override
protected ClassMatch enhanceClass() {
return byMultiClassMath("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver");
return byMultiClassMatch("com.mysql.jdbc.Driver", "com.mysql.cj.jdbc.Driver");
}
}
Expand Up @@ -28,7 +28,7 @@
import static net.bytebuddy.matcher.ElementMatchers.named;

/**
* Match multiple classes name with an explicit class name.
* Match class with a given set of classes.
*
* @author zhangxin
*/
Expand Down Expand Up @@ -61,7 +61,7 @@ public boolean isMatch(TypeDescription typeDescription) {
return matchClassNames.contains(typeDescription.getTypeName());
}

public static ClassMatch byMultiClassMath(String... classNames) {
public static ClassMatch byMultiClassMatch(String... classNames) {
return new MultiClassNameMatch(classNames);
}
}
Expand Up @@ -23,12 +23,15 @@
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;

/**
* {@link AbstractPreparedStatementInstrumentation} define that the mysql-2.x plugin intercepts the following methods in
* the {@link com.mysql.jdbc.JDBC42PreparedStatement} and {@link com.mysql.jdbc.PreparedStatement} class.
* {@link PreparedStatementInstrumentation} define that the mysql-2.x plugin intercepts the following methods in the
* {@link com.mysql.jdbc.JDBC42PreparedStatement}, {@link com.mysql.jdbc.PreparedStatement} and {@link
* com.mysql.cj.jdbc.PreparedStatement} class:
* 1. execute <br/>
* 2. executeQuery <br/>
* 3. executeUpdate <br/>
Expand All @@ -37,9 +40,12 @@
*
* @author zhangxin
*/
public abstract class AbstractPreparedStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
public class PreparedStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {

private static final String PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.PreparedStatement";
private static final String SERVICE_METHOD_INTERCEPTOR = "org.skywalking.apm.plugin.jdbc.mysql.StatementExecuteMethodsInterceptor";
public static final String MYSQL6_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.PreparedStatement";
public static final String JDBC42_PREPARED_STATEMENT_CLASS_NAME = "com.mysql.jdbc.JDBC42PreparedStatement";

@Override protected final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
Expand All @@ -66,4 +72,8 @@ public abstract class AbstractPreparedStatementInstrumentation extends ClassInst
}
};
}

@Override protected ClassMatch enhanceClass() {
return byMultiClassMatch(PREPARED_STATEMENT_CLASS_NAME, MYSQL6_PREPARED_STATEMENT_CLASS_NAME, JDBC42_PREPARED_STATEMENT_CLASS_NAME);
}
}
Expand Up @@ -26,11 +26,11 @@
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMatch;

/**
* {@link JDBC42PreparedStatementInstrumentation} intercepts the following methods in the {@link
* com.mysql.jdbc.JDBC42PreparedStatement} class.
* {@link StatementInstrumentation} intercepts the following methods in the {@link
* com.mysql.jdbc.StatementImpl} and {@link com.mysql.cj.jdbc.StatementImpl}class.
* 1. execute <br/>
* 2. executeQuery <br/>
* 3. executeUpdate <br/>
Expand All @@ -44,8 +44,9 @@
* @author zhangxin
*/
public class StatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
private static final String ENHANCE_CLASS = "com.mysql.jdbc.StatementImpl";
private static final String STATEMENT_CLASS_NAME = "com.mysql.jdbc.StatementImpl";
private static final String SERVICE_METHOD_INTERCEPTOR = "org.skywalking.apm.plugin.jdbc.mysql.StatementExecuteMethodsInterceptor";
public static final String MYSQL6_STATEMENT_CLASS_NAME = "com.mysql.cj.jdbc.StatementImpl";

@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
Expand Down Expand Up @@ -78,6 +79,6 @@ public class StatementInstrumentation extends ClassInstanceMethodsEnhancePluginD
}

@Override protected ClassMatch enhanceClass() {
return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.StatementImpl");
return byMultiClassMatch(STATEMENT_CLASS_NAME, MYSQL6_STATEMENT_CLASS_NAME);
}
}
@@ -0,0 +1,5 @@
mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.CallableInstrumentation
mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.PreparedStatementInstrumentation
mysql-5.x=org.skywalking.apm.plugin.jdbc.mysql.define.StatementInstrumentation
2 changes: 1 addition & 1 deletion apm-sniffer/apm-sdk-plugin/pom.xml
Expand Up @@ -48,7 +48,7 @@
<module>sharding-jdbc-1.5.x-plugin</module>
<module>xmemcached-2.x-plugin</module>
<module>grpc-1.x-plugin</module>
<module>mysql-2.x-plugin</module>
<module>mysql-5.x-plugin</module>
<module>h2-1.x-plugin</module>
<module>postgresql-8.x-plugin</module>
<module>oracle-10.x-plugin</module>
Expand Down

0 comments on commit 9946a71

Please sign in to comment.