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 2020/09/02 02:02:20 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #5426: exception-ignore-plugin

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



##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
##########
@@ -96,6 +99,8 @@
      */
     protected boolean skipAnalysis;
 
+    protected String exceptionKind = "";

Review comment:
       This could be overridden, such as two exceptions happened. 

##########
File path: apm-sniffer/optional-plugins/exception-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/exception/ignore/ExceptionIgnorerService.java
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.exception.ignore;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.ClassPath;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.skywalking.apm.agent.core.boot.OverrideImplementor;
+import org.apache.skywalking.apm.agent.core.context.DefaultExceptionIgnorerService;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.apache.skywalking.apm.agent.core.plugin.PluginBootstrap;
+import org.apache.skywalking.apm.toolkit.trace.IgnoredException;
+import org.apache.skywalking.apm.util.StringUtil;
+
+import static org.apache.skywalking.apm.plugin.exception.ignore.ExceptionAnalyzerConfig.Plugin.IgnoredException.IGNORED_EXCEPTION_CLASS_NAMES;
+import static org.apache.skywalking.apm.plugin.exception.ignore.ExceptionAnalyzerConfig.Plugin.IgnoredException.IGNORED_EXCEPTION_SCAN_SCOPE;
+
+@OverrideImplementor(DefaultExceptionIgnorerService.class)
+public class ExceptionIgnorerService extends DefaultExceptionIgnorerService {
+
+    private final Set<String> exceptionClassNames = new HashSet<>();
+
+    @Override
+    public void prepare() throws Throwable {
+        if (StringUtil.isNotEmpty(IGNORED_EXCEPTION_CLASS_NAMES)) {
+            exceptionClassNames.addAll(Arrays.asList(IGNORED_EXCEPTION_CLASS_NAMES.split(",")));
+        }
+        if (StringUtil.isNotEmpty(IGNORED_EXCEPTION_SCAN_SCOPE)) {
+            ClassPath classpath = ClassPath.from(PluginBootstrap.class.getClassLoader());
+            ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClasses(IGNORED_EXCEPTION_SCAN_SCOPE);

Review comment:
       We can't do this in the agent, because some classes are not in this classloader, such as in Tomcat case, all user exception classes can't be scanned.

##########
File path: apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractSpan.java
##########
@@ -62,6 +62,10 @@
 
     AbstractSpan errorOccurred();
 
+    AbstractSpan undoErrorOccurred();
+
+    String exceptionKind();

Review comment:
       Adding two methods in the core level is unexpected. Usually, the span APIs are not providing capabilities to read fields.




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