Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
706debcb
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 1 年多
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
提交
706debcb
编写于
4月 20, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
03711ab0
31a4e28b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
135 addition
and
82 deletion
+135
-82
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ApplicationExceptionHandler.java
...d/skywalking/buriedpoint/ApplicationExceptionHandler.java
+23
-12
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/LocalBuriedPointSender.java
.../cloud/skywalking/buriedpoint/LocalBuriedPointSender.java
+53
-38
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/RPCBuriedPointReceiver.java
.../cloud/skywalking/buriedpoint/RPCBuriedPointReceiver.java
+45
-31
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ThreadBuriedPointSender.java
...cloud/skywalking/buriedpoint/ThreadBuriedPointSender.java
+7
-1
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ThreadFactoryBuriedPointSender.java
...kywalking/buriedpoint/ThreadFactoryBuriedPointSender.java
+7
-0
未找到文件。
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ApplicationExceptionHandler.java
浏览文件 @
706debcb
...
...
@@ -5,31 +5,42 @@ import static com.ai.cloud.skywalking.conf.Config.BuriedPoint.EXCLUSIVE_EXCEPTIO
import
java.util.HashSet
;
import
java.util.Set
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
com.ai.cloud.skywalking.api.IExceptionHandler
;
import
com.ai.cloud.skywalking.conf.Config
;
import
com.ai.cloud.skywalking.context.Context
;
import
com.ai.cloud.skywalking.protocol.Span
;
public
class
ApplicationExceptionHandler
implements
IExceptionHandler
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ApplicationExceptionHandler
.
class
);
private
static
String
EXCEPTION_SPLIT
=
","
;
private
static
Set
<
String
>
exclusiveExceptionSet
=
null
;
@Override
public
void
handleException
(
Throwable
th
)
{
if
(
exclusiveExceptionSet
==
null
)
{
Set
<
String
>
exclusiveExceptions
=
new
HashSet
<
String
>();
String
[]
exceptions
=
EXCLUSIVE_EXCEPTIONS
.
split
(
EXCEPTION_SPLIT
);
for
(
String
exception
:
exceptions
){
exclusiveExceptions
.
add
(
exception
);
try
{
if
(
exclusiveExceptionSet
==
null
)
{
Set
<
String
>
exclusiveExceptions
=
new
HashSet
<
String
>();
String
[]
exceptions
=
EXCLUSIVE_EXCEPTIONS
.
split
(
EXCEPTION_SPLIT
);
for
(
String
exception
:
exceptions
)
{
exclusiveExceptions
.
add
(
exception
);
}
exclusiveExceptionSet
=
exclusiveExceptions
;
}
exclusiveExceptionSet
=
exclusiveExceptions
;
}
Span
span
=
Context
.
getLastSpan
();
span
.
handleException
(
th
,
exclusiveExceptionSet
,
Config
.
BuriedPoint
.
MAX_EXCEPTION_STACK_LENGTH
);
Span
span
=
Context
.
getLastSpan
();
span
.
handleException
(
th
,
exclusiveExceptionSet
,
Config
.
BuriedPoint
.
MAX_EXCEPTION_STACK_LENGTH
);
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
}
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/LocalBuriedPointSender.java
浏览文件 @
706debcb
...
...
@@ -14,42 +14,57 @@ import com.ai.cloud.skywalking.model.Identification;
import
com.ai.cloud.skywalking.protocol.Span
;
import
com.ai.cloud.skywalking.util.ContextGenerator
;
public
class
LocalBuriedPointSender
extends
ApplicationExceptionHandler
implements
IBuriedPointSender
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
LocalBuriedPointSender
.
class
);
public
ContextData
beforeSend
(
Identification
id
)
{
if
(!
AuthDesc
.
isAuth
())
return
new
EmptyContextData
();
Span
spanData
=
ContextGenerator
.
generateSpanFromThreadLocal
(
id
);
// 将新创建的Context存放到ThreadLocal栈中。
Context
.
append
(
spanData
);
// 并将当前的Context返回回去
return
new
ContextData
(
spanData
);
}
public
void
afterSend
()
{
if
(!
AuthDesc
.
isAuth
())
return
;
// 弹出上下文的栈顶中的元素
Span
spanData
=
Context
.
removeLastSpan
();
if
(
spanData
==
null
)
{
return
;
}
// 加上花费时间
spanData
.
setCost
(
System
.
currentTimeMillis
()
-
spanData
.
getStartDate
());
if
(
Config
.
BuriedPoint
.
PRINTF
)
{
logger
.
debug
(
"TraceId:"
+
spanData
.
getTraceId
()
+
"\tviewpointId:"
+
spanData
.
getViewPointId
()
+
"\tParentLevelId:"
+
spanData
.
getParentLevel
()
+
"\tLevelId:"
+
spanData
.
getLevelId
()
+
"\tbusinessKey:"
+
spanData
.
getBusinessKey
());
}
// 存放到本地发送进程中
if
(!
Config
.
Sender
.
IS_OFF
)
{
ContextBuffer
.
save
(
spanData
);
}
}
public
class
LocalBuriedPointSender
extends
ApplicationExceptionHandler
implements
IBuriedPointSender
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
LocalBuriedPointSender
.
class
);
public
ContextData
beforeSend
(
Identification
id
)
{
try
{
if
(!
AuthDesc
.
isAuth
())
return
new
EmptyContextData
();
Span
spanData
=
ContextGenerator
.
generateSpanFromThreadLocal
(
id
);
// 将新创建的Context存放到ThreadLocal栈中。
Context
.
append
(
spanData
);
// 并将当前的Context返回回去
return
new
ContextData
(
spanData
);
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
return
new
EmptyContextData
();
}
}
public
void
afterSend
()
{
try
{
if
(!
AuthDesc
.
isAuth
())
return
;
// 弹出上下文的栈顶中的元素
Span
spanData
=
Context
.
removeLastSpan
();
if
(
spanData
==
null
)
{
return
;
}
// 加上花费时间
spanData
.
setCost
(
System
.
currentTimeMillis
()
-
spanData
.
getStartDate
());
if
(
Config
.
BuriedPoint
.
PRINTF
)
{
logger
.
debug
(
"TraceId:"
+
spanData
.
getTraceId
()
+
"\tviewpointId:"
+
spanData
.
getViewPointId
()
+
"\tParentLevelId:"
+
spanData
.
getParentLevel
()
+
"\tLevelId:"
+
spanData
.
getLevelId
()
+
"\tbusinessKey:"
+
spanData
.
getBusinessKey
());
}
// 存放到本地发送进程中
if
(!
Config
.
Sender
.
IS_OFF
)
{
ContextBuffer
.
save
(
spanData
);
}
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
}
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/RPCBuriedPointReceiver.java
浏览文件 @
706debcb
...
...
@@ -13,35 +13,49 @@ import com.ai.cloud.skywalking.model.Identification;
import
com.ai.cloud.skywalking.protocol.Span
;
import
com.ai.cloud.skywalking.util.ContextGenerator
;
public
class
RPCBuriedPointReceiver
extends
ApplicationExceptionHandler
implements
IBuriedPointReceiver
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
RPCBuriedPointReceiver
.
class
);
public
void
afterReceived
()
{
if
(!
AuthDesc
.
isAuth
())
return
;
// 获取上下文的栈顶中的元素
Span
spanData
=
Context
.
removeLastSpan
();
// 填上必要信息
spanData
.
setCost
(
System
.
currentTimeMillis
()
-
spanData
.
getStartDate
());
// 存放到本地发送进程中
ContextBuffer
.
save
(
spanData
);
}
public
void
beforeReceived
(
ContextData
context
,
Identification
id
)
{
if
(!
AuthDesc
.
isAuth
())
return
;
Span
spanData
=
ContextGenerator
.
generateSpanFromContextData
(
context
,
id
);
//设置是否为接收端
spanData
.
setReceiver
(
true
);
if
(
Config
.
BuriedPoint
.
PRINTF
)
{
logger
.
debug
(
"TraceId:"
+
spanData
.
getTraceId
()
+
"\tviewpointId:"
+
spanData
.
getViewPointId
()
+
"\tParentLevelId:"
+
spanData
.
getParentLevel
()
+
"\tLevelId:"
+
spanData
.
getLevelId
());
}
Context
.
append
(
spanData
);
}
public
class
RPCBuriedPointReceiver
extends
ApplicationExceptionHandler
implements
IBuriedPointReceiver
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
RPCBuriedPointReceiver
.
class
);
public
void
afterReceived
()
{
try
{
if
(!
AuthDesc
.
isAuth
())
return
;
// 获取上下文的栈顶中的元素
Span
spanData
=
Context
.
removeLastSpan
();
// 填上必要信息
spanData
.
setCost
(
System
.
currentTimeMillis
()
-
spanData
.
getStartDate
());
// 存放到本地发送进程中
ContextBuffer
.
save
(
spanData
);
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
}
}
public
void
beforeReceived
(
ContextData
context
,
Identification
id
)
{
try
{
if
(!
AuthDesc
.
isAuth
())
return
;
Span
spanData
=
ContextGenerator
.
generateSpanFromContextData
(
context
,
id
);
// 设置是否为接收端
spanData
.
setReceiver
(
true
);
if
(
Config
.
BuriedPoint
.
PRINTF
)
{
logger
.
debug
(
"TraceId:"
+
spanData
.
getTraceId
()
+
"\tviewpointId:"
+
spanData
.
getViewPointId
()
+
"\tParentLevelId:"
+
spanData
.
getParentLevel
()
+
"\tLevelId:"
+
spanData
.
getLevelId
());
}
Context
.
append
(
spanData
);
}
catch
(
Throwable
t
)
{
logger
.
error
(
t
.
getMessage
(),
t
);
}
}
}
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ThreadBuriedPointSender.java
浏览文件 @
706debcb
...
...
@@ -15,7 +15,13 @@ import com.ai.cloud.skywalking.protocol.Span;
import
com.ai.cloud.skywalking.util.BuriedPointMachineUtil
;
import
com.ai.cloud.skywalking.util.TraceIdGenerator
;
/**
* 暂不确定多线程的实现方式
*
* @author wusheng
*
*/
@Deprecated
public
class
ThreadBuriedPointSender
extends
ApplicationExceptionHandler
implements
IBuriedPointSender
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ThreadBuriedPointSender
.
class
);
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/buriedpoint/ThreadFactoryBuriedPointSender.java
浏览文件 @
706debcb
...
...
@@ -14,6 +14,13 @@ import com.ai.cloud.skywalking.model.Identification;
import
com.ai.cloud.skywalking.protocol.Span
;
import
com.ai.cloud.skywalking.util.ContextGenerator
;
/**
* 暂不确定多线程的实现方式
*
* @author wusheng
*
*/
@Deprecated
public
class
ThreadFactoryBuriedPointSender
extends
ApplicationExceptionHandler
implements
IBuriedPointSender
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
ThreadBuriedPointSender
.
class
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录