Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
5bc3ccde
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5bc3ccde
编写于
12月 06, 2018
作者:
J
Jared.Tan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix conflicts and test case.
上级
2c1d28f4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
53 addition
and
41 deletion
+53
-41
apm-sniffer/apm-test-tools/pom.xml
apm-sniffer/apm-test-tools/pom.xml
+7
-2
apm-sniffer/optional-plugins/trace-ignore-plugin/apm-trace-ignore-plugin.config
...lugins/trace-ignore-plugin/apm-trace-ignore-plugin.config
+1
-1
apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml
apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml
+15
-1
apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java
...apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java
+11
-30
apm-sniffer/optional-plugins/trace-ignore-plugin/src/test/java/org/apache/skywalking/apm/plugin/trace/ignore/TraceIgnoreTest.java
...e/skywalking/apm/plugin/trace/ignore/TraceIgnoreTest.java
+19
-7
未找到文件。
apm-sniffer/apm-test-tools/pom.xml
浏览文件 @
5bc3ccde
...
...
@@ -16,7 +16,8 @@
~
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
...
...
@@ -30,11 +31,15 @@
<name>
apm-test-tools
</name>
<url>
http://maven.apache.org
</url>
<properties>
<junit.version>
4.12
</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<version>
${junit.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
...
...
apm-sniffer/optional-plugins/trace-ignore-plugin/apm-trace-ignore-plugin.config
浏览文件 @
5bc3ccde
...
...
@@ -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
=${
SW_TRACE_IGNORE_PATH
:/
eureka
/**}
\ No newline at end of file
#trace.ignore_path=${SW_AGENT_TRACE_IGNORE_PATH:/eureka/**}
apm-sniffer/optional-plugins/trace-ignore-plugin/pom.xml
浏览文件 @
5bc3ccde
...
...
@@ -16,7 +16,8 @@
~
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
optional-plugins
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
...
...
@@ -29,4 +30,17 @@
<name>
apm-trace-ignore-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<ststem-rules.version>
1.18.0
</ststem-rules.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.github.stefanbirkner
</groupId>
<artifactId>
system-rules
</artifactId>
<version>
${ststem-rules.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/optional-plugins/trace-ignore-plugin/src/main/java/org/apache/skywalking/apm/plugin/trace/ignore/conf/IgnoreConfigInitializer.java
浏览文件 @
5bc3ccde
...
...
@@ -18,28 +18,15 @@
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
java.io.*
;
import
java.util.*
;
import
org.apache.skywalking.apm.agent.core.boot.*
;
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
;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Properties
;
import
org.apache.skywalking.apm.agent.core.logging.api.*
;
import
org.apache.skywalking.apm.util.*
;
/**
*
* @author liujc [liujunc1993@163.com]
*
*/
public
class
IgnoreConfigInitializer
{
private
static
final
ILog
LOGGER
=
LogManager
.
getLogger
(
IgnoreConfigInitializer
.
class
);
...
...
@@ -47,7 +34,8 @@ public class IgnoreConfigInitializer {
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.
* Try to locate `apm-trace-ignore-plugin.config`, which should be in the /optional-plugins/apm-trace-ignore-plugin/
* dictionary of agent package.
* <p>
* 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
...
...
@@ -60,17 +48,11 @@ 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
);
PropertyPlaceholderHelper
helper
=
PropertyPlaceholderHelper
.
INSTANCE
;
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
));
}
properties
.
put
(
key
,
PropertyPlaceholderHelper
.
INSTANCE
.
replacePlaceholders
(
value
,
properties
));
}
ConfigInitializer
.
initialize
(
properties
,
IgnoreConfig
.
class
);
}
catch
(
Exception
e
)
{
...
...
@@ -78,13 +60,13 @@ public class IgnoreConfigInitializer {
}
try
{
overrideConfigBySystem
Env
();
overrideConfigBySystem
Prop
();
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
e
,
"Failed to read the system env."
);
}
}
private
static
void
overrideConfigBySystem
Env
()
throws
IllegalAccessException
{
private
static
void
overrideConfigBySystem
Prop
()
throws
IllegalAccessException
{
Properties
properties
=
new
Properties
();
Properties
systemProperties
=
System
.
getProperties
();
Iterator
<
Map
.
Entry
<
Object
,
Object
>>
entryIterator
=
systemProperties
.
entrySet
().
iterator
();
...
...
@@ -101,7 +83,6 @@ public class IgnoreConfigInitializer {
}
}
/**
* Load the config file, where the agent jar is.
*
...
...
apm-sniffer/optional-plugins/trace-ignore-plugin/src/test/java/org/apache/skywalking/apm/plugin/trace/ignore/TraceIgnoreTest.java
浏览文件 @
5bc3ccde
...
...
@@ -18,22 +18,26 @@
package
org.apache.skywalking.apm.plugin.trace.ignore
;
import
java.util.Properties
;
import
org.apache.skywalking.apm.agent.core.boot.ServiceManager
;
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.context.TracingContext
;
import
org.apache.skywalking.apm.agent.core.context.*
;
import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule
;
import
org.apache.skywalking.apm.plugin.trace.ignore.conf.IgnoreConfig
;
import
org.junit.Assert
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.apache.skywalking.apm.util.*
;
import
org.junit.*
;
import
org.junit.contrib.java.lang.system.EnvironmentVariables
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
/**
* @author liujc [liujunc1993@163.com]
*/
public
class
TraceIgnoreTest
{
@Rule
public
final
EnvironmentVariables
environmentVariables
=
new
EnvironmentVariables
().
set
(
"SW_AGENT_TRACE_IGNORE_PATH"
,
"path_test"
);
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
...
...
@@ -54,4 +58,12 @@ public class TraceIgnoreTest {
Assert
.
assertEquals
(
TracingContext
.
class
,
traceContext
.
getClass
());
}
@Test
public
void
testTraceIgnoreConfigOverridingFromSystemEnv
()
throws
IllegalAccessException
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"trace.ignore_path"
,
"${SW_AGENT_TRACE_IGNORE_PATH:/path/eureka/**}"
);
properties
.
put
(
"trace.ignore_path"
,
PropertyPlaceholderHelper
.
INSTANCE
.
replacePlaceholders
((
String
)
properties
.
get
(
"trace.ignore_path"
),
properties
));
ConfigInitializer
.
initialize
(
properties
,
IgnoreConfig
.
class
);
assertThat
(
IgnoreConfig
.
Trace
.
IGNORE_PATH
,
is
(
"path_test"
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录