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



##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/status/AnnotationMatchExceptionCheckStrategy.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.agent.core.context.status;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+
+public class AnnotationMatchExceptionCheckStrategy implements 
ExceptionCheckStrategy {
+
+    private final Set<Class<? extends Throwable>> ignoredExceptions = new 
CopyOnWriteArraySet<>();
+    private final Set<Class<? extends Throwable>> exceptions = new 
CopyOnWriteArraySet<>();

Review comment:
       ```suggestion
       private final Set<Class<? extends Throwable>> errorStatusExceptions = 
new CopyOnWriteArraySet<>();
   ```

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
##########
@@ -268,6 +267,19 @@
         public static String PATTERN = "%level %timestamp %thread %class : 
%msg %throwable";
     }
 
+    public static class StatusCheck {
+        /**
+         * Ignored exception list, also affect their subclasses.
+         */
+        public static String IGNORED_EXCEPTIONS = "";
+
+        /**
+         * Agent would do hierarchy check for the exception unless the 
max_recursive_depth equals to 0.And -1 means no limit.

Review comment:
       Don't provide no limitation. That could cause OOM

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/status/AnnotationMatchExceptionCheckStrategy.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.agent.core.context.status;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+
+public class AnnotationMatchExceptionCheckStrategy implements 
ExceptionCheckStrategy {
+
+    private final Set<Class<? extends Throwable>> ignoredExceptions = new 
CopyOnWriteArraySet<>();

Review comment:
       @kezhenxu94 @EvanLjp Any of you know the performance difference between 
`CopyOnWriteArraySet` and `ConcurrentHashMap`? This check is highly performance 
sensitive.

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
##########
@@ -268,6 +267,19 @@
         public static String PATTERN = "%level %timestamp %thread %class : 
%msg %throwable";
     }
 
+    public static class StatusCheck {
+        /**
+         * Ignored exception list, also affect their subclasses.
+         */
+        public static String IGNORED_EXCEPTIONS = "";
+
+        /**
+         * Agent would do hierarchy check for the exception unless the 
max_recursive_depth equals to 0.And -1 means no limit.

Review comment:
       All negative value should be considered as 0.

##########
File path: 
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/status/AnnotationMatchExceptionCheckStrategy.java
##########
@@ -0,0 +1,48 @@
+/*
+ * 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.agent.core.context.status;
+
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+import 
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+
+public class AnnotationMatchExceptionCheckStrategy implements 
ExceptionCheckStrategy {
+
+    private final Set<Class<? extends Throwable>> ignoredExceptions = new 
CopyOnWriteArraySet<>();
+    private final Set<Class<? extends Throwable>> exceptions = new 
CopyOnWriteArraySet<>();
+    private static final String TAG_NAME = 
AnnotationMatchExceptionCheckStrategy.class.getSimpleName();
+
+    @Override
+    public boolean isError(final Throwable e) {
+        Class<? extends Throwable> clazz = e.getClass();
+        if (ignoredExceptions.contains(clazz)) {
+            return false;
+        }
+        if (exceptions.contains(clazz)) {
+            return true;
+        }
+        if (e instanceof EnhancedInstance && ((EnhancedInstance) 
e).getSkyWalkingDynamicField().equals(TAG_NAME)) {

Review comment:
       Use `TAG_NAME.equals...` to avoid NPE.




----------------------------------------------------------------
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]


Reply via email to