提交 9946a71d 编写于 作者: A ascrutae

change mysql plugin module name

上级 1d1c81f4
......@@ -29,8 +29,11 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptR
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
*/
......
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.plugin.jdbc.mysql.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
* {@link JDBC42PreparedStatementInstrumentation} intercepts {@link com.mysql.jdbc.JDBC42PreparedStatement} class.
*
* @author zhangxin
*/
public class JDBC42PreparedStatementInstrumentation extends AbstractPreparedStatementInstrumentation {
private static final String ENHANCE_CLASS = "com.mysql.jdbc.JDBC42PreparedStatement";
@Override protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
}
}
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package org.skywalking.apm.plugin.jdbc.mysql.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.byMultiClassMath;
/**
* {@link JDBC42PreparedStatementInstrumentation} intercepts {@link com.mysql.jdbc.PreparedStatement} class.
*
* @author zhangxin
*/
public class PreparedStatementInstrumentation extends AbstractPreparedStatementInstrumentation {
private static final String ENHANCE_CLASS = "com.mysql.jdbc.PreparedStatement";
@Override protected ClassMatch enhanceClass() {
return byMultiClassMath(ENHANCE_CLASS, "com.mysql.cj.jdbc.PreparedStatement");
}
}
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.CallableInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.PreparedStatementInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.JDBC42PreparedStatementInstrumentation
mysql=org.skywalking.apm.plugin.jdbc.mysql.define.StatementInstrumentation
......@@ -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>
......@@ -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>
......
......@@ -41,6 +41,13 @@ public class StatementExecuteMethodsInterceptor implements InstanceMethodsAround
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());
......
......@@ -26,12 +26,14 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
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
*/
......@@ -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");
}
}
......@@ -35,7 +35,7 @@ import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_
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
......@@ -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");
}
}
......@@ -21,7 +21,7 @@ package org.skywalking.apm.plugin.jdbc.mysql.define;
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}.
......@@ -31,6 +31,6 @@ import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.by
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");
}
}
......@@ -28,7 +28,7 @@ import org.skywalking.apm.agent.core.plugin.match.IndirectMatch;
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
*/
......@@ -61,7 +61,7 @@ public class MultiClassNameMatch implements IndirectMatch {
return matchClassNames.contains(typeDescription.getTypeName());
}
public static ClassMatch byMultiClassMath(String... classNames) {
public static ClassMatch byMultiClassMatch(String... classNames) {
return new MultiClassNameMatch(classNames);
}
}
......@@ -23,12 +23,15 @@ import net.bytebuddy.matcher.ElementMatcher;
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/>
......@@ -37,9 +40,12 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
*
* @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];
......@@ -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);
}
}
......@@ -26,11 +26,11 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
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/>
......@@ -44,8 +44,9 @@ import static org.skywalking.apm.plugin.jdbc.mysql.define.MultiClassNameMatch.by
* @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];
......@@ -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);
}
}
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
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册