Support ojdbc8 (#1571)
This commit is contained in:
parent
18d2d352fd
commit
1c8431c86f
|
|
@ -39,14 +39,16 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
|
|||
Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
|
||||
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
|
||||
if (cacheObject != null && cacheObject.getConnectionInfo() != null) {
|
||||
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
|
||||
|
||||
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
|
||||
span.setComponent(connectInfo.getComponent());
|
||||
SpanLayer.asDB(span);
|
||||
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
Tags.DB_STATEMENT.set(span, cacheObject.getSql());
|
||||
span.setComponent(connectInfo.getComponent());
|
||||
SpanLayer.asDB(span);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -54,9 +56,11 @@ public class PreparedStatementExecuteMethodsInterceptor implements InstanceMetho
|
|||
Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
|
||||
if (cacheObject.getConnectionInfo() != null) {
|
||||
|
||||
if (cacheObject != null && cacheObject.getConnectionInfo() != null) {
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,21 +34,23 @@ public class StatementExecuteMethodsInterceptor implements InstanceMethodsAround
|
|||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
|
||||
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
|
||||
if (cacheObject != null && cacheObject.getConnectionInfo() != null) {
|
||||
ConnectionInfo connectInfo = cacheObject.getConnectionInfo();
|
||||
|
||||
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(connectInfo, method.getName(), cacheObject.getStatementName()), connectInfo.getDatabasePeer());
|
||||
Tags.DB_TYPE.set(span, "sql");
|
||||
Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
|
||||
|
||||
String sql = "";
|
||||
if (allArguments.length > 0) {
|
||||
sql = (String)allArguments[0];
|
||||
String sql = "";
|
||||
if (allArguments.length > 0) {
|
||||
sql = (String)allArguments[0];
|
||||
}
|
||||
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
span.setComponent(connectInfo.getComponent());
|
||||
|
||||
SpanLayer.asDB(span);
|
||||
}
|
||||
|
||||
Tags.DB_STATEMENT.set(span, sql);
|
||||
span.setComponent(connectInfo.getComponent());
|
||||
|
||||
SpanLayer.asDB(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -56,7 +58,7 @@ public class StatementExecuteMethodsInterceptor implements InstanceMethodsAround
|
|||
Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
|
||||
if (cacheObject.getConnectionInfo() != null) {
|
||||
if (cacheObject != null && cacheObject.getConnectionInfo() != null) {
|
||||
ContextManager.stopSpan();
|
||||
}
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
|
||||
import org.apache.skywalking.apm.plugin.jdbc.define.Constants;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
|
@ -33,13 +33,12 @@ import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
|
|||
/**
|
||||
* {@link ConnectionInstrumentation} define that the oracle plugin intercept the following methods that the class which
|
||||
* extend oracle.jdbc.driver.PhysicalConnection
|
||||
*
|
||||
*
|
||||
* 1. Enhance <code>prepareStatement</code> by <code>org.apache.skywalking.apm.plugin.jdbc.oracle.CreatePreparedStatementInterceptor</code>
|
||||
* 2. Enhance <code>prepareCall</code> by <code>org.apache.skywalking.apm.plugin.jdbc.oracle.CreateCallableInterceptor</code>
|
||||
* 3. Enhance <code>createStatement</code> by <code>org.apache.skywalking.apm.plugin.jdbc.oracle.CreateStatementInterceptor</code>
|
||||
* 4. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
|
||||
*
|
||||
*
|
||||
* @author zhangxin
|
||||
*/
|
||||
public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
|
@ -48,6 +47,7 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
|
|||
public static final String PREPARED_STATEMENT_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.oracle.CreatePreparedStatementInterceptor";
|
||||
public static final String CALLABLE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.oracle.CreateCallableInterceptor";
|
||||
public static final String CREATE_STATEMENT_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.oracle.CreateStatementInterceptor";
|
||||
public static final String T4C_CONNECTION_CLASS = "oracle.jdbc.driver.T4CConnection";
|
||||
|
||||
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[0];
|
||||
|
|
@ -111,6 +111,6 @@ public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePlugin
|
|||
}
|
||||
|
||||
@Override protected ClassMatch enhanceClass() {
|
||||
return NameMatch.byName(ENHANCE_CLASS);
|
||||
return MultiClassNameMatch.byMultiClassMatch(ENHANCE_CLASS, T4C_CONNECTION_CLASS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
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;
|
||||
import static org.apache.skywalking.apm.plugin.jdbc.oracle.Constants.PREPARED_STATEMENT_INTERCEPT_CLASS;
|
||||
|
||||
public class OracleCallableInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OracleCallableStatement";
|
||||
public static final String CALLABLE_STATEMENT_WRAPPER_CLASS = "oracle.jdbc.driver.OracleCallableStatementWrapper";
|
||||
public static final String T4C_CALLABLE_STATMENT_CLASS = "oracle.jdbc.driver.T4CCallableStatement";
|
||||
|
||||
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[0];
|
||||
|
|
@ -58,6 +60,6 @@ public class OracleCallableInstrumentation extends ClassInstanceMethodsEnhancePl
|
|||
}
|
||||
|
||||
@Override protected ClassMatch enhanceClass() {
|
||||
return byName(ENHANCE_CLASS);
|
||||
return MultiClassNameMatch.byMultiClassMatch(ENHANCE_CLASS, CALLABLE_STATEMENT_WRAPPER_CLASS, T4C_CALLABLE_STATMENT_CLASS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
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;
|
||||
import static org.apache.skywalking.apm.plugin.jdbc.oracle.Constants.PREPARED_STATEMENT_INTERCEPT_CLASS;
|
||||
|
||||
public class OraclePrepareStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OraclePreparedStatement";
|
||||
public static final String PREPARED_STATEMENT_WRAPPER_CLASS = "oracle.jdbc.driver.OraclePreparedStatementWrapper";
|
||||
public static final String T4C_PREPARED_STATEMENT_CLASS = "oracle.jdbc.driver.T4CPreparedStatement";
|
||||
|
||||
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[0];
|
||||
|
|
@ -59,6 +61,6 @@ public class OraclePrepareStatementInstrumentation extends ClassInstanceMethodsE
|
|||
}
|
||||
|
||||
@Override protected ClassMatch enhanceClass() {
|
||||
return byName(ENHANCE_CLASS);
|
||||
return MultiClassNameMatch.byMultiClassMatch(ENHANCE_CLASS, PREPARED_STATEMENT_WRAPPER_CLASS, T4C_PREPARED_STATEMENT_CLASS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,14 +24,16 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
|
||||
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;
|
||||
import static org.apache.skywalking.apm.plugin.jdbc.oracle.Constants.STATEMENT_INTERCEPT_CLASS;
|
||||
|
||||
public class OracleStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OracleStatement";
|
||||
public static final String STATEMENT_WRAPPER_CLASS = "oracle.jdbc.driver.OracleStatementWrapper";
|
||||
public static final String T4C_STATEMENT_CLASS = "oracle.jdbc.driver.T4CStatement";
|
||||
|
||||
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
|
||||
return new ConstructorInterceptPoint[0];
|
||||
|
|
@ -62,6 +64,6 @@ public class OracleStatementInstrumentation extends ClassInstanceMethodsEnhanceP
|
|||
}
|
||||
|
||||
@Override protected ClassMatch enhanceClass() {
|
||||
return byName(ENHANCE_CLASS);
|
||||
return MultiClassNameMatch.byMultiClassMatch(ENHANCE_CLASS, STATEMENT_WRAPPER_CLASS, T4C_STATEMENT_CLASS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue