diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/pom.xml b/apm-sniffer/optional-plugins/optional-spring-plugins/pom.xml
index b6129a640..bf573e83b 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/pom.xml
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/pom.xml
@@ -27,12 +27,13 @@
pomoptional-spring-plugins
-
- ${project.build.directory}/../../../../../skywalking-agent/optional-plugins
- spring-annotation-plugin
+
+ /..
+
+
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/pom.xml b/apm-sniffer/optional-plugins/pom.xml
index 9e7c01054..bd56ad773 100644
--- a/apm-sniffer/optional-plugins/pom.xml
+++ b/apm-sniffer/optional-plugins/pom.xml
@@ -30,12 +30,16 @@
net.bytebuddy${shade.package}.${shade.net.bytebuddy.source}
+ UTF-8
- ${project.build.directory}/../../../../skywalking-agent/optional-plugins
+
+ ${project.build.directory}${sdk.plugin.related.dir}/../../../../skywalking-agent
+ ${agent.package.dest.dir}/optional-pluginsoptional-spring-plugins
+ trace-ignore-plugin
@@ -101,11 +105,10 @@
-
-
+
+
-
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/README.md b/apm-sniffer/optional-plugins/trace-ignore-plugin/README.md
new file mode 100644
index 000000000..b6950a9ea
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/README.md
@@ -0,0 +1,6 @@
+#How to use trace ignore plugin
+Please copy the apm-trace-ignore-plugin-x.jar to `agent/plugins`
+
+## How to set config
+ 1. This plugin support reading config from environment variables(The env key must start with `skywalking.`, the reuslt should be as same as in `apm-trace-ignore-plugin.config`)
+ 2. Or you can copy the `apm-trace-ignore-plugin.config` to `agent/config` then you'll set you need ignore paths in `apm-trace-ignore-plugin.config`
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/apm-trace-ignore-plugin.config b/apm-sniffer/optional-plugins/trace-ignore-plugin/apm-trace-ignore-plugin.config
new file mode 100644
index 000000000..acb31c74d
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/apm-trace-ignore-plugin.config
@@ -0,0 +1,23 @@
+# 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.
+
+# If the operation name of the first span is matching, this segment should be ignored
+# ant path match style
+# /path/? Match any single character
+# /path/* Match any number of characters
+# /path/** Match any number of characters and support multilevel directories
+# Multiple path comma separation, like trace.ignore_path=/eureka/**,/consul/**
+#trace.ignore_path=/eureka/**
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml b/apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml
new file mode 100644
index 000000000..d348501ca
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml
@@ -0,0 +1,62 @@
+
+
+
+
+ optional-plugins
+ org.apache.skywalking
+ 5.0.0-beta2-SNAPSHOT
+
+ 4.0.0
+
+ apm-trace-ignore-plugin
+ jar
+
+ apm-trace-ignore-plugin
+ http://maven.apache.org
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+
+
+ package
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/TraceIgnoreExtendService.java b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/TraceIgnoreExtendService.java
new file mode 100644
index 000000000..2c88a1d1d
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/TraceIgnoreExtendService.java
@@ -0,0 +1,80 @@
+/*
+ * 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.trace.ignore;
+
+import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
+import org.apache.skywalking.apm.agent.core.boot.OverrideImplementor;
+import org.apache.skywalking.apm.agent.core.conf.ConfigNotFoundException;
+import org.apache.skywalking.apm.agent.core.context.AbstractTracerContext;
+import org.apache.skywalking.apm.agent.core.context.ContextManagerExtendService;
+import org.apache.skywalking.apm.agent.core.context.IgnoredTracerContext;
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.plugin.trace.ignore.conf.IgnoreConfig;
+import org.apache.skywalking.apm.plugin.trace.ignore.conf.IgnoreConfigInitializer;
+import org.apache.skywalking.apm.plugin.trace.ignore.matcher.AntPathMatcher;
+import org.apache.skywalking.apm.plugin.trace.ignore.matcher.TracePathMatcher;
+import org.apache.skywalking.apm.util.StringUtil;
+
+/**
+ *
+ * @author liujc [liujunc1993@163.com]
+ *
+ */
+@OverrideImplementor(ContextManagerExtendService.class)
+public class TraceIgnoreExtendService extends ContextManagerExtendService {
+
+ private static final ILog LOGGER = LogManager.getLogger(TraceIgnoreExtendService.class);
+
+ private static final String DEFAULT_PATH_SEPARATOR = "/";
+
+ private static final String PATTERN_SEPARATOR = ",";
+
+ private TracePathMatcher pathMatcher = new AntPathMatcher();
+
+ @Override
+ public void boot() {
+ try {
+ IgnoreConfigInitializer.initialize();
+ } catch (ConfigNotFoundException e) {
+ LOGGER.error("trace ignore config init error", e);
+ } catch (AgentPackageNotFoundException e) {
+ LOGGER.error("trace ignore config init error", e);
+ }
+ }
+
+ @Override
+ public AbstractTracerContext createTraceContext(String operationName, boolean forceSampling) {
+ String pattens = IgnoreConfig.Trace.IGNORE_PATH;
+ if (!StringUtil.isEmpty(pattens) && !forceSampling) {
+ String path = operationName;
+ if (!StringUtil.isEmpty(path) && path.length() > 1 && path.endsWith(DEFAULT_PATH_SEPARATOR)) {
+ path = path.substring(0, path.length() - 1);
+ }
+
+ for (String pattern : pattens.split(PATTERN_SEPARATOR)) {
+ if (pathMatcher.match(pattern, path)) {
+ LOGGER.debug("operationName : " + operationName + " Ignore tracking");
+ return new IgnoredTracerContext();
+ }
+ }
+ }
+ return super.createTraceContext(operationName, forceSampling);
+ }
+}
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfig.java b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfig.java
new file mode 100644
index 000000000..f317ac2b4
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfig.java
@@ -0,0 +1,37 @@
+/*
+ * 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.trace.ignore.conf;
+
+/**
+ *
+ * @author liujc [liujunc1993@163.com]
+ *
+ */
+public class IgnoreConfig {
+
+ public static class Trace {
+ /**
+ * If the operation name of the first span is matching, this segment should be ignored
+ * /path/? Match any single character
+ * /path/* Match any number of characters
+ * /path/** Match any number of characters and support multilevel directories
+ */
+ public static String IGNORE_PATH = "";
+ }
+}
diff --git a/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java
new file mode 100644
index 000000000..af8f599ea
--- /dev/null
+++ b/apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java
@@ -0,0 +1,107 @@
+/*
+ * 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.trace.ignore.conf;
+
+import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
+import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
+import org.apache.skywalking.apm.agent.core.conf.ConfigNotFoundException;
+import org.apache.skywalking.apm.agent.core.logging.api.ILog;
+import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
+import org.apache.skywalking.apm.util.ConfigInitializer;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ *
+ * @author liujc [liujunc1993@163.com]
+ *
+ */
+public class IgnoreConfigInitializer {
+ private static final ILog LOGGER = LogManager.getLogger(IgnoreConfigInitializer.class);
+ private static String CONFIG_FILE_NAME = "/config/apm-trace-ignore-plugin.config";
+ private static String ENV_KEY_PREFIX = "skywalking.";
+
+ /**
+ * Try to locate `apm-trace-ignore-plugin.config`, which should be in the /optional-plugins/apm-trace-ignore-plugin/ dictionary of agent package.
+ *
+ * Also try to override the config by system.env and system.properties. All the keys in these two places should
+ * start with {@link #ENV_KEY_PREFIX}. e.g. in env `skywalking.trace.ignore_path=your_path` to override
+ * `trace.ignore_path` in apm-trace-ignore-plugin.config file.
+ *
+ */
+ public static void initialize() throws ConfigNotFoundException, AgentPackageNotFoundException {
+ InputStream configFileStream;
+ try {
+ configFileStream = loadConfigFromAgentFolder();
+ Properties properties = new Properties();
+ properties.load(configFileStream);
+ ConfigInitializer.initialize(properties, IgnoreConfig.class);
+ } catch (Exception e) {
+ LOGGER.error(e, "Failed to read the config file, skywalking is going to run in default config.");
+ }
+
+ try {
+ overrideConfigBySystemEnv();
+ } catch (Exception e) {
+ LOGGER.error(e, "Failed to read the system env.");
+ }
+ }
+
+ private static void overrideConfigBySystemEnv() throws IllegalAccessException {
+ Properties properties = new Properties();
+ Properties systemProperties = System.getProperties();
+ Iterator> entryIterator = systemProperties.entrySet().iterator();
+ while (entryIterator.hasNext()) {
+ Map.Entry