Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
04771ffc
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
04771ffc
编写于
10月 18, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjust log APIs.
上级
030f7c63
变更
51
隐藏空白更改
内联
并排
Showing
51 changed file
with
152 addition
and
323 deletion
+152
-323
apm-commons/apm-logging-api/pom.xml
apm-commons/apm-logging-api/pom.xml
+0
-31
apm-commons/apm-logging-api/src/test/java/org/skywalking/apm/logging/LogManagerTest.java
.../test/java/org/skywalking/apm/logging/LogManagerTest.java
+0
-107
apm-commons/apm-logging-api/src/test/java/org/skywalking/apm/logging/NoopLoggerTest.java
.../test/java/org/skywalking/apm/logging/NoopLoggerTest.java
+0
-44
apm-commons/pom.xml
apm-commons/pom.xml
+0
-1
apm-sniffer/apm-agent-core/pom.xml
apm-sniffer/apm-agent-core/pom.xml
+0
-5
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/boot/AgentPackagePath.java
.../org/skywalking/apm/agent/core/boot/AgentPackagePath.java
+12
-4
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/boot/ServiceManager.java
...va/org/skywalking/apm/agent/core/boot/ServiceManager.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java
.../main/java/org/skywalking/apm/agent/core/conf/Config.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
...walking/apm/agent/core/conf/SnifferConfigInitializer.java
+24
-21
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
...org/skywalking/apm/agent/core/context/ContextManager.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java
...skywalking/apm/agent/core/context/trace/TraceSegment.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/JVMService.java
...in/java/org/skywalking/apm/agent/core/jvm/JVMService.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java
...va/org/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api/ILog.java
.../java/org/skywalking/apm/agent/core/logging/api/ILog.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api/LogManager.java
...org/skywalking/apm/agent/core/logging/api/LogManager.java
+4
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api/LogResolver.java
...rg/skywalking/apm/agent/core/logging/api/LogResolver.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api/NoopLogger.java
...org/skywalking/apm/agent/core/logging/api/NoopLogger.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/EasyLogResolver.java
...ywalking/apm/agent/core/logging/core/EasyLogResolver.java
+3
-3
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/EasyLogger.java
...rg/skywalking/apm/agent/core/logging/core/EasyLogger.java
+3
-3
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/FileWriter.java
...rg/skywalking/apm/agent/core/logging/core/FileWriter.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/IWriter.java
...a/org/skywalking/apm/agent/core/logging/core/IWriter.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/LogLevel.java
.../org/skywalking/apm/agent/core/logging/core/LogLevel.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/LogMessageHolder.java
...walking/apm/agent/core/logging/core/LogMessageHolder.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/SystemOutWriter.java
...ywalking/apm/agent/core/logging/core/SystemOutWriter.java
+1
-5
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/core/WriterFactory.java
...skywalking/apm/agent/core/logging/core/WriterFactory.java
+11
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
...m/agent/core/plugin/AbstractClassEnhancePluginDefine.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
...org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginCfg.java
.../java/org/skywalking/apm/agent/core/plugin/PluginCfg.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginResourcesResolver.java
...alking/apm/agent/core/plugin/PluginResourcesResolver.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
.../plugin/interceptor/enhance/ClassEnhancePluginDefine.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/ConstructorInter.java
...ent/core/plugin/interceptor/enhance/ConstructorInter.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/InstMethodsInter.java
...ent/core/plugin/interceptor/enhance/InstMethodsInter.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java
...interceptor/enhance/InstMethodsInterWithOverrideArgs.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java
...t/core/plugin/interceptor/enhance/StaticMethodsInter.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java
...terceptor/enhance/StaticMethodsInterWithOverrideArgs.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java
...alking/apm/agent/core/plugin/loader/AgentClassLoader.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/loader/InterceptorInstanceLoader.java
...m/agent/core/plugin/loader/InterceptorInstanceLoader.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java
...ng/apm/agent/core/remote/AppAndServiceRegisterClient.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/DiscoveryRestServiceClient.java
...ing/apm/agent/core/remote/DiscoveryRestServiceClient.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/GRPCChannelManager.java
.../skywalking/apm/agent/core/remote/GRPCChannelManager.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java
...king/apm/agent/core/remote/TraceSegmentServiceClient.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/sampling/SamplingService.java
...g/skywalking/apm/agent/core/sampling/SamplingService.java
+2
-2
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java
...ing/apm/agent/core/conf/SnifferConfigInitializerTest.java
+1
-1
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/core/EasyLogResolverTest.java
...king/apm/agent/core/logging/core/EasyLogResolverTest.java
+1
-1
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/core/EasyLoggerTest.java
...kywalking/apm/agent/core/logging/core/EasyLoggerTest.java
+18
-7
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/core/FileWriterTest.java
...kywalking/apm/agent/core/logging/core/FileWriterTest.java
+4
-3
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/core/SystemOutWriterTest.java
...king/apm/agent/core/logging/core/SystemOutWriterTest.java
+3
-2
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/core/WriterFactoryTest.java
...alking/apm/agent/core/logging/core/WriterFactoryTest.java
+3
-7
apm-sniffer/apm-agent/pom.xml
apm-sniffer/apm-agent/pom.xml
+1
-0
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
...c/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
+8
-19
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextInterceptor.java
...apm/toolkit/activation/trace/TraceContextInterceptor.java
+2
-2
未找到文件。
apm-commons/apm-logging-api/pom.xml
已删除
100644 → 0
浏览文件 @
030f7c63
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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.
~
~ Project repository: https://github.com/OpenSkywalking/skywalking
-->
<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>
apm-commons
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.3-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-logging-api
</artifactId>
</project>
apm-commons/apm-logging-api/src/test/java/org/skywalking/apm/logging/LogManagerTest.java
已删除
100644 → 0
浏览文件 @
030f7c63
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.logging
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.powermock.api.support.membermodification.MemberModifier
;
/**
* @author wusheng
*/
public
class
LogManagerTest
{
@Test
public
void
testGetNoopLogger
()
{
ILog
logger
=
LogManager
.
getLogger
(
LogManagerTest
.
class
);
Assert
.
assertEquals
(
NoopLogger
.
INSTANCE
,
logger
);
}
@Before
@After
public
void
clear
()
throws
IllegalAccessException
{
MemberModifier
.
field
(
LogManager
.
class
,
"RESOLVER"
).
set
(
null
,
null
);
}
public
class
TestLogger
implements
ILog
{
@Override
public
void
info
(
String
format
)
{
}
@Override
public
void
info
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
warn
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
error
(
String
format
,
Throwable
e
)
{
}
@Override
public
void
error
(
Throwable
e
,
String
format
,
Object
...
arguments
)
{
}
@Override
public
boolean
isDebugEnable
()
{
return
false
;
}
@Override
public
boolean
isInfoEnable
()
{
return
false
;
}
@Override
public
boolean
isWarnEnable
()
{
return
false
;
}
@Override
public
boolean
isErrorEnable
()
{
return
false
;
}
@Override
public
void
debug
(
String
format
)
{
}
@Override
public
void
debug
(
String
format
,
Object
...
arguments
)
{
}
@Override
public
void
error
(
String
format
)
{
}
}
}
apm-commons/apm-logging-api/src/test/java/org/skywalking/apm/logging/NoopLoggerTest.java
已删除
100644 → 0
浏览文件 @
030f7c63
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.logging
;
import
org.junit.Assert
;
import
org.junit.Test
;
/**
* Created by wusheng on 2017/2/27.
*/
public
class
NoopLoggerTest
{
@Test
public
void
testOnNothing
()
{
Assert
.
assertFalse
(
NoopLogger
.
INSTANCE
.
isDebugEnable
());
Assert
.
assertFalse
(
NoopLogger
.
INSTANCE
.
isInfoEnable
());
Assert
.
assertFalse
(
NoopLogger
.
INSTANCE
.
isErrorEnable
());
Assert
.
assertFalse
(
NoopLogger
.
INSTANCE
.
isWarnEnable
());
NoopLogger
.
INSTANCE
.
debug
(
"Any string"
);
NoopLogger
.
INSTANCE
.
debug
(
"Any string"
,
new
Object
[
0
]);
NoopLogger
.
INSTANCE
.
info
(
"Any string"
);
NoopLogger
.
INSTANCE
.
info
(
"Any string"
,
new
Object
[
0
]);
NoopLogger
.
INSTANCE
.
warn
(
"Any string"
,
new
Object
[
0
]);
NoopLogger
.
INSTANCE
.
warn
(
"Any string"
,
new
Object
[
0
],
new
NullPointerException
());
NoopLogger
.
INSTANCE
.
error
(
"Any string"
);
NoopLogger
.
INSTANCE
.
error
(
"Any string"
,
new
NullPointerException
());
}
}
apm-commons/pom.xml
浏览文件 @
04771ffc
...
...
@@ -30,7 +30,6 @@
<modules>
<module>
apm-util
</module>
<module>
apm-logging-api
</module>
<module>
apm-datacarrier
</module>
</modules>
...
...
apm-sniffer/apm-agent-core/pom.xml
浏览文件 @
04771ffc
...
...
@@ -53,11 +53,6 @@
</properties>
<dependencies>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-logging-api
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-network
</artifactId>
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/boot/AgentPackagePath.java
浏览文件 @
04771ffc
...
...
@@ -18,15 +18,19 @@
package
org.skywalking.apm.agent.core.boot
;
import
org.skywalking.apm.agent.core.logging.api.ILog
;
import
org.skywalking.apm.agent.core.logging.api.LogManager
;
import
java.io.File
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
org.skywalking.apm.agent.core.logging.SystemOutWriter
;
/**
* @author wusheng
*/
public
class
AgentPackagePath
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
AgentPackagePath
.
class
);
private
static
File
AGENT_PACKAGE_PATH
;
public
static
File
getPath
()
throws
AgentPackageNotFoundException
{
...
...
@@ -36,6 +40,10 @@ public class AgentPackagePath {
return
AGENT_PACKAGE_PATH
;
}
public
static
boolean
isPathFound
()
{
return
AGENT_PACKAGE_PATH
!=
null
;
}
private
static
File
findPath
()
throws
AgentPackageNotFoundException
{
String
classResourcePath
=
AgentPackagePath
.
class
.
getName
().
replaceAll
(
"\\."
,
"/"
)
+
".class"
;
...
...
@@ -43,7 +51,7 @@ public class AgentPackagePath {
if
(
resource
!=
null
)
{
String
urlString
=
resource
.
toString
();
SystemOutWriter
.
INSTANCE
.
write
(
urlString
);
logger
.
debug
(
"The beacon class location is {}."
,
urlString
);
int
insidePathIndex
=
urlString
.
indexOf
(
'!'
);
boolean
isInJar
=
insidePathIndex
>
-
1
;
...
...
@@ -54,7 +62,7 @@ public class AgentPackagePath {
try
{
agentJarFile
=
new
File
(
new
URL
(
urlString
).
getFile
());
}
catch
(
MalformedURLException
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
"Can not locate agent jar file by url:"
+
urlString
);
logger
.
error
(
e
,
"Can not locate agent jar file by url:"
+
urlString
);
}
if
(
agentJarFile
.
exists
())
{
return
agentJarFile
.
getParentFile
();
...
...
@@ -65,7 +73,7 @@ public class AgentPackagePath {
}
}
SystemOutWriter
.
INSTANCE
.
write
(
"Can not locate agent jar file."
);
logger
.
error
(
"Can not locate agent jar file."
);
throw
new
AgentPackageNotFoundException
(
"Can not locate agent jar file."
);
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/boot/ServiceManager.java
浏览文件 @
04771ffc
...
...
@@ -22,8 +22,8 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.ServiceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The <code>ServiceManager</code> bases on {@link ServiceLoader},
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/Config.java
浏览文件 @
04771ffc
...
...
@@ -21,8 +21,8 @@ package org.skywalking.apm.agent.core.conf;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.logging.LogLevel
;
import
org.skywalking.apm.agent.core.logging.WriterFactory
;
import
org.skywalking.apm.agent.core.logging.
core.
LogLevel
;
import
org.skywalking.apm.agent.core.logging.
core.
WriterFactory
;
/**
* This is the core config in sniffer agent.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
浏览文件 @
04771ffc
...
...
@@ -18,6 +18,13 @@
package
org.skywalking.apm.agent.core.conf
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.boot.AgentPackagePath
;
import
org.skywalking.apm.agent.core.logging.api.ILog
;
import
org.skywalking.apm.agent.core.logging.api.LogManager
;
import
org.skywalking.apm.util.ConfigInitializer
;
import
org.skywalking.apm.util.StringUtil
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
...
...
@@ -25,11 +32,6 @@ import java.io.InputStream;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Properties
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.boot.AgentPackagePath
;
import
org.skywalking.apm.agent.core.logging.SystemOutWriter
;
import
org.skywalking.apm.util.ConfigInitializer
;
import
org.skywalking.apm.util.StringUtil
;
/**
* The <code>SnifferConfigInitializer</code> initializes all configs in several way.
...
...
@@ -38,16 +40,17 @@ import org.skywalking.apm.util.StringUtil;
* @see {@link #initialize()}, to learn more about how to initialzie.
*/
public
class
SnifferConfigInitializer
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
SnifferConfigInitializer
.
class
);
private
static
String
CONFIG_FILE_NAME
=
"/config/agent.config"
;
private
static
String
ENV_KEY_PREFIX
=
"skywalking."
;
/**
* Try to locate `agent.config`, which should be in the /config 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.agent.application_code=yourAppName` to override
* `agent.application_code` in config file.
*
*
<p>
* At the end, `agent.application_code` and `collector.servers` must be not blank.
*/
public
static
void
initialize
()
throws
ConfigNotFoundException
,
AgentPackageNotFoundException
{
...
...
@@ -59,15 +62,13 @@ public class SnifferConfigInitializer {
properties
.
load
(
configFileStream
);
ConfigInitializer
.
initialize
(
properties
,
Config
.
class
);
}
catch
(
Exception
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
"Failed to read the config file, skywalking is going to run in default config."
);
e
.
printStackTrace
(
SystemOutWriter
.
INSTANCE
.
getStream
());
logger
.
error
(
e
,
"Failed to read the config file, skywalking is going to run in default config."
);
}
try
{
overrideConfigBySystemEnv
();
}
catch
(
Exception
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
"Failed to read the system env."
);
e
.
printStackTrace
(
SystemOutWriter
.
INSTANCE
.
getStream
());
logger
.
error
(
e
,
"Failed to read the system env."
);
}
if
(
StringUtil
.
isEmpty
(
Config
.
Agent
.
APPLICATION_CODE
))
{
...
...
@@ -81,7 +82,7 @@ public class SnifferConfigInitializer {
/**
* Override the config by system env. The env key must start with `skywalking`, the reuslt should be as same as in
* `agent.config`
*
*
<p>
* such as:
* Env key of `agent.application_code` shoule be `skywalking.agent.application_code`
*
...
...
@@ -89,13 +90,6 @@ public class SnifferConfigInitializer {
*/
private
static
void
overrideConfigBySystemEnv
()
throws
IllegalAccessException
{
Properties
properties
=
new
Properties
();
Map
<
String
,
String
>
envs
=
System
.
getenv
();
for
(
String
envKey
:
envs
.
keySet
())
{
if
(
envKey
.
startsWith
(
ENV_KEY_PREFIX
))
{
String
realKey
=
envKey
.
substring
(
ENV_KEY_PREFIX
.
length
());
properties
.
setProperty
(
realKey
,
envs
.
get
(
envKey
));
}
}
Properties
systemProperties
=
System
.
getProperties
();
Iterator
<
Map
.
Entry
<
Object
,
Object
>>
entryIterator
=
systemProperties
.
entrySet
().
iterator
();
while
(
entryIterator
.
hasNext
())
{
...
...
@@ -105,6 +99,15 @@ public class SnifferConfigInitializer {
properties
.
put
(
realKey
,
prop
.
getValue
());
}
}
Map
<
String
,
String
>
envs
=
System
.
getenv
();
for
(
String
envKey
:
envs
.
keySet
())
{
if
(
envKey
.
startsWith
(
ENV_KEY_PREFIX
))
{
String
realKey
=
envKey
.
substring
(
ENV_KEY_PREFIX
.
length
());
properties
.
setProperty
(
realKey
,
envs
.
get
(
envKey
));
}
}
if
(!
properties
.
isEmpty
())
{
ConfigInitializer
.
initialize
(
properties
,
Config
.
class
);
}
...
...
@@ -119,13 +122,13 @@ public class SnifferConfigInitializer {
File
configFile
=
new
File
(
AgentPackagePath
.
getPath
(),
CONFIG_FILE_NAME
);
if
(
configFile
.
exists
()
&&
configFile
.
isFile
())
{
try
{
SystemOutWriter
.
INSTANCE
.
write
(
CONFIG_FILE_NAME
+
" file found in agent folder."
);
logger
.
info
(
"Config file found in {}."
,
configFile
);
return
new
FileInputStream
(
configFile
);
}
catch
(
FileNotFoundException
e
)
{
throw
new
ConfigNotFoundException
(
"Fail to load agent.config"
,
e
);
}
}
throw
new
ConfigNotFoundException
(
"Fail to load agent
.config
"
);
throw
new
ConfigNotFoundException
(
"Fail to load agent
config file.
"
);
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
04771ffc
...
...
@@ -26,8 +26,8 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
import
org.skywalking.apm.agent.core.sampling.SamplingService
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.util.StringUtil
;
/**
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java
浏览文件 @
04771ffc
...
...
@@ -26,8 +26,8 @@ import org.skywalking.apm.agent.core.context.ids.DistributedTraceIds;
import
org.skywalking.apm.agent.core.context.ids.GlobalIdGenerator
;
import
org.skywalking.apm.agent.core.context.ids.ID
;
import
org.skywalking.apm.agent.core.context.ids.NewDistributedTraceId
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.network.proto.TraceSegmentObject
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/JVMService.java
浏览文件 @
04771ffc
...
...
@@ -37,8 +37,8 @@ import org.skywalking.apm.agent.core.jvm.memorypool.MemoryPoolProvider;
import
org.skywalking.apm.agent.core.remote.GRPCChannelListener
;
import
org.skywalking.apm.agent.core.remote.GRPCChannelManager
;
import
org.skywalking.apm.agent.core.remote.GRPCChannelStatus
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.network.proto.JVMMetric
;
import
org.skywalking.apm.network.proto.JVMMetrics
;
import
org.skywalking.apm.network.proto.JVMMetricsServiceGrpc
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/jvm/cpu/CPUProvider.java
浏览文件 @
04771ffc
...
...
@@ -19,8 +19,8 @@
package
org.skywalking.apm.agent.core.jvm.cpu
;
import
org.skywalking.apm.agent.core.os.ProcessorUtil
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.network.proto.CPU
;
/**
...
...
apm-
commons/apm-logging-api/src/main/java/org/skywalking/apm/logging
/ILog.java
→
apm-
sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api
/ILog.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.
logging
;
package
org.skywalking.apm.
agent.core.logging.api
;
/**
* The Log interface.
...
...
apm-
commons/apm-logging-api/src/main/java/org/skywalking/apm/logging
/LogManager.java
→
apm-
sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api
/LogManager.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,9 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.logging
;
package
org.skywalking.apm.agent.core.logging.api
;
import
org.skywalking.apm.agent.core.logging.core.EasyLogResolver
;
/**
* LogManager is the {@link LogResolver} implementation manager. By using {@link LogResolver}, {@link
...
...
@@ -27,7 +29,7 @@ package org.skywalking.apm.logging;
* override the first without any warning or exception. <p> Created by xin on 2016/11/10.
*/
public
class
LogManager
{
private
static
LogResolver
RESOLVER
;
private
static
LogResolver
RESOLVER
=
new
EasyLogResolver
()
;
public
static
void
setLogResolver
(
LogResolver
resolver
)
{
LogManager
.
RESOLVER
=
resolver
;
...
...
apm-
commons/apm-logging-api/src/main/java/org/skywalking/apm/logging
/LogResolver.java
→
apm-
sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api
/LogResolver.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.
logging
;
package
org.skywalking.apm.
agent.core.logging.api
;
/**
* {@link LogResolver} just do only one thing: return the {@link ILog} implementation.
...
...
apm-
commons/apm-logging-api/src/main/java/org/skywalking/apm/logging
/NoopLogger.java
→
apm-
sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/api
/NoopLogger.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.
logging
;
package
org.skywalking.apm.
agent.core.logging.api
;
/**
* No operation logger implementation.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/EasyLogResolver.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
EasyLogResolver.java
浏览文件 @
04771ffc
...
...
@@ -16,10 +16,10 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogResolver
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogResolver
;
/**
* Created by wusheng on 2016/11/26.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/EasyLogger.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
EasyLogger.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
...
...
@@ -25,7 +25,7 @@ import java.util.Date;
import
java.util.regex.Matcher
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.conf.Constants
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.util.StringUtil
;
/**
...
...
@@ -41,7 +41,7 @@ public class EasyLogger implements ILog {
this
.
targetClass
=
targetClass
;
}
pr
ivate
void
logger
(
LogLevel
level
,
String
message
,
Throwable
e
)
{
pr
otected
void
logger
(
LogLevel
level
,
String
message
,
Throwable
e
)
{
WriterFactory
.
getLogWriter
().
write
(
format
(
level
,
message
,
e
));
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/FileWriter.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
FileWriter.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
com.lmax.disruptor.EventFactory
;
import
com.lmax.disruptor.EventHandler
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/IWriter.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
IWriter.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
public
interface
IWriter
{
void
write
(
String
message
);
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/LogLevel.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
LogLevel.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
/**
* Created by xin on 2016/12/7.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/LogMessageHolder.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
LogMessageHolder.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
/**
* The <code>LogMessageHolder</code> is a {@link String} holder,
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/SystemOutWriter.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
SystemOutWriter.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.PrintStream
;
...
...
@@ -34,8 +34,4 @@ public enum SystemOutWriter implements IWriter {
PrintStream
out
=
System
.
out
;
out
.
println
(
message
);
}
public
PrintStream
getStream
()
{
return
System
.
out
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/WriterFactory.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/logging/
core/
WriterFactory.java
浏览文件 @
04771ffc
...
...
@@ -16,14 +16,23 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.boot.AgentPackagePath
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.util.StringUtil
;
public
class
WriterFactory
{
public
static
IWriter
getLogWriter
()
{
if
(!
StringUtil
.
isEmpty
(
Config
.
Logging
.
DIR
))
{
if
(
AgentPackagePath
.
isPathFound
())
{
if
(
StringUtil
.
isEmpty
(
Config
.
Logging
.
DIR
))
{
try
{
Config
.
Logging
.
DIR
=
AgentPackagePath
.
getPath
()
+
"/logs"
;
}
catch
(
AgentPackageNotFoundException
e
)
{
e
.
printStackTrace
();
}
}
return
FileWriter
.
get
();
}
else
{
return
SystemOutWriter
.
INSTANCE
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/AbstractClassEnhancePluginDefine.java
浏览文件 @
04771ffc
...
...
@@ -21,8 +21,8 @@ package org.skywalking.apm.agent.core.plugin;
import
net.bytebuddy.dynamic.DynamicType
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.util.StringUtil
;
/**
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginBootstrap.java
浏览文件 @
04771ffc
...
...
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import
java.util.List
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.plugin.loader.AgentClassLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* Plugins finder.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginCfg.java
浏览文件 @
04771ffc
...
...
@@ -25,8 +25,8 @@ import java.io.InputStreamReader;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.plugin.exception.IllegalPluginDefineException
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
public
enum
PluginCfg
{
INSTANCE
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/PluginResourcesResolver.java
浏览文件 @
04771ffc
...
...
@@ -24,8 +24,8 @@ import java.util.ArrayList;
import
java.util.Enumeration
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.plugin.loader.AgentClassLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* Use the current classloader to read all plugin define file.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/ClassEnhancePluginDefine.java
浏览文件 @
04771ffc
...
...
@@ -30,8 +30,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoin
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhanceException
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.util.StringUtil
;
import
static
net
.
bytebuddy
.
jar
.
asm
.
Opcodes
.
ACC_PRIVATE
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/ConstructorInter.java
浏览文件 @
04771ffc
...
...
@@ -23,8 +23,8 @@ import net.bytebuddy.implementation.bind.annotation.RuntimeType;
import
net.bytebuddy.implementation.bind.annotation.This
;
import
org.skywalking.apm.agent.core.plugin.PluginException
;
import
org.skywalking.apm.agent.core.plugin.loader.InterceptorInstanceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The actual byte-buddy's interceptor to intercept constructor methods.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/InstMethodsInter.java
浏览文件 @
04771ffc
...
...
@@ -27,8 +27,8 @@ import net.bytebuddy.implementation.bind.annotation.SuperCall;
import
net.bytebuddy.implementation.bind.annotation.This
;
import
org.skywalking.apm.agent.core.plugin.PluginException
;
import
org.skywalking.apm.agent.core.plugin.loader.InterceptorInstanceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The actual byte-buddy's interceptor to intercept class instance methods.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/InstMethodsInterWithOverrideArgs.java
浏览文件 @
04771ffc
...
...
@@ -26,8 +26,8 @@ import net.bytebuddy.implementation.bind.annotation.RuntimeType;
import
net.bytebuddy.implementation.bind.annotation.This
;
import
org.skywalking.apm.agent.core.plugin.PluginException
;
import
org.skywalking.apm.agent.core.plugin.loader.InterceptorInstanceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The actual byte-buddy's interceptor to intercept class instance methods.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/StaticMethodsInter.java
浏览文件 @
04771ffc
...
...
@@ -25,8 +25,8 @@ import net.bytebuddy.implementation.bind.annotation.Origin;
import
net.bytebuddy.implementation.bind.annotation.RuntimeType
;
import
net.bytebuddy.implementation.bind.annotation.SuperCall
;
import
org.skywalking.apm.agent.core.plugin.loader.InterceptorInstanceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The actual byte-buddy's interceptor to intercept class instance methods.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/interceptor/enhance/StaticMethodsInterWithOverrideArgs.java
浏览文件 @
04771ffc
...
...
@@ -24,8 +24,8 @@ import net.bytebuddy.implementation.bind.annotation.Morph;
import
net.bytebuddy.implementation.bind.annotation.Origin
;
import
net.bytebuddy.implementation.bind.annotation.RuntimeType
;
import
org.skywalking.apm.agent.core.plugin.loader.InterceptorInstanceLoader
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The actual byte-buddy's interceptor to intercept class instance methods.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/loader/AgentClassLoader.java
浏览文件 @
04771ffc
...
...
@@ -21,8 +21,8 @@ package org.skywalking.apm.agent.core.plugin.loader;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.boot.AgentPackagePath
;
import
org.skywalking.apm.agent.core.plugin.PluginBootstrap
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
java.io.*
;
import
java.net.MalformedURLException
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/plugin/loader/InterceptorInstanceLoader.java
浏览文件 @
04771ffc
...
...
@@ -19,8 +19,8 @@
package
org.skywalking.apm.agent.core.plugin.loader
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.HashMap
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/AppAndServiceRegisterClient.java
浏览文件 @
04771ffc
...
...
@@ -35,8 +35,8 @@ import org.skywalking.apm.agent.core.dictionary.ApplicationDictionary;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
import
org.skywalking.apm.agent.core.dictionary.OperationNameDictionary
;
import
org.skywalking.apm.agent.core.os.OSUtil
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.network.proto.Application
;
import
org.skywalking.apm.network.proto.ApplicationInstance
;
import
org.skywalking.apm.network.proto.ApplicationInstanceHeartbeat
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/DiscoveryRestServiceClient.java
浏览文件 @
04771ffc
...
...
@@ -31,8 +31,8 @@ import org.apache.http.impl.client.CloseableHttpClient;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
conf
.
RemoteDownstreamConfig
.
Collector
.
GRPC_SERVERS
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/GRPCChannelManager.java
浏览文件 @
04771ffc
...
...
@@ -35,8 +35,8 @@ import org.skywalking.apm.agent.core.boot.BootService;
import
org.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* @author wusheng
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/TraceSegmentServiceClient.java
浏览文件 @
04771ffc
...
...
@@ -29,8 +29,8 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
import
org.skywalking.apm.commons.datacarrier.DataCarrier
;
import
org.skywalking.apm.commons.datacarrier.buffer.BufferStrategy
;
import
org.skywalking.apm.commons.datacarrier.consumer.IConsumer
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
import
org.skywalking.apm.network.proto.Downstream
;
import
org.skywalking.apm.network.proto.TraceSegmentServiceGrpc
;
import
org.skywalking.apm.network.proto.UpstreamSegment
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/sampling/SamplingService.java
浏览文件 @
04771ffc
...
...
@@ -27,8 +27,8 @@ import org.skywalking.apm.agent.core.boot.BootService;
import
org.skywalking.apm.agent.core.boot.DefaultNamedThreadFactory
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
/**
* The <code>SamplingService</code> take charge of how to sample the {@link TraceSegment}. Every {@link TraceSegment}s
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/conf/SnifferConfigInitializerTest.java
浏览文件 @
04771ffc
...
...
@@ -21,7 +21,7 @@ package org.skywalking.apm.agent.core.conf;
import
org.junit.AfterClass
;
import
org.junit.Test
;
import
org.skywalking.apm.agent.core.boot.AgentPackageNotFoundException
;
import
org.skywalking.apm.agent.core.logging.LogLevel
;
import
org.skywalking.apm.agent.core.logging.
core.
LogLevel
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/EasyLogResolverTest.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/
core/
EasyLogResolverTest.java
浏览文件 @
04771ffc
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/EasyLoggerTest.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/
core/
EasyLoggerTest.java
浏览文件 @
04771ffc
...
...
@@ -16,9 +16,8 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.PrintStream
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
...
...
@@ -26,6 +25,8 @@ import org.junit.Test;
import
org.mockito.Mockito
;
import
org.skywalking.apm.agent.core.conf.Constants
;
import
java.io.PrintStream
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
times
;
...
...
@@ -48,7 +49,12 @@ public class EasyLoggerTest {
System
.
setOut
(
output
);
PrintStream
err
=
Mockito
.
mock
(
PrintStream
.
class
);
System
.
setErr
(
err
);
EasyLogger
logger
=
new
EasyLogger
(
EasyLoggerTest
.
class
);
EasyLogger
logger
=
new
EasyLogger
(
EasyLoggerTest
.
class
)
{
@Override
protected
void
logger
(
LogLevel
level
,
String
message
,
Throwable
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
format
(
level
,
message
,
e
));
}
};
Assert
.
assertTrue
(
logger
.
isDebugEnable
());
Assert
.
assertTrue
(
logger
.
isInfoEnable
());
...
...
@@ -67,7 +73,7 @@ public class EasyLoggerTest {
logger
.
error
(
new
NullPointerException
(),
"hello {}"
,
"world"
);
Mockito
.
verify
(
output
,
times
(
9
))
.
println
(
anyString
());
.
println
(
anyString
());
}
@Test
...
...
@@ -76,7 +82,12 @@ public class EasyLoggerTest {
System
.
setOut
(
output
);
PrintStream
err
=
Mockito
.
mock
(
PrintStream
.
class
);
System
.
setErr
(
err
);
EasyLogger
logger
=
new
EasyLogger
(
EasyLoggerTest
.
class
);
EasyLogger
logger
=
new
EasyLogger
(
EasyLoggerTest
.
class
)
{
@Override
protected
void
logger
(
LogLevel
level
,
String
message
,
Throwable
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
format
(
level
,
message
,
e
));
}
};
Assert
.
assertTrue
(
logger
.
isDebugEnable
());
Assert
.
assertTrue
(
logger
.
isInfoEnable
());
...
...
@@ -95,7 +106,7 @@ public class EasyLoggerTest {
logger
.
error
(
new
NullPointerException
(),
"hello {}"
,
"&&&**%%"
);
Mockito
.
verify
(
output
,
times
(
9
))
.
println
(
anyString
());
.
println
(
anyString
());
}
@Test
...
...
@@ -105,7 +116,7 @@ public class EasyLoggerTest {
String
formatLines
=
logger
.
format
(
exception
);
String
[]
lines
=
formatLines
.
split
(
Constants
.
LINE_SEPARATOR
);
Assert
.
assertEquals
(
"java.lang.NullPointerException"
,
lines
[
1
]);
Assert
.
assertEquals
(
"\tat org.skywalking.apm.agent.core.logging.
EasyLoggerTest.testFormat(EasyLoggerTest.java:103
)"
,
lines
[
2
]);
Assert
.
assertEquals
(
"\tat org.skywalking.apm.agent.core.logging.
core.EasyLoggerTest.testFormat(EasyLoggerTest.java:114
)"
,
lines
[
2
]);
}
@AfterClass
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/FileWriterTest.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/
core/
FileWriterTest.java
浏览文件 @
04771ffc
...
...
@@ -16,16 +16,17 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.File
;
import
java.io.IOException
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.conf.Constants
;
import
java.io.File
;
import
java.io.IOException
;
/**
* @author wusheng
*/
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/SystemOutWriterTest.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/
core/
SystemOutWriterTest.java
浏览文件 @
04771ffc
...
...
@@ -16,14 +16,15 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.PrintStream
;
import
org.junit.AfterClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
java.io.PrintStream
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
times
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/WriterFactoryTest.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/logging/
core/
WriterFactoryTest.java
浏览文件 @
04771ffc
...
...
@@ -16,16 +16,16 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.agent.core.logging
;
package
org.skywalking.apm.agent.core.logging
.core
;
import
java.io.PrintStream
;
import
org.junit.AfterClass
;
import
org.junit.Assert
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
java.io.PrintStream
;
/**
* Created by wusheng on 2017/2/28.
*/
...
...
@@ -43,10 +43,6 @@ public class WriterFactoryTest {
*/
@Test
public
void
testGetLogWriter
()
{
PrintStream
mockStream
=
Mockito
.
mock
(
PrintStream
.
class
);
System
.
setErr
(
mockStream
);
Assert
.
assertEquals
(
SystemOutWriter
.
INSTANCE
,
WriterFactory
.
getLogWriter
());
Config
.
Logging
.
DIR
=
"/only/test/folder"
;
Assert
.
assertTrue
(
WriterFactory
.
getLogWriter
()
instanceof
FileWriter
);
}
...
...
apm-sniffer/apm-agent/pom.xml
浏览文件 @
04771ffc
...
...
@@ -112,6 +112,7 @@
<copy
file=
"${project.build.directory}/skywalking-agent.jar"
tofile=
"${project.basedir}/../../packages/skywalking-agent/skywalking-agent.jar"
overwrite=
"true"
/>
<mkdir
dir=
"${project.basedir}/../../packages/skywalking-agent/config"
/>
<mkdir
dir=
"${project.basedir}/../../packages/skywalking-agent/logs"
/>
<copydir
src=
"${project.basedir}/../config"
dest=
"${project.basedir}/../../packages/skywalking-agent/config"
forceoverwrite=
"true"
/>
</tasks>
...
...
apm-sniffer/apm-agent/src/main/java/org/skywalking/apm/agent/SkyWalkingAgent.java
浏览文件 @
04771ffc
...
...
@@ -18,23 +18,18 @@
package
org.skywalking.apm.agent
;
import
java.lang.instrument.Instrumentation
;
import
java.util.List
;
import
net.bytebuddy.agent.builder.AgentBuilder
;
import
net.bytebuddy.description.type.TypeDescription
;
import
net.bytebuddy.dynamic.DynamicType
;
import
net.bytebuddy.utility.JavaModule
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.SnifferConfigInitializer
;
import
org.skywalking.apm.agent.core.logging.EasyLogResolver
;
import
org.skywalking.apm.agent.core.logging.SystemOutWriter
;
import
org.skywalking.apm.agent.core.plugin.AbstractClassEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.EnhanceContext
;
import
org.skywalking.apm.agent.core.plugin.PluginBootstrap
;
import
org.skywalking.apm.agent.core.plugin.PluginException
;
import
org.skywalking.apm.agent.core.plugin.PluginFinder
;
import
org.skywalking.apm.logging.ILog
;
import
org.skywalking.apm.logging.LogManager
;
import
org.skywalking.apm.agent.core.logging.api.ILog
;
import
org.skywalking.apm.agent.core.logging.api.LogManager
;
import
org.skywalking.apm.agent.core.plugin.*
;
import
java.lang.instrument.Instrumentation
;
import
java.util.List
;
/**
* The main entrance of sky-waking agent,
...
...
@@ -43,12 +38,7 @@ import org.skywalking.apm.logging.LogManager;
* @author wusheng
*/
public
class
SkyWalkingAgent
{
private
static
final
ILog
logger
;
static
{
LogManager
.
setLogResolver
(
new
EasyLogResolver
());
logger
=
LogManager
.
getLogger
(
SkyWalkingAgent
.
class
);
}
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
SkyWalkingAgent
.
class
);
/**
* Main entrance.
...
...
@@ -67,8 +57,7 @@ public class SkyWalkingAgent {
ServiceManager
.
INSTANCE
.
boot
();
}
catch
(
Exception
e
)
{
SystemOutWriter
.
INSTANCE
.
write
(
"skywalking agent is shutting down."
);
e
.
printStackTrace
(
SystemOutWriter
.
INSTANCE
.
getStream
());
logger
.
error
(
e
,
"Skywalking agent initialized failure. Shutting down."
);
return
;
}
...
...
apm-sniffer/apm-toolkit-activation/apm-toolkit-trace-activation/src/main/java/org/skywalking/apm/toolkit/activation/trace/TraceContextInterceptor.java
浏览文件 @
04771ffc
...
...
@@ -22,8 +22,8 @@ import java.lang.reflect.Method;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.StaticMethodsAroundInterceptor
;
import
org.skywalking.apm.
logging
.ILog
;
import
org.skywalking.apm.
logging
.LogManager
;
import
org.skywalking.apm.
agent.core.logging.api
.ILog
;
import
org.skywalking.apm.
agent.core.logging.api
.LogManager
;
public
class
TraceContextInterceptor
implements
StaticMethodsAroundInterceptor
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录