add system env for trace ignore plugin

This commit is contained in:
lixin40 2018-11-30 12:12:05 +08:00
parent 5577f67de7
commit efad1165f5
2 changed files with 16 additions and 1 deletions

View File

@ -20,4 +20,4 @@
# /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/**
#trace.ignore_path=${SW_TRACE_IGNORE_PATH:/eureka/**}

View File

@ -24,6 +24,9 @@ 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 org.apache.skywalking.apm.util.PlaceholderConfigurerSupport;
import org.apache.skywalking.apm.util.PropertyPlaceholderHelper;
import org.apache.skywalking.apm.util.StringUtil;
import java.io.File;
import java.io.FileInputStream;
@ -57,6 +60,18 @@ public class IgnoreConfigInitializer {
configFileStream = loadConfigFromAgentFolder();
Properties properties = new Properties();
properties.load(configFileStream);
PropertyPlaceholderHelper helper =
new PropertyPlaceholderHelper(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
for (String key : properties.stringPropertyNames()) {
String value = (String)properties.get(key);
//replace the key's value. properties.replace(key,value) in jdk8+
value = helper.replacePlaceholders(value, properties);
if (!StringUtil.isEmpty(value)) {
properties.put(key, helper.replacePlaceholders(value, properties));
}
}
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.");