stone-wlg commented on a change in pull request #3330: Cassandra 3.x Plugin
URL: https://github.com/apache/skywalking/pull/3330#discussion_r319727364
 
 

 ##########
 File path: 
apm-sniffer/apm-sdk-plugin/cassandra-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/cassandra/v3/define/SessionInstrumentation.java
 ##########
 @@ -0,0 +1,72 @@
+/*
+ * 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.cassandra.v3.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.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static 
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+/**
+ * @author stone.wlg
+ */
+public class SessionInstrumentation extends 
ClassInstanceMethodsEnhancePluginDefine {
+
+    private static final String ENHANCE_CLASS = 
"com.datastax.driver.core.SessionManager";
+    private static final String 
SESSION_EXECUTE_ASYNC_WITH_STATEMENT_INTERCEPT_CLASS = 
"org.apache.skywalking.apm.plugin.cassandra.v3.SessionExecuteAsyncWithStatementArgInterceptor";
+
+    @Override
+    protected ClassMatch enhanceClass() {
+        return byName(ENHANCE_CLASS);
+    }
+
+    @Override
+    public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+        return null;
+    }
+
+    @Override
+    public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() 
{
+        return new InstanceMethodsInterceptPoint[]{
+            new InstanceMethodsInterceptPoint() {
+                @Override
+                public ElementMatcher<MethodDescription> getMethodsMatcher() {
+                    return named("executeAsync")
+                        .and(takesArgumentWithType(0, 
"com.datastax.driver.core.Statement"));
 
 Review comment:
   > LGTM.
   > 
   > What guard have you if this method changes (or an alternative method is 
added) in a future version of the java-driver? How thorough are the tests in 
running through all the different execute and executeAsync variations?
   > 
   > Otherwise, @kezhenxu94 talks about how this only captures the entry point 
to the call to Cassandra. The result is a (subclass of a) Future.
   > Can the first implementation of the Cassandra plugin ignore the exit 
point? (you lose timing and success/failure status, but it's a start)
   > Otherwise can you intercept on the future's success and failure methods 
(and somehow connect the threads)?
   
   i think i should rename cassandra-3.x-plugin with 
cassandra-java-driver-3.x-plugin. it solve future version of the java-driver. 
ex: cassandra-java-driver-4.x-plugin in future
   
   @wu-sheng could we start with a simple without timing and success / failure 
status, and the async api. i am not familiar with skywalking even i read the 
document but it is too simple, there is not enough sample to tell us how to use 
async api. :)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to