You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/06/14 07:57:10 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #7099: feat: add neo4j-4.x-plugin

wu-sheng commented on a change in pull request #7099:
URL: https://github.com/apache/skywalking/pull/7099#discussion_r650501047



##########
File path: docs/en/setup/service-agent/java-agent/Supported-list.md
##########
@@ -13,15 +14,17 @@ metrics based on the tracing data.
   * [Resin](http://www.caucho.com/resin-4.0/) 3 (Optional¹)
   * [Resin](http://www.caucho.com/resin-4.0/) 4 (Optional¹)
   * [Jetty Server](http://www.eclipse.org/jetty/) 9
-  * [Spring WebFlux](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) 5.x (Optional¹)
+  * [Spring WebFlux](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html)
+    5.x (Optional¹)

Review comment:
       I don't think this change is expected, same as following changes of this file.

##########
File path: apm-sniffer/apm-sdk-plugin/pom.xml
##########
@@ -17,7 +17,9 @@
   ~
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

Review comment:
       The format is not expected to change.

##########
File path: test/plugin/scenarios/neo4j-4.x-scenario/support-version.list
##########
@@ -0,0 +1,24 @@
+# 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.
+
+4.0.0
+4.0.3
+4.1.0
+4.1.2
+4.2.0
+4.2.3
+4.2.5
+4.3.0

Review comment:
       We usually keep one version per min version. So 4.0.0, 4.1.0, 4.2.0, 4.2.5 should be removed from here.

##########
File path: docs/en/setup/service-agent/java-agent/Supported-list.md
##########
@@ -1,6 +1,7 @@
 # Tracing and Tracing based Metrics Analyze Plugins
-The following plugins provide the distributed tracing capability, and the OAP backend would analyze the topology and 
-metrics based on the tracing data.
+
+The following plugins provide the distributed tracing capability, and the OAP backend would analyze
+the topology and metrics based on the tracing data.

Review comment:
       Don't format this document in a feature-related PR. If you want to fix the format issue, please submit another separate one.

##########
File path: apm-sniffer/apm-sdk-plugin/neo4j-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/neo4j/v4x/SessionConstructorInterceptor.java
##########
@@ -0,0 +1,43 @@
+/*
+ * 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.neo4j.v4x;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+
+/**
+ * This constructor interceptor is used to create {@link SessionRequiredInfo} object and save it in skywalking dynamic
+ * field.
+ */
+public class SessionConstructorInterceptor implements InstanceConstructorInterceptor {
+
+    @Override
+    public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
+        final Object databaseNameArg = allArguments[2];
+        if (databaseNameArg == null) {

Review comment:
       When this could be `null`? If this is not expected, we should not intercept this method.

##########
File path: apm-sniffer/apm-sdk-plugin/neo4j-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/neo4j/v4x/SessionBeginTransactionInterceptor.java
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.neo4j.v4x;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.CompletionStage;
+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;
+
+/**
+ * This interceptor is used to propagate the context snapshot in {@link SessionRequiredInfo} after {@link
+ * org.neo4j.driver.internal.async.NetworkSession#beginTransactionAsync}
+ * method is invoked.
+ */
+public class SessionBeginTransactionInterceptor 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 == null) {
+            return null;
+        }

Review comment:
       We need explanations for all these `==null`.

##########
File path: oap-server/server-bootstrap/src/main/resources/component-libraries.yml
##########
@@ -365,6 +365,9 @@ tcp:
 AzureHttpTrigger:
   id: 111
   languages: Java,C#,Node.js,Python
+Neo4j:
+  id: 112
+  languages: Java,Golang,C#,Python,JavaScript

Review comment:
       ```suggestion
     languages: Java
   ```
   
   We don't have plugin of neo4j in other languages.

##########
File path: apm-sniffer/apm-sdk-plugin/neo4j-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/neo4j/v4x/Neo4jPluginConfig.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.neo4j.v4x;
+
+import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
+
+public class Neo4jPluginConfig {
+
+    public static class Plugin {
+
+        @PluginConfig(root = Neo4jPluginConfig.class)
+        public static class Neo4j {
+
+            /**
+             * If set to true, the parameters of the cypher would be collected.
+             */
+            public static boolean TRACE_CYPHER_PARAMETERS = false;
+            /**
+             * For the sake of performance, SkyWalking won't save the entire parameters string into the tag, but only
+             * the first {@code CYPHER_PARAMETERS_MAX_LENGTH} characters.
+             * <p>
+             * Set a negative number to save the complete parameter string to the tag.
+             */
+            public static int CYPHER_PARAMETERS_MAX_LENGTH = 512;
+            /**
+             * For the sake of performance, SkyWalking won't save the entire sql body into the tag, but only the first
+             * {@code CYPHER_BODY_MAX_LENGTH} characters.
+             * <p>
+             * Set a negative number to save the complete sql body to the tag.
+             */
+            public static int CYPHER_BODY_MAX_LENGTH = 2048;

Review comment:
       All these are missing in the agent setup doc. No one would know how to use these unless reading source codes.




-- 
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:
users@infra.apache.org