You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/02/01 00:58:17 UTC
[GitHub] wu-sheng closed pull request #786: [Agent] Change the enhance way of oracle plugin
wu-sheng closed pull request #786: [Agent] Change the enhance way of oracle plugin
URL: https://github.com/apache/incubator-skywalking/pull/786
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/Constants.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/Constants.java
new file mode 100644
index 000000000..3a4e72de0
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/Constants.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
+
+/**
+ * Constants variables
+ *
+ * @author zhang xin
+ */
+public final class Constants {
+ public static final String STATEMENT_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.oracle.StatementExecuteMethodsInterceptor";
+
+ public static final String PREPARED_STATEMENT_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jdbc.oracle.PreparedStatementExecuteMethodsInterceptor";
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateCallableInterceptor.java
similarity index 55%
rename from apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateCallableInterceptor.java
index 06ccae6d6..d526ac506 100644
--- a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateCallableInterceptor.java
@@ -16,26 +16,16 @@
*
*/
-package oracle.jdbc.driver;
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
-import org.apache.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement;
-/**
- * {@link JDBCPrepareStatementWithArrayInterceptor} return {@link SWPreparedStatement} instance that wrapper the real
- * preparedStatement instance when the client call <code>oracle.jdbc.driver.PhysicalConnection#prepareStatement(String,
- * int[])</code> method or <code>oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])</code>
- * method.
- *
- * @author zhangxin
- */
-public class JDBCPrepareStatementWithArrayInterceptor implements InstanceMethodsAroundInterceptor {
+public class CreateCallableInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
@@ -45,19 +35,10 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
- /**
- * To prevent the <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method from repeating
- * interceptor, Because PGConnection call <code>org.postgresql.jdbc.prepareStatement(String sql)</code> method when
- * the second argument is empty.
- *
- * @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, int[])
- * @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])
- **/
- String sql = (String)allArguments[0];
- if (!AutoKeyInfo.isInsertSqlStmt(sql)) {
- return ret;
+ if (ret instanceof EnhancedInstance) {
+ ((EnhancedInstance)ret).setSkyWalkingDynamicField(new StatementEnhanceInfos((ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0], "CallableStatement"));
}
- return new SWPreparedStatement((Connection)objInst, (PreparedStatement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0]);
+ return ret;
}
@Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreatePreparedStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreatePreparedStatementInterceptor.java
new file mode 100644
index 000000000..9c8a2ba3b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreatePreparedStatementInterceptor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
+import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+
+public class CreatePreparedStatementInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (ret instanceof EnhancedInstance) {
+ ((EnhancedInstance)ret).setSkyWalkingDynamicField(new StatementEnhanceInfos((ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0], "PreparedStatement"));
+ }
+ return ret;
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateStatementInterceptor.java
new file mode 100644
index 000000000..ea2b95cad
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/CreateStatementInterceptor.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
+import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+
+public class CreateStatementInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (ret instanceof EnhancedInstance) {
+ ((EnhancedInstance)ret).setSkyWalkingDynamicField(new StatementEnhanceInfos((ConnectionInfo)objInst.getSkyWalkingDynamicField(), "", "Statement"));
+ }
+ return ret;
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/PreparedStatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/PreparedStatementExecuteMethodsInterceptor.java
new file mode 100644
index 000000000..065333931
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/PreparedStatementExecuteMethodsInterceptor.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
+import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+
+/**
+ * @author zhang xin
+ */
+public class PreparedStatementExecuteMethodsInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ 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);
+ }
+
+ @Override
+ public final Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes,
+ Object ret) throws Throwable {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ if (cacheObject.getConnectionInfo() != null) {
+ ContextManager.stopSpan();
+ }
+ return ret;
+ }
+
+ @Override public final void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ if (cacheObject.getConnectionInfo() != null) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ }
+ }
+
+ private String buildOperationName(ConnectionInfo connectionInfo, String methodName, String statementName) {
+ return connectionInfo.getDBType() + "/JDBI/" + statementName + "/" + methodName;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/StatementExecuteMethodsInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/StatementExecuteMethodsInterceptor.java
new file mode 100644
index 000000000..df6668e39
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/StatementExecuteMethodsInterceptor.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.jdbc.define.StatementEnhanceInfos;
+import org.apache.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+
+public class StatementExecuteMethodsInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ 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());
+
+ String sql = "";
+ if (allArguments.length > 0) {
+ sql = (String)allArguments[0];
+ }
+
+ Tags.DB_STATEMENT.set(span, sql);
+ span.setComponent(connectInfo.getComponent());
+
+ SpanLayer.asDB(span);
+ }
+
+ @Override
+ public final Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes,
+ Object ret) throws Throwable {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ if (cacheObject.getConnectionInfo() != null) {
+ ContextManager.stopSpan();
+ }
+ return ret;
+ }
+
+ @Override public final void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ StatementEnhanceInfos cacheObject = (StatementEnhanceInfos)objInst.getSkyWalkingDynamicField();
+ if (cacheObject.getConnectionInfo() != null) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ }
+ }
+
+ private String buildOperationName(ConnectionInfo connectionInfo, String methodName, String statementName) {
+ return connectionInfo.getDBType() + "/JDBI/" + statementName + "/" + methodName;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
index 7533ae68d..f4542100f 100644
--- a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
@@ -16,12 +16,10 @@
*
*/
-
package org.apache.skywalking.apm.plugin.jdbc.oracle.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch;
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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
@@ -33,28 +31,23 @@
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
/**
- * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
- * oracle.jdbc.driver.PhysicalConnection}. <br/>
- *
- * 1. Enhance <code>prepareStatement</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor</code>
- * 2. Enhance <code>prepareStatement</code> that the seconds argument type is <code>java.lang.String[]</code> by
- * <code>oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor</code>
- * 3. Enhance <code>prepareStatement</code> that the seconds argument type is <code>int[]</code> by
- * <code>oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor</code>
- * 4. Enhance <code>prepareCall</code> by
- * <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor</code>
- * 5. Enhance <code>createStatement</code>
- * by <code>org.apache.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor</code>
- * 6. Enhance <code>commit, rollback, close, releaseSavepoint</code> by <code>org.apache.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor</code>
+ * {@link ConnectionInstrumentation} define that the oracle plugin intercept the following methods that the class which
+ * extend {@link oracle.jdbc.driver.PhysicalConnection}. <br/>
+ * <pre>
+ * 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>
+ * </pre>
*
* @author zhangxin
*/
public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS = "oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor";
public static final String ENHANCE_CLASS = "oracle.jdbc.driver.PhysicalConnection";
- public static final String STRING_ARRAY_ARGUMENT_TYPE = "java.lang.String[]";
- public static final String INT_ARRAY_ARGUMENT_TYPE = "int[]";
+ 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";
@Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
@@ -64,37 +57,11 @@
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named(Constants.PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(3));
- }
-
- @Override public String getMethodsInterceptor() {
- return Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named(Constants.PREPARE_STATEMENT_METHOD_NAME).and(ArgumentTypeNameMatch.takesArgumentWithType(1, STRING_ARRAY_ARGUMENT_TYPE));
- }
-
- @Override public String getMethodsInterceptor() {
- return PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS;
- }
-
- @Override public boolean isOverrideArgs() {
- return false;
- }
- },
- new InstanceMethodsInterceptPoint() {
- @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
- return named(Constants.PREPARE_STATEMENT_METHOD_NAME).and(ArgumentTypeNameMatch.takesArgumentWithType(1, INT_ARRAY_ARGUMENT_TYPE));
+ return named(Constants.PREPARE_STATEMENT_METHOD_NAME);
}
@Override public String getMethodsInterceptor() {
- return PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS;
+ return PREPARED_STATEMENT_INTERCEPT_CLASS;
}
@Override public boolean isOverrideArgs() {
@@ -107,7 +74,7 @@
}
@Override public String getMethodsInterceptor() {
- return Constants.PREPARE_CALL_INTERCEPT_CLASS;
+ return CALLABLE_INTERCEPT_CLASS;
}
@Override public boolean isOverrideArgs() {
@@ -120,7 +87,7 @@
}
@Override public String getMethodsInterceptor() {
- return Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
}
@Override public boolean isOverrideArgs() {
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleCallableInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleCallableInstrumentation.java
new file mode 100644
index 000000000..1d0be4a5e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleCallableInstrumentation.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+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;
+
+/**
+ * {@link OracleCallableInstrumentation} define that the oracle plugin intercept the <code>execute, executeQuery and
+ * executeUpdate</code> method in {@link oracle.jdbc.driver.OracleCallableStatement} class by ${@link
+ * org.apache.skywalking.apm.plugin.jdbc.oracle.StatementExecuteMethodsInterceptor}
+ *
+ * @author zhangxin
+ */
+public class OracleCallableInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OracleCallableStatement";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named("execute")
+ .or(named("executeQuery"))
+ .or(named("executeUpdate"));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARED_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OraclePrepareStatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OraclePrepareStatementInstrumentation.java
new file mode 100644
index 000000000..093ded3eb
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OraclePrepareStatementInstrumentation.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+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;
+
+/**
+ * {@link OraclePrepareStatementInstrumentation} define that the oracle plugin intercept the <code>execute,
+ * executeQuery, executeUpdate and executeLargeUpdate</code> method in {@link oracle.jdbc.driver.OraclePreparedStatement}
+ * class by ${@link org.apache.skywalking.apm.plugin.jdbc.oracle.StatementExecuteMethodsInterceptor}
+ *
+ * @author zhangxin
+ */
+public class OraclePrepareStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OraclePreparedStatement";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named("execute")
+ .or(named("executeQuery"))
+ .or(named("executeUpdate"))
+ .or(named("executeLargeUpdate"));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARED_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleStatementInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleStatementInstrumentation.java
new file mode 100644
index 000000000..94c15f2c7
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jdbc/oracle/define/OracleStatementInstrumentation.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.jdbc.oracle.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+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.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+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;
+
+/**
+ * {@link OracleStatementInstrumentation} define that the oracle plugin intercept the <code>execute, executeQuery,
+ * executeUpdate and executeLargeUpdate</code> method in {@link oracle.jdbc.driver.OracleStatement} class by ${@link
+ * org.apache.skywalking.apm.plugin.jdbc.oracle.StatementExecuteMethodsInterceptor}
+ *
+ * @author zhangxin
+ */
+public class OracleStatementInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "oracle.jdbc.driver.OracleStatement";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named("execute")
+ .or(named("executeQuery"))
+ .or(named("executeUpdate"))
+ .or(named("executeLargeUpdate"))
+ .or(named("executeBatchInternal"))
+ .or(named("executeUpdateInternal"))
+ .or(named("executeQuery"));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
index 3a3b19358..8b6dd1307 100644
--- a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
@@ -1,2 +1,5 @@
oracle-10.x=org.apache.skywalking.apm.plugin.jdbc.oracle.define.DriverInstrumentation
oracle-10.x=org.apache.skywalking.apm.plugin.jdbc.oracle.define.ConnectionInstrumentation
+oracle-10.x=org.apache.skywalking.apm.plugin.jdbc.oracle.define.OracleCallableInstrumentation
+oracle-10.x=org.apache.skywalking.apm.plugin.jdbc.oracle.define.OraclePrepareStatementInstrumentation
+oracle-10.x=org.apache.skywalking.apm.plugin.jdbc.oracle.define.OracleStatementInstrumentation
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services