Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
99539695
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,发现更多精彩内容 >>
提交
99539695
编写于
7月 06, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support cross-thread propagation.
上级
eaa2a7ca
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
122 addition
and
37 deletion
+122
-37
apm-network/src/main/proto/TraceSegmentService.proto
apm-network/src/main/proto/TraceSegmentService.proto
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
...walking/apm/agent/core/context/AbstractTracerContext.java
+4
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
...org/skywalking/apm/agent/core/context/ContextCarrier.java
+8
-8
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
...org/skywalking/apm/agent/core/context/ContextManager.java
+11
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextSnapshot.java
...rg/skywalking/apm/agent/core/context/ContextSnapshot.java
+39
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/IgnoredTracerContext.java
...ywalking/apm/agent/core/context/IgnoredTracerContext.java
+8
-5
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
...org/skywalking/apm/agent/core/context/TracingContext.java
+15
-7
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
...walking/apm/agent/core/context/trace/TraceSegmentRef.java
+35
-13
未找到文件。
apm-network/src/main/proto/TraceSegmentService.proto
浏览文件 @
99539695
...
...
@@ -20,7 +20,7 @@ message TraceSegmentObject {
string
traceSegmentId
=
1
;
repeated
TraceSegmentReference
refs
=
2
;
repeated
SpanObject
spans
=
3
;
int32
applicationI
nstanceI
d
=
4
;
int32
applicationId
=
4
;
int32
applicationInstanceId
=
5
;
}
...
...
@@ -28,7 +28,7 @@ message TraceSegmentReference {
RefType
refType
=
1
;
string
parentTraceSegmentId
=
2
;
int32
parentSpanId
=
3
;
int32
parentApplicationId
=
4
;
int32
parentApplicationI
nstanceI
d
=
4
;
string
networkAddress
=
5
;
int32
networkAddressId
=
6
;
string
entryServiceName
=
7
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracerContext.java
浏览文件 @
99539695
...
...
@@ -12,6 +12,10 @@ public interface AbstractTracerContext {
void
extract
(
ContextCarrier
carrier
);
ContextSnapshot
capture
();
void
continued
(
ContextSnapshot
snapshot
);
String
getGlobalTraceId
();
AbstractSpan
createEntrySpan
(
String
operationName
);
...
...
@@ -23,6 +27,4 @@ public interface AbstractTracerContext {
AbstractSpan
activeSpan
();
void
stopSpan
(
AbstractSpan
span
);
void
dispose
();
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
浏览文件 @
99539695
...
...
@@ -23,7 +23,7 @@ public class ContextCarrier implements Serializable {
private
int
spanId
=
-
1
;
private
int
applicationId
=
DictionaryUtil
.
nullValue
();
private
int
applicationI
nstanceI
d
=
DictionaryUtil
.
nullValue
();
private
String
peerHost
;
...
...
@@ -45,7 +45,7 @@ public class ContextCarrier implements Serializable {
return
StringUtil
.
join
(
'|'
,
this
.
getTraceSegmentId
(),
this
.
getSpanId
()
+
""
,
this
.
getApplicationId
()
+
""
,
this
.
getApplicationI
nstanceI
d
()
+
""
,
this
.
getPeerHost
(),
this
.
getEntryOperationName
(),
this
.
serializeDistributedTraceIds
());
...
...
@@ -66,7 +66,7 @@ public class ContextCarrier implements Serializable {
try
{
this
.
traceSegmentId
=
parts
[
0
];
this
.
spanId
=
Integer
.
parseInt
(
parts
[
1
]);
this
.
applicationId
=
Integer
.
parseInt
(
parts
[
2
]);
this
.
applicationI
nstanceI
d
=
Integer
.
parseInt
(
parts
[
2
]);
this
.
peerHost
=
parts
[
3
];
this
.
entryOperationName
=
parts
[
4
];
this
.
distributedTraceIds
=
deserializeDistributedTraceIds
(
parts
[
5
]);
...
...
@@ -86,7 +86,7 @@ public class ContextCarrier implements Serializable {
public
boolean
isValid
()
{
return
!
StringUtil
.
isEmpty
(
traceSegmentId
)
&&
getSpanId
()
>
-
1
&&
applicationId
!=
DictionaryUtil
.
nullValue
()
&&
applicationI
nstanceI
d
!=
DictionaryUtil
.
nullValue
()
&&
!
StringUtil
.
isEmpty
(
peerHost
)
&&
!
StringUtil
.
isEmpty
(
entryOperationName
)
&&
distributedTraceIds
!=
null
;
...
...
@@ -120,12 +120,12 @@ public class ContextCarrier implements Serializable {
this
.
spanId
=
spanId
;
}
public
int
getApplicationId
()
{
return
applicationId
;
public
int
getApplicationI
nstanceI
d
()
{
return
applicationI
nstanceI
d
;
}
void
setApplicationI
d
(
int
application
Id
)
{
this
.
applicationI
d
=
application
Id
;
void
setApplicationI
nstanceId
(
int
applicationInstance
Id
)
{
this
.
applicationI
nstanceId
=
applicationInstance
Id
;
}
public
String
getPeerHost
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
99539695
...
...
@@ -106,6 +106,17 @@ public class ContextManager implements TracingContextListener, BootService, Igno
return
span
;
}
public
ContextSnapshot
capture
()
{
return
get
().
capture
();
}
public
void
continued
(
ContextSnapshot
snapshot
)
{
if
(
snapshot
==
null
)
{
throw
new
IllegalArgumentException
(
"ContextSnapshot can't be null."
);
}
get
().
continued
(
snapshot
);
}
public
static
AbstractSpan
activeSpan
()
{
return
get
().
activeSpan
();
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextSnapshot.java
0 → 100644
浏览文件 @
99539695
package
org.skywalking.apm.agent.core.context
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.ids.DistributedTraceId
;
/**
* The <code>ContextSnapshot</code> is a snapshot for current context.
*
* @author wusheng
*/
public
class
ContextSnapshot
{
private
String
traceSegmentId
;
private
int
spanId
=
-
1
;
/**
* {@link DistributedTraceId}
*/
private
List
<
DistributedTraceId
>
distributedTraceIds
;
ContextSnapshot
(
String
traceSegmentId
,
int
spanId
,
List
<
DistributedTraceId
>
distributedTraceIds
)
{
this
.
traceSegmentId
=
traceSegmentId
;
this
.
spanId
=
spanId
;
this
.
distributedTraceIds
=
distributedTraceIds
;
}
public
List
<
DistributedTraceId
>
getDistributedTraceIds
()
{
return
distributedTraceIds
;
}
public
String
getTraceSegmentId
()
{
return
traceSegmentId
;
}
public
int
getSpanId
()
{
return
spanId
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/IgnoredTracerContext.java
浏览文件 @
99539695
...
...
@@ -31,6 +31,14 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
@Override
public
ContextSnapshot
capture
()
{
return
new
ContextSnapshot
(
null
,
-
1
,
null
);
}
@Override
public
void
continued
(
ContextSnapshot
snapshot
)
{
}
@Override
public
String
getGlobalTraceId
()
{
return
"[Ignored Trace]"
;
...
...
@@ -67,11 +75,6 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
}
@Override
public
void
dispose
()
{
}
public
static
class
ListenerManager
{
private
static
List
<
IgnoreTracerContextListener
>
LISTENERS
=
new
LinkedList
<
IgnoreTracerContextListener
>();
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
99539695
...
...
@@ -53,7 +53,7 @@ public class TracingContext implements AbstractTracerContext {
carrier
.
setTraceSegmentId
(
this
.
segment
.
getTraceSegmentId
());
carrier
.
setSpanId
(
span
.
getSpanId
());
carrier
.
setApplicationId
(
segment
.
getApplicationId
());
carrier
.
setApplicationI
nstanceI
d
(
segment
.
getApplicationId
());
if
(
DictionaryUtil
.
isNull
(
exitSpan
.
getPeerId
()))
{
carrier
.
setPeerHost
(
exitSpan
.
getPeer
());
...
...
@@ -87,6 +87,20 @@ public class TracingContext implements AbstractTracerContext {
this
.
segment
.
relatedGlobalTraces
(
carrier
.
getDistributedTraceIds
());
}
@Override
public
ContextSnapshot
capture
()
{
return
new
ContextSnapshot
(
segment
.
getTraceSegmentId
(),
activeSpan
().
getSpanId
(),
segment
.
getRelatedGlobalTraces
()
);
}
@Override
public
void
continued
(
ContextSnapshot
snapshot
)
{
this
.
segment
.
ref
(
new
TraceSegmentRef
(
snapshot
));
this
.
segment
.
relatedGlobalTraces
(
snapshot
.
getDistributedTraceIds
());
}
@Override
public
String
getGlobalTraceId
()
{
return
segment
.
getRelatedGlobalTraces
().
get
(
0
).
get
();
...
...
@@ -236,12 +250,6 @@ public class TracingContext implements AbstractTracerContext {
TracingContext
.
ListenerManager
.
notifyFinish
(
finishedSegment
);
}
@Override
public
void
dispose
()
{
this
.
segment
=
null
;
this
.
activeSpanStack
=
null
;
}
public
static
class
ListenerManager
{
private
static
List
<
TracingContextListener
>
LISTENERS
=
new
LinkedList
<
TracingContextListener
>();
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
浏览文件 @
99539695
package
org.skywalking.apm.agent.core.context.trace
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
import
org.skywalking.apm.network.proto.RefType
;
import
org.skywalking.apm.network.proto.TraceSegmentReference
;
/**
...
...
@@ -11,11 +13,13 @@ import org.skywalking.apm.network.proto.TraceSegmentReference;
* Created by wusheng on 2017/2/17.
*/
public
class
TraceSegmentRef
{
private
SegmentRefType
type
;
private
String
traceSegmentId
;
private
int
spanId
=
-
1
;
private
int
applicationId
;
private
int
applicationI
nstanceI
d
;
private
String
peerHost
;
...
...
@@ -31,9 +35,10 @@ public class TraceSegmentRef {
* @param carrier the valid cross-process propagation format.
*/
public
TraceSegmentRef
(
ContextCarrier
carrier
)
{
this
.
type
=
SegmentRefType
.
CROSS_PROCESS
;
this
.
traceSegmentId
=
carrier
.
getTraceSegmentId
();
this
.
spanId
=
carrier
.
getSpanId
();
this
.
applicationI
d
=
carrier
.
getApplication
Id
();
this
.
applicationI
nstanceId
=
carrier
.
getApplicationInstance
Id
();
String
host
=
carrier
.
getPeerHost
();
if
(
host
.
charAt
(
0
)
==
'#'
)
{
this
.
peerHost
=
host
.
substring
(
1
);
...
...
@@ -48,6 +53,12 @@ public class TraceSegmentRef {
}
}
public
TraceSegmentRef
(
ContextSnapshot
snapshot
)
{
this
.
type
=
SegmentRefType
.
CROSS_THREAD
;
this
.
traceSegmentId
=
snapshot
.
getTraceSegmentId
();
this
.
spanId
=
snapshot
.
getSpanId
();
}
public
String
getOperationName
()
{
return
operationName
;
}
...
...
@@ -58,19 +69,25 @@ public class TraceSegmentRef {
public
TraceSegmentReference
transform
()
{
TraceSegmentReference
.
Builder
refBuilder
=
TraceSegmentReference
.
newBuilder
();
if
(
SegmentRefType
.
CROSS_PROCESS
.
equals
(
type
))
{
refBuilder
.
setRefType
(
RefType
.
CrossProcess
);
refBuilder
.
setParentApplicationInstanceId
(
applicationInstanceId
);
if
(
peerId
==
DictionaryUtil
.
nullValue
())
{
refBuilder
.
setNetworkAddress
(
peerHost
);
}
else
{
refBuilder
.
setNetworkAddressId
(
peerId
);
}
if
(
operationId
==
DictionaryUtil
.
nullValue
())
{
refBuilder
.
setEntryServiceName
(
operationName
);
}
else
{
refBuilder
.
setEntryServiceId
(
operationId
);
}
}
else
{
refBuilder
.
setRefType
(
RefType
.
CrossThread
);
}
refBuilder
.
setParentTraceSegmentId
(
traceSegmentId
);
refBuilder
.
setParentSpanId
(
spanId
);
refBuilder
.
setParentApplicationId
(
applicationId
);
if
(
peerId
==
DictionaryUtil
.
nullValue
())
{
refBuilder
.
setNetworkAddress
(
peerHost
);
}
else
{
refBuilder
.
setNetworkAddressId
(
peerId
);
}
if
(
operationId
==
DictionaryUtil
.
nullValue
())
{
refBuilder
.
setEntryServiceName
(
operationName
);
}
else
{
refBuilder
.
setEntryServiceId
(
operationId
);
}
return
refBuilder
.
build
();
}
...
...
@@ -94,4 +111,9 @@ public class TraceSegmentRef {
result
=
31
*
result
+
spanId
;
return
result
;
}
public
enum
SegmentRefType
{
CROSS_PROCESS
,
CROSS_THREAD
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录