Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
0d0d9840
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 搜索 >>
提交
0d0d9840
编写于
3月 17, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. Remove the primary ref. Only use ref to the parent segment.
2. Adjust globalTracerIds
上级
dfa0eead
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
53 addition
and
75 deletion
+53
-75
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java
...rc/main/java/com/a/eye/skywalking/trace/TraceSegment.java
+22
-58
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
...main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
+27
-0
skywalking-commons/skywalking-trace/src/main/proto/trace.proto
...lking-commons/skywalking-trace/src/main/proto/trace.proto
+3
-4
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java
.../java/com/a/eye/skywalking/api/context/TracerContext.java
+1
-13
未找到文件。
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegment.java
浏览文件 @
0d0d9840
...
...
@@ -41,14 +41,8 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
private
long
endTime
;
/**
* The primary ref of the parent trace segment.
* Use {@link TraceSegmentRef}, we can link this trace segment to the primary parent segment.
*/
private
TraceSegmentRef
primaryRef
;
/**
* The refs of other parent trace segments, except the primary one.
* For most RPC call, {@link #refs} stay in null,
* The refs of parent trace segments, except the primary one.
* For most RPC call, {@link #refs} contains only one element,
* but if this segment is a start span of batch process, the segment faces multi parents,
* at this moment, we use this {@link #refs} to link them.
*/
...
...
@@ -74,13 +68,13 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
* element, because only one parent {@link TraceSegment} exists, but, in batch scenario, the num becomes greater
* than 1, also meaning multi-parents {@link TraceSegment}.
*
* The difference between <code>relatedGlobalTraces</code> and {@link #
primaryRef}/{@link #refs} is: {@link
*
#primaryRef}/
{@link #refs} targets this {@link TraceSegment}'s direct parent,
* The difference between <code>relatedGlobalTraces</code> and {@link #
refs} is:
* {@link #refs} targets this {@link TraceSegment}'s direct parent,
*
* and
*
* <code>relatedGlobalTraces</code> targets this {@link TraceSegment}'s related call chain, a call chain contains
* multi {@link TraceSegment}s, only using {@link #
primaryRef}/{@link #refs} is
enough for analysis and ui.
* multi {@link TraceSegment}s, only using {@link #
refs} is not
enough for analysis and ui.
*/
private
LinkedList
<
DistributedTraceId
>
relatedGlobalTraces
;
...
...
@@ -108,48 +102,27 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
/**
* Establish the link between this segment and its parents.
* When {@param primaryOnly} is true;
* The first time, you {@link #ref(TraceSegmentRef)} to parent, it is affirmed as {@link #primaryRef}.
* And others are affirmed as {@link #refs}.
*
* @param refSegment {@link TraceSegmentRef}
* @param primaryOnly if true, set {@param refSegment} to {@link #primaryRef} only.
*/
public
void
ref
(
TraceSegmentRef
refSegment
,
boolean
primaryOnly
)
{
if
(
primaryOnly
)
{
if
(
primaryRef
==
null
)
{
primaryRef
=
refSegment
;
}
}
else
{
if
(
primaryRef
==
null
)
{
primaryRef
=
refSegment
;
}
else
{
if
(
refs
==
null
)
{
refs
=
new
LinkedList
<
TraceSegmentRef
>();
}
refs
.
add
(
refSegment
);
}
}
}
/**
* Set to {@link #primaryRef} only,
* based on {@link #ref(TraceSegmentRef, boolean)}
*
* @param refSegment {@link TraceSegmentRef}
*/
public
void
ref
(
TraceSegmentRef
refSegment
)
{
ref
(
refSegment
,
true
);
if
(!
refs
.
contains
(
refSegment
)){
refs
.
add
(
refSegment
);
}
}
public
void
buildRelation
(
List
<
DistributedTraceId
>
distributedTraceIds
)
{
if
(
distributedTraceIds
==
null
||
distributedTraceIds
.
size
()
==
0
)
{
public
void
relatedGlobalTraces
(
List
<
DistributedTraceId
>
distributedTraceIds
)
{
if
(
distributedTraceIds
==
null
||
distributedTraceIds
.
size
()
==
0
)
{
return
;
}
if
(
relatedGlobalTraces
.
getFirst
()
instanceof
NewDistributedTraceId
)
{
if
(
relatedGlobalTraces
.
getFirst
()
instanceof
NewDistributedTraceId
)
{
relatedGlobalTraces
.
removeFirst
();
}
relatedGlobalTraces
.
addAll
(
distributedTraceIds
);
for
(
DistributedTraceId
distributedTraceId
:
distributedTraceIds
)
{
if
(!
relatedGlobalTraces
.
contains
(
distributedTraceId
)){
relatedGlobalTraces
.
add
(
distributedTraceId
);
}
}
}
/**
...
...
@@ -184,10 +157,6 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
return
endTime
;
}
public
TraceSegmentRef
getPrimaryRef
()
{
return
primaryRef
;
}
public
List
<
TraceSegmentRef
>
getRefs
()
{
if
(
refs
==
null
)
{
return
null
;
...
...
@@ -207,13 +176,15 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
return
applicationCode
;
}
@Override
public
String
toString
()
{
@Override
public
String
toString
()
{
return
"TraceSegment{"
+
"traceSegmentId='"
+
traceSegmentId
+
'\''
+
", startTime="
+
startTime
+
", endTime="
+
endTime
+
", primaryRef="
+
primaryRef
+
", spans.size="
+
spans
.
size
()
+
", refs="
+
refs
+
", spans="
+
spans
+
", applicationCode='"
+
applicationCode
+
'\''
+
", relatedGlobalTraces="
+
relatedGlobalTraces
+
'}'
;
}
...
...
@@ -224,9 +195,6 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
segmentBuilder
.
setStartTime
(
startTime
);
segmentBuilder
.
setEndTime
(
endTime
);
segmentBuilder
.
setApplicationCode
(
applicationCode
);
if
(
primaryRef
!=
null
)
{
segmentBuilder
.
setPrimaryRef
(
primaryRef
.
serialize
());
}
if
(
refs
!=
null
&&
refs
.
size
()
>
0
)
{
for
(
TraceSegmentRef
ref
:
refs
)
{
segmentBuilder
.
addRefs
(
ref
.
serialize
());
...
...
@@ -247,10 +215,6 @@ public class TraceSegment implements ISerializable<SegmentMessage> {
startTime
=
message
.
getStartTime
();
endTime
=
message
.
getEndTime
();
applicationCode
=
message
.
getApplicationCode
();
SegmentRefMessage
messagePrimaryRef
=
message
.
getPrimaryRef
();
if
(
messagePrimaryRef
!=
null
)
{
(
primaryRef
=
new
TraceSegmentRef
()).
deserialize
(
messagePrimaryRef
);
}
List
<
SegmentRefMessage
>
refsList
=
message
.
getRefsList
();
if
(
refsList
!=
null
&&
refsList
.
size
()
>
0
)
{
this
.
refs
=
new
LinkedList
<
TraceSegmentRef
>();
...
...
skywalking-commons/skywalking-trace/src/main/java/com/a/eye/skywalking/trace/TraceSegmentRef.java
浏览文件 @
0d0d9840
...
...
@@ -97,4 +97,31 @@ public class TraceSegmentRef implements ISerializable<SegmentRefMessage> {
applicationCode
=
message
.
getApplicationCode
();
peerHost
=
message
.
getPeerHost
();
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
TraceSegmentRef
ref
=
(
TraceSegmentRef
)
o
;
if
(
spanId
!=
ref
.
spanId
)
return
false
;
if
(
traceSegmentId
!=
null
?
!
traceSegmentId
.
equals
(
ref
.
traceSegmentId
)
:
ref
.
traceSegmentId
!=
null
)
return
false
;
if
(
applicationCode
!=
null
?
!
applicationCode
.
equals
(
ref
.
applicationCode
)
:
ref
.
applicationCode
!=
null
)
return
false
;
return
peerHost
!=
null
?
peerHost
.
equals
(
ref
.
peerHost
)
:
ref
.
peerHost
==
null
;
}
@Override
public
int
hashCode
()
{
int
result
=
traceSegmentId
!=
null
?
traceSegmentId
.
hashCode
()
:
0
;
result
=
31
*
result
+
spanId
;
result
=
31
*
result
+
(
applicationCode
!=
null
?
applicationCode
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
peerHost
!=
null
?
peerHost
.
hashCode
()
:
0
);
return
result
;
}
}
skywalking-commons/skywalking-trace/src/main/proto/trace.proto
浏览文件 @
0d0d9840
...
...
@@ -8,10 +8,9 @@ message SegmentMessage {
int64
startTime
=
2
;
int64
endTime
=
3
;
string
applicationCode
=
4
;
SegmentRefMessage
primaryRef
=
5
;
repeated
SegmentRefMessage
refs
=
6
;
repeated
string
relatedTraceIds
=
7
;
repeated
SpanMessage
spans
=
8
;
repeated
SegmentRefMessage
refs
=
5
;
repeated
string
relatedTraceIds
=
6
;
repeated
SpanMessage
spans
=
7
;
}
message
SegmentRefMessage
{
...
...
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/context/TracerContext.java
浏览文件 @
0d0d9840
...
...
@@ -137,19 +137,7 @@ public final class TracerContext {
public
void
extract
(
ContextCarrier
carrier
)
{
if
(
carrier
.
isValid
())
{
this
.
segment
.
ref
(
getRef
(
carrier
));
this
.
segment
.
buildRelation
(
carrier
.
getDistributedTraceIds
());
}
}
/**
* Ref this {@link ContextCarrier} to this {@link TraceSegment}, and support multi-extract for supporting batch process, like MQ.
*
* @param carrier holds the snapshot, if get this {@link ContextCarrier} from remote, make sure {@link
* ContextCarrier#deserialize(String)} called.
*/
public
void
multiExtract
(
ContextCarrier
carrier
){
if
(
carrier
.
isValid
())
{
this
.
segment
.
ref
(
getRef
(
carrier
),
false
);
this
.
segment
.
relatedGlobalTraces
(
carrier
.
getDistributedTraceIds
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录