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 03:51:39 UTC

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

kezhenxu94 commented on a change in pull request #5426:
URL: https://github.com/apache/skywalking/pull/5426#discussion_r481628017



##########
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:
       > In my mind , user would be like to add a new ignored exception by @IgnoredException annotation rather than change skywalking agent config frequency.
   
   I don't agree, for those exceptions thrown by some frameworks, users cannot do anything to ignore them but only change the agent config, and I suppose that's a common case where users want to ignore exceptions from frameworks, if they have control to where the exceptions are thrown, they can choose not to throw the exceptions and only log some errors




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