Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
1fd449cd
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,发现更多精彩内容 >>
提交
1fd449cd
编写于
6月 28, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish the refactor of agent-core.
上级
48b2164f
变更
59
隐藏空白更改
内联
并排
Showing
59 changed file
with
436 addition
and
729 deletion
+436
-729
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
...org/skywalking/apm/agent/core/context/ContextCarrier.java
+10
-12
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
...org/skywalking/apm/agent/core/context/ContextManager.java
+8
-10
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/IgnoredTracerContext.java
...ywalking/apm/agent/core/context/IgnoredTracerContext.java
+6
-10
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/Injectable.java
...ava/org/skywalking/apm/agent/core/context/Injectable.java
+1
-4
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracerContext.java
.../org/skywalking/apm/agent/core/context/TracerContext.java
+0
-293
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
...org/skywalking/apm/agent/core/context/TracingContext.java
+79
-20
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/BooleanTag.java
...org/skywalking/apm/agent/core/context/tag/BooleanTag.java
+0
-27
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/BooleanTagItem.java
...skywalking/apm/agent/core/context/tag/BooleanTagItem.java
+0
-24
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/IntTag.java
...ava/org/skywalking/apm/agent/core/context/tag/IntTag.java
+0
-20
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/IntTagItem.java
...org/skywalking/apm/agent/core/context/tag/IntTagItem.java
+0
-24
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/StringTag.java
.../org/skywalking/apm/agent/core/context/tag/StringTag.java
+1
-1
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/StringTagItem.java
.../skywalking/apm/agent/core/context/tag/StringTagItem.java
+0
-24
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/Tags.java
.../java/org/skywalking/apm/agent/core/context/tag/Tags.java
+1
-6
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractSpan.java
...skywalking/apm/agent/core/context/trace/AbstractSpan.java
+8
-47
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
...ing/apm/agent/core/context/trace/AbstractTracingSpan.java
+74
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/EntrySpan.java
...rg/skywalking/apm/agent/core/context/trace/EntrySpan.java
+10
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/ExitSpan.java
...org/skywalking/apm/agent/core/context/trace/ExitSpan.java
+30
-4
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/LocalSpan.java
...rg/skywalking/apm/agent/core/context/trace/LocalSpan.java
+4
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/LogDataEntity.java
...kywalking/apm/agent/core/context/trace/LogDataEntity.java
+2
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopSpan.java
...org/skywalking/apm/agent/core/context/trace/NoopSpan.java
+3
-8
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
+20
-21
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
+19
-49
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/ApplicationDictionary.java
...king/apm/agent/core/dictionary/ApplicationDictionary.java
+15
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryManager.java
...ywalking/apm/agent/core/dictionary/DictionaryManager.java
+9
-2
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryUtil.java
.../skywalking/apm/agent/core/dictionary/DictionaryUtil.java
+18
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryValueHolder.java
...king/apm/agent/core/dictionary/DictionaryValueHolder.java
+16
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/Found.java
.../java/org/skywalking/apm/agent/core/dictionary/Found.java
+10
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/IDictionaryCompressible.java
...ng/apm/agent/core/dictionary/IDictionaryCompressible.java
+0
-15
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/NotFound.java
...va/org/skywalking/apm/agent/core/dictionary/NotFound.java
+10
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/OperationNameDictionary.java
...ng/apm/agent/core/dictionary/OperationNameDictionary.java
+55
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java
...g/skywalking/apm/agent/core/dictionary/PossibleFound.java
+27
-5
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/queue/TraceSegmentProcessQueue.java
...alking/apm/agent/core/queue/TraceSegmentProcessQueue.java
+0
-1
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/trace/LeafSpanTestCase.java
...alking/apm/agent/core/context/trace/LeafSpanTestCase.java
+0
-4
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/trace/SpanTestCase.java
...skywalking/apm/agent/core/context/trace/SpanTestCase.java
+0
-1
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/sampling/SamplingTracerContextTestCase.java
...pm/agent/core/sampling/SamplingTracerContextTestCase.java
+0
-1
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/BooleanTagReader.java
.../org/skywalking/apm/agent/core/tags/BooleanTagReader.java
+0
-32
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/IntTagReader.java
...java/org/skywalking/apm/agent/core/tags/IntTagReader.java
+0
-32
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/StringTagReader.java
...a/org/skywalking/apm/agent/core/tags/StringTagReader.java
+0
-1
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
...org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
...lugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
...lugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
...g/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
...java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
.../java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
...g/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jedis/v2/JedisMethodInterceptorTest.java
...lking/apm/plugin/jedis/v2/JedisMethodInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java
...g/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBWriteMethodInterceptorTest.java
.../plugin/mongodb/v3/MongoDBWriteMethodInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
...alking/apm/plugin/motan/MotanConsumerInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
...alking/apm/plugin/motan/MotanProviderInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
...walking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java
...kywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java
...kywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java
+0
-1
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java
...kywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java
+0
-1
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/context/MockTracingContextListener.java
.../apm/sniffer/mock/context/MockTracingContextListener.java
+0
-1
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
...ng/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
+0
-1
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/BooleanTagReader.java
...walking/apm/sniffer/mock/trace/tags/BooleanTagReader.java
+0
-2
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/IntTagReader.java
.../skywalking/apm/sniffer/mock/trace/tags/IntTagReader.java
+0
-2
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/StringTagReader.java
...ywalking/apm/sniffer/mock/trace/tags/StringTagReader.java
+0
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
浏览文件 @
1fd449cd
...
...
@@ -9,8 +9,8 @@ import org.skywalking.apm.agent.core.context.trace.TraceSegment;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link ContextCarrier} is a data carrier of {@link Trac
er
Context}.
* It holds the snapshot (current state) of {@link Trac
er
Context}.
* {@link ContextCarrier} is a data carrier of {@link Trac
ing
Context}.
* It holds the snapshot (current state) of {@link Trac
ing
Context}.
* <p>
* Created by wusheng on 2017/2/17.
*/
...
...
@@ -20,20 +20,10 @@ public class ContextCarrier implements Serializable {
*/
private
String
traceSegmentId
;
/**
* {@link Span#spanId}
*/
private
int
spanId
=
-
1
;
/**
* {@link TraceSegment#applicationCode}
*/
private
String
applicationCode
;
/**
* Either {@link Span#peerHost} + {@link Span#port} or {@link Span#peers},
* depend on which one of them is valid.
*/
private
String
peerHost
;
/**
...
...
@@ -120,6 +110,10 @@ public class ContextCarrier implements Serializable {
this
.
applicationCode
=
applicationCode
;
}
public
void
setApplicationId
(
int
applicationId
)
{
this
.
applicationCode
=
applicationId
+
""
;
}
public
String
getPeerHost
()
{
return
peerHost
;
}
...
...
@@ -128,6 +122,10 @@ public class ContextCarrier implements Serializable {
this
.
peerHost
=
peerHost
;
}
public
void
setPeerId
(
int
peerId
)
{
this
.
peerHost
=
peerId
+
""
;
}
public
List
<
DistributedTraceId
>
getDistributedTraceIds
()
{
return
distributedTraceIds
;
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
1fd449cd
...
...
@@ -10,13 +10,12 @@ import org.skywalking.apm.agent.core.sampling.SamplingService;
import
org.skywalking.apm.util.StringUtil
;
/**
* {@link
TracerContext
} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
* {@link
ContextManager
} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
* single-thread, so this context use {@link ThreadLocal} to maintain the context, and make sure, since a {@link
* TraceSegment} starts, all ChildOf spans are in the same context. <p> What is 'ChildOf'? {@see
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans} <p> Also, {@link
* ContextManager} delegates to all {@link TracerContext}'s major methods: {@link TracerContext#createSpan(String,
* boolean)}, {@link TracerContext#activeSpan()}, {@link AbstractTracerContext#stopSpan(org.skywalking.apm.agent.core.context.trace.AbstractSpan)}
* <p>
* https://github.com/opentracing/specification/blob/master/specification.md#references-between-spans}
*
* <p> Also, {@link ContextManager} delegates to all {@link AbstractTracerContext}'s major methods.
*
* @author wusheng
*/
...
...
@@ -37,10 +36,7 @@ public class ContextManager implements TracingContextListener, BootService, Igno
if
(
forceSampling
||
samplingService
.
trySampling
())
{
context
=
new
TracingContext
();
}
else
{
/**
* {@link ContextType#AGGREGATED_TRACING}
* TODO
*/
context
=
new
IgnoredTracerContext
();
}
}
CONTEXT
.
set
(
context
);
...
...
@@ -90,7 +86,9 @@ public class ContextManager implements TracingContextListener, BootService, Igno
throw
new
IllegalArgumentException
(
"Injectable can't be null."
);
}
AbstractTracerContext
context
=
getOrCreate
(
operationName
,
false
);
return
context
.
createSpan
(
operationName
,
SpanType
.
EXIT
);
AbstractSpan
span
=
context
.
createSpan
(
operationName
,
SpanType
.
EXIT
);
context
.
inject
(
injectable
.
getCarrier
());
return
span
;
}
public
static
AbstractSpan
activeSpan
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/IgnoredTracerContext.java
浏览文件 @
1fd449cd
...
...
@@ -4,6 +4,7 @@ import java.util.LinkedList;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.NoopSpan
;
import
org.skywalking.apm.agent.core.context.trace.SpanType
;
/**
* The <code>IgnoredTracerContext</code> represent a context should be ignored.
...
...
@@ -37,14 +38,14 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
@Override
public
AbstractSpan
createSpan
(
String
operationName
,
boolean
isLeaf
)
{
stackDepth
++;
return
NOOP_SPAN
;
public
AbstractSpan
createSpan
(
String
operationName
,
SpanType
spanType
)
{
return
createSpan
(
operationName
,
spanType
,
null
);
}
@Override
public
AbstractSpan
createSpan
(
String
operationName
,
long
startTime
,
boolean
isLeaf
)
{
return
createSpan
(
operationName
,
isLeaf
);
public
AbstractSpan
createSpan
(
String
operationName
,
SpanType
spanType
,
Injectable
injectable
)
{
stackDepth
++;
return
NOOP_SPAN
;
}
@Override
...
...
@@ -60,11 +61,6 @@ public class IgnoredTracerContext implements AbstractTracerContext {
}
}
@Override
public
void
stopSpan
(
AbstractSpan
span
,
Long
endTime
)
{
stopSpan
(
span
);
}
@Override
public
void
dispose
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/Injectable.java
浏览文件 @
1fd449cd
...
...
@@ -6,10 +6,7 @@ package org.skywalking.apm.agent.core.context;
* @author wusheng
*/
public
interface
Injectable
{
/**
* @param injectedCarrier notify the <code>Injectable</code> the {@link ContextCarrier} has been injected.
*/
void
notify
(
ContextCarrier
injectedCarrier
);
ContextCarrier
getCarrier
();
/**
* @return peer, represent ipv4, ipv6, hostname, or cluster addresses list.
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracerContext.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegmentRef
;
import
org.skywalking.apm.agent.core.sampling.SamplingService
;
/**
* {@link TracerContext} maintains the context.
* You manipulate (create/finish/get) spans and (inject/extract) context.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
final
class
TracerContext
implements
AbstractTracerContext
{
private
SamplingService
samplingService
;
private
TraceSegment
segment
;
/**
* Active spans stored in a Stack, usually called 'ActiveSpanStack'.
* This {@link LinkedList} is the in-memory storage-structure.
* <p>
* I use {@link LinkedList#removeLast()}, {@link LinkedList#addLast(Object)} and {@link LinkedList#last} instead of
* {@link #pop()}, {@link #push(Span)}, {@link #peek()}
*/
private
LinkedList
<
Span
>
activeSpanStack
=
new
LinkedList
<
Span
>();
private
int
spanIdGenerator
;
/**
* Create a {@link TraceSegment} and init {@link #spanIdGenerator} as 0;
*/
TracerContext
()
{
this
.
segment
=
new
TraceSegment
(
Config
.
Agent
.
APPLICATION_CODE
);
this
.
spanIdGenerator
=
0
;
if
(
samplingService
==
null
)
{
samplingService
=
ServiceManager
.
INSTANCE
.
findService
(
SamplingService
.
class
);
}
}
/**
* Create a new span, as an active span, by the given operationName
*
* @param operationName {@link Span#operationName}
* @return the new active span.
*/
public
AbstractSpan
createSpan
(
String
operationName
,
boolean
isLeaf
)
{
return
this
.
createSpan
(
operationName
,
System
.
currentTimeMillis
(),
isLeaf
);
}
/**
* Create a new span, as an active span, by the given operationName and startTime;
*
* @param operationName {@link Span#operationName}
* @param startTime {@link Span#startTime}
* @param isLeaf is true, if the span is a leaf in trace tree.
* @return
*/
public
AbstractSpan
createSpan
(
String
operationName
,
long
startTime
,
boolean
isLeaf
)
{
Span
parentSpan
=
peek
();
Span
span
;
if
(
parentSpan
==
null
)
{
if
(
operationName
!=
null
)
{
int
suffixIdx
=
operationName
.
lastIndexOf
(
"."
);
if
(
suffixIdx
>
-
1
&&
Config
.
Agent
.
IGNORE_SUFFIX
.
contains
(
operationName
.
substring
(
suffixIdx
)))
{
ContextManager
.
ContextSwitcher
.
INSTANCE
.
toNew
(
new
IgnoredTracerContext
(
1
));
return
ContextManager
.
activeSpan
();
}
}
if
(
isLeaf
)
{
span
=
new
LeafSpan
(
spanIdGenerator
++,
operationName
,
startTime
);
}
else
{
span
=
new
Span
(
spanIdGenerator
++,
operationName
,
startTime
);
}
push
(
span
);
}
else
{
/**
* Don't have ref yet, means this isn't part of distributed trace.
* Use sampling mechanism
* Only check this on the second span,
* because the {@link #extract(ContextCarrier)} invoke before create the second span.
*/
if
(
spanIdGenerator
==
1
)
{
if
(
segment
.
hasRef
())
{
samplingService
.
forceSampled
();
}
else
{
if
(!
samplingService
.
trySampling
())
{
/**
* Don't sample this trace.
* Now, switch this trace as an {@link IgnoredTracerContext},
* further more, we will provide an analytic tracer context for all metrics in this trace.
*/
ContextManager
.
ContextSwitcher
.
INSTANCE
.
toNew
(
new
IgnoredTracerContext
(
2
));
return
ContextManager
.
activeSpan
();
}
}
}
if
(
parentSpan
.
isLeaf
())
{
span
=
parentSpan
;
LeafSpan
leafSpan
=
(
LeafSpan
)
span
;
leafSpan
.
push
();
}
else
{
if
(
isLeaf
)
{
span
=
new
LeafSpan
(
spanIdGenerator
++,
parentSpan
,
operationName
,
startTime
);
}
else
{
span
=
new
Span
(
spanIdGenerator
++,
parentSpan
,
operationName
,
startTime
);
}
push
(
span
);
}
}
return
span
;
}
/**
* @return the active span of current context.
*/
public
AbstractSpan
activeSpan
()
{
Span
span
=
peek
();
if
(
span
==
null
)
{
throw
new
IllegalStateException
(
"No active span."
);
}
return
span
;
}
/**
* Stop the span. And finish the {@link #segment} if all {@link #activeSpanStack} elements are finished.
*
* @param span to finish. It must the the top element of {@link #activeSpanStack}.
*/
public
void
stopSpan
(
AbstractSpan
span
)
{
stopSpan
(
span
,
System
.
currentTimeMillis
());
}
/**
* @return the current trace id.
*/
public
String
getGlobalTraceId
()
{
return
segment
.
getRelatedGlobalTraces
().
get
(
0
).
get
();
}
public
void
stopSpan
(
AbstractSpan
span
,
Long
endTime
)
{
Span
lastSpan
=
peek
();
if
(
lastSpan
.
isLeaf
())
{
LeafSpan
leafSpan
=
(
LeafSpan
)
lastSpan
;
leafSpan
.
pop
();
if
(!
leafSpan
.
isFinished
())
{
return
;
}
}
if
(
lastSpan
==
span
)
{
pop
().
finish
(
segment
,
endTime
);
}
else
{
throw
new
IllegalStateException
(
"Stopping the unexpected span = "
+
span
);
}
if
(
activeSpanStack
.
isEmpty
())
{
this
.
finish
();
}
}
@Override
public
void
dispose
()
{
this
.
segment
=
null
;
this
.
activeSpanStack
=
null
;
}
/**
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link ListenerManager}
*/
private
void
finish
()
{
TraceSegment
finishedSegment
=
segment
.
finish
();
/**
* Recheck the segment if the segment contains only one span.
* Because in the runtime, can't sure this segment is part of distributed trace.
*
* @see {@link #createSpan(String, long, boolean)}
*/
if
(!
segment
.
hasRef
()
&&
segment
.
isSingleSpanSegment
())
{
if
(!
samplingService
.
trySampling
())
{
finishedSegment
.
setIgnore
(
true
);
}
}
ListenerManager
.
notifyFinish
(
finishedSegment
);
}
/**
* Give a snapshot of this {@link TracerContext},
* and save current state to the given {@link ContextCarrier}.
*
* @param carrier holds the snapshot
*/
public
void
inject
(
ContextCarrier
carrier
)
{
carrier
.
setTraceSegmentId
(
this
.
segment
.
getTraceSegmentId
());
Span
span
=
(
Span
)
this
.
activeSpan
();
carrier
.
setSpanId
(
span
.
getSpanId
());
carrier
.
setApplicationCode
(
Config
.
Agent
.
APPLICATION_CODE
);
String
host
=
span
.
getPeerHost
();
if
(
host
!=
null
)
{
Integer
port
=
span
.
getPort
();
carrier
.
setPeerHost
(
host
+
":"
+
port
);
}
else
{
carrier
.
setPeerHost
(
span
.
getPeers
());
}
carrier
.
setDistributedTraceIds
(
this
.
segment
.
getRelatedGlobalTraces
());
}
/**
* Ref this {@link ContextCarrier} to this {@link TraceSegment}
*
* @param carrier holds the snapshot, if get this {@link ContextCarrier} from remote, make sure {@link
* ContextCarrier#deserialize(String)} called.
*/
public
void
extract
(
ContextCarrier
carrier
)
{
if
(
carrier
.
isValid
())
{
this
.
segment
.
ref
(
getRef
(
carrier
));
this
.
segment
.
relatedGlobalTraces
(
carrier
.
getDistributedTraceIds
());
}
}
private
TraceSegmentRef
getRef
(
ContextCarrier
carrier
)
{
TraceSegmentRef
ref
=
new
TraceSegmentRef
();
ref
.
setTraceSegmentId
(
carrier
.
getTraceSegmentId
());
ref
.
setSpanId
(
carrier
.
getSpanId
());
ref
.
setApplicationCode
(
carrier
.
getApplicationCode
());
ref
.
setPeerHost
(
carrier
.
getPeerHost
());
return
ref
;
}
/**
* @return the top element of 'ActiveSpanStack', and remove it.
*/
private
Span
pop
()
{
return
activeSpanStack
.
removeLast
();
}
/**
* Add a new Span at the top of 'ActiveSpanStack'
*
* @param span
*/
private
void
push
(
Span
span
)
{
activeSpanStack
.
addLast
(
span
);
}
/**
* @return the top element of 'ActiveSpanStack' only.
*/
private
Span
peek
()
{
if
(
activeSpanStack
.
isEmpty
())
{
return
null
;
}
return
activeSpanStack
.
getLast
();
}
public
static
class
ListenerManager
{
private
static
List
<
TracingContextListener
>
LISTENERS
=
new
LinkedList
<
TracingContextListener
>();
/**
* Add the given {@link TracingContextListener} to {@link #LISTENERS} list.
*
* @param listener the new listener.
*/
public
static
synchronized
void
add
(
TracingContextListener
listener
)
{
LISTENERS
.
add
(
listener
);
}
/**
* Notify the {@link ListenerManager} about the given {@link TraceSegment} have finished.
* And trigger {@link ListenerManager} to notify all {@link #LISTENERS} 's
* {@link TracingContextListener#afterFinished(TraceSegment)}
*
* @param finishedSegment
*/
static
void
notifyFinish
(
TraceSegment
finishedSegment
)
{
for
(
TracingContextListener
listener
:
LISTENERS
)
{
listener
.
afterFinished
(
finishedSegment
);
}
}
/**
* Clear the given {@link TracingContextListener}
*/
public
static
synchronized
void
remove
(
TracingContextListener
listener
)
{
LISTENERS
.
remove
(
listener
);
}
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
浏览文件 @
1fd449cd
...
...
@@ -11,6 +11,9 @@ import org.skywalking.apm.agent.core.context.trace.LocalSpan;
import
org.skywalking.apm.agent.core.context.trace.SpanType
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegmentRef
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryManager
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
import
org.skywalking.apm.agent.core.dictionary.PossibleFound
;
import
org.skywalking.apm.agent.core.sampling.SamplingService
;
/**
...
...
@@ -42,12 +45,29 @@ public class TracingContext implements AbstractTracerContext {
@Override
public
void
inject
(
ContextCarrier
carrier
)
{
AbstractTracingSpan
span
=
this
.
activeSpan
();
if
(
span
.
isExit
())
{
throw
new
IllegalStateException
(
"Inject can be done only in Exit Span"
);
}
ExitSpan
exitSpan
=
(
ExitSpan
)
span
;
carrier
.
setTraceSegmentId
(
this
.
segment
.
getTraceSegmentId
());
carrier
.
setSpanId
(
span
.
getSpanId
());
carrier
.
setApplicationId
(
segment
.
getApplicationId
());
if
(
DictionaryUtil
.
isNull
(
exitSpan
.
getPeerId
()))
{
carrier
.
setPeerHost
(
exitSpan
.
getPeer
());
}
else
{
carrier
.
setPeerId
(
exitSpan
.
getPeerId
());
}
carrier
.
setDistributedTraceIds
(
this
.
segment
.
getRelatedGlobalTraces
());
}
@Override
public
void
extract
(
ContextCarrier
carrier
)
{
this
.
segment
.
ref
(
ge
tRef
(
carrier
));
this
.
segment
.
ref
(
new
TraceSegmen
tRef
(
carrier
));
this
.
segment
.
relatedGlobalTraces
(
carrier
.
getDistributedTraceIds
());
}
...
...
@@ -69,23 +89,71 @@ public class TracingContext implements AbstractTracerContext {
return
span
.
start
();
}
private
AbstractTracingSpan
createByType
(
int
spanId
,
int
parentSpanId
,
String
operationName
,
SpanType
spanType
,
String
peerHost
,
AbstractTracingSpan
parentSpan
)
{
private
AbstractTracingSpan
createByType
(
final
int
spanId
,
final
int
parentSpanId
,
final
String
operationName
,
SpanType
spanType
,
final
String
peerHost
,
AbstractTracingSpan
parentSpan
)
{
switch
(
spanType
)
{
case
LOCAL:
return
new
LocalSpan
(
spanId
,
parentSpanId
,
operationName
);
return
(
AbstractTracingSpan
)
DictionaryManager
.
findOperationNameCodeSection
()
.
find
(
segment
.
getApplicationId
(),
operationName
)
.
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
int
operationId
)
{
return
new
LocalSpan
(
spanId
,
parentSpanId
,
operationId
);
}
},
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
return
new
LocalSpan
(
spanId
,
parentSpanId
,
operationName
);
}
});
case
EXIT:
if
(
parentSpan
!=
null
&&
parentSpan
.
isExit
())
{
return
parentSpan
;
}
else
{
return
new
ExitSpan
(
spanId
,
parentSpanId
,
operationName
,
peerHost
);
return
(
AbstractTracingSpan
)
DictionaryManager
.
findApplicationCodeSection
()
.
find
(
peerHost
).
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
final
int
applicationId
)
{
return
DictionaryManager
.
findOperationNameCodeSection
()
.
find
(
applicationId
,
operationName
)
.
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
int
peerId
)
{
return
new
ExitSpan
(
spanId
,
parentSpanId
,
applicationId
,
peerId
);
}
},
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
return
new
ExitSpan
(
spanId
,
parentSpanId
,
applicationId
,
peerHost
);
}
});
}
},
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
return
new
ExitSpan
(
spanId
,
parentSpanId
,
operationName
,
peerHost
);
}
});
}
case
ENTRY:
if
(
parentSpan
.
isEntry
())
{
return
parentSpan
;
}
else
if
(
parentSpan
==
null
)
{
return
new
EntrySpan
(
spanId
,
parentSpanId
,
operationName
);
return
(
AbstractTracingSpan
)
DictionaryManager
.
findOperationNameCodeSection
()
.
find
(
segment
.
getApplicationId
(),
operationName
)
.
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
int
operationId
)
{
return
new
EntrySpan
(
spanId
,
parentSpanId
,
operationId
);
}
},
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
return
new
EntrySpan
(
spanId
,
parentSpanId
,
operationName
);
}
});
}
else
{
throw
new
IllegalStateException
(
"The Entry Span can't be the child of Non-Entry Span"
);
}
...
...
@@ -121,7 +189,7 @@ public class TracingContext implements AbstractTracerContext {
/**
* Finish this context, and notify all {@link TracingContextListener}s, managed by {@link
* Trac
er
Context.ListenerManager}
* Trac
ing
Context.ListenerManager}
*/
private
void
finish
()
{
TraceSegment
finishedSegment
=
segment
.
finish
();
...
...
@@ -136,7 +204,7 @@ public class TracingContext implements AbstractTracerContext {
finishedSegment
.
setIgnore
(
true
);
}
}
Trac
er
Context
.
ListenerManager
.
notifyFinish
(
finishedSegment
);
Trac
ing
Context
.
ListenerManager
.
notifyFinish
(
finishedSegment
);
}
@Override
...
...
@@ -158,8 +226,8 @@ public class TracingContext implements AbstractTracerContext {
}
/**
* Notify the {@link Trac
er
Context.ListenerManager} about the given {@link TraceSegment} have finished.
* And trigger {@link Trac
er
Context.ListenerManager} to notify all {@link #LISTENERS} 's
* Notify the {@link Trac
ing
Context.ListenerManager} about the given {@link TraceSegment} have finished.
* And trigger {@link Trac
ing
Context.ListenerManager} to notify all {@link #LISTENERS} 's
* {@link TracingContextListener#afterFinished(TraceSegment)}
*
* @param finishedSegment
...
...
@@ -204,13 +272,4 @@ public class TracingContext implements AbstractTracerContext {
}
return
activeSpanStack
.
getLast
();
}
private
TraceSegmentRef
getRef
(
ContextCarrier
carrier
)
{
TraceSegmentRef
ref
=
new
TraceSegmentRef
();
ref
.
setTraceSegmentId
(
carrier
.
getTraceSegmentId
());
ref
.
setSpanId
(
carrier
.
getSpanId
());
ref
.
setApplicationCode
(
carrier
.
getApplicationCode
());
ref
.
setPeerHost
(
carrier
.
getPeerHost
());
return
ref
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/BooleanTag.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context.tag
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
/**
* Do the same thing as {@link StringTag}, just with a {@link Boolean} value.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
class
BooleanTag
extends
AbstractTag
<
Boolean
>
{
private
boolean
defaultValue
;
public
BooleanTag
(
String
key
,
boolean
defaultValue
)
{
super
(
key
);
this
.
defaultValue
=
defaultValue
;
}
@Override
public
void
set
(
AbstractSpan
span
,
Boolean
tagValue
)
{
span
.
setTag
(
key
,
tagValue
);
}
public
boolean
defaultValue
()
{
return
defaultValue
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/BooleanTagItem.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context.tag
;
/**
* The tag item with String key and Boolean value.
*
* @author wusheng
*/
public
class
BooleanTagItem
{
private
String
key
;
private
boolean
value
;
public
BooleanTagItem
(
String
key
,
boolean
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
String
getKey
()
{
return
key
;
}
public
boolean
getValue
()
{
return
value
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/IntTag.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context.tag
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
/**
* Do the same thing as {@link StringTag}, just with a {@link Integer} value.
* <p>
* Created by wusheng on 2017/2/18.
*/
public
class
IntTag
extends
AbstractTag
<
Integer
>
{
public
IntTag
(
String
key
)
{
super
(
key
);
}
@Override
public
void
set
(
AbstractSpan
span
,
Integer
tagValue
)
{
span
.
setTag
(
super
.
key
,
tagValue
);
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/IntTagItem.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context.tag
;
/**
* The tag item with String key and Int value.
*
* @author wusheng
*/
public
class
IntTagItem
{
private
String
key
;
private
int
value
;
public
IntTagItem
(
String
key
,
int
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
String
getKey
()
{
return
key
;
}
public
int
getValue
()
{
return
value
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/StringTag.java
浏览文件 @
1fd449cd
...
...
@@ -15,6 +15,6 @@ public class StringTag extends AbstractTag<String> {
@Override
public
void
set
(
AbstractSpan
span
,
String
tagValue
)
{
span
.
setT
ag
(
key
,
tagValue
);
span
.
t
ag
(
key
,
tagValue
);
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/StringTagItem.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.context.tag
;
/**
* The tag item with String key and String value.
*
* @author wusheng
*/
public
final
class
StringTagItem
{
private
String
key
;
private
String
value
;
public
StringTagItem
(
String
key
,
String
value
)
{
this
.
key
=
key
;
this
.
value
=
value
;
}
public
String
getKey
()
{
return
key
;
}
public
String
getValue
()
{
return
value
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/tag/Tags.java
浏览文件 @
1fd449cd
...
...
@@ -20,7 +20,7 @@ public final class Tags {
/**
* STATUS_CODE records the http status code of the response.
*/
public
static
final
IntTag
STATUS_CODE
=
new
Int
Tag
(
"status_code"
);
public
static
final
StringTag
STATUS_CODE
=
new
String
Tag
(
"status_code"
);
/**
* SPAN_KIND hints at the relationship between spans, e.g. client/server.
...
...
@@ -71,11 +71,6 @@ public final class Tags {
*/
public
static
final
StringTag
COMPONENT
=
new
StringTag
(
"component"
);
/**
* ERROR indicates whether a Span ended in an error state.
*/
public
static
final
BooleanTag
ERROR
=
new
BooleanTag
(
"error"
,
false
);
/**
* DB_TYPE records database type, such as sql, redis, cassandra and so on.
*/
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractSpan.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.context.trace
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.util.KeyValuePair
;
import
org.skywalking.apm.agent.core.context.util.ThrowableTransformer
;
/**
* The <code>AbstractSpan</code> represents the span's skeleton,
...
...
@@ -11,39 +7,13 @@ import org.skywalking.apm.agent.core.context.util.ThrowableTransformer;
*
* @author wusheng
*/
public
abstract
class
AbstractSpan
{
protected
String
operationName
;
/**
* The start time of this Span.
*/
protected
long
startTime
;
/**
* The end time of this Span.
*/
protected
long
endTime
;
/**
* Log is a concept from OpenTracing spec.
* <p>
* {@see https://github.com/opentracing/specification/blob/master/specification.md#log-structured-data}
*/
protected
List
<
LogDataEntity
>
logs
;
protected
AbstractSpan
(
String
operationName
)
{
this
.
operationName
=
operationName
;
}
public
AbstractSpan
start
()
{
this
.
startTime
=
System
.
currentTimeMillis
();
return
this
;
}
public
interface
AbstractSpan
{
/**
* Set a key:value tag on the Span.
*
* @return this Span instance, for chaining
*/
public
abstract
AbstractSpan
tag
(
String
key
,
String
value
);
AbstractSpan
tag
(
String
key
,
String
value
);
/**
* Record an exception event of the current walltime timestamp.
...
...
@@ -51,31 +21,22 @@ public abstract class AbstractSpan {
* @param t any subclass of {@link Throwable}, which occurs in this span.
* @return the Span, for chaining
*/
public
AbstractSpan
log
(
Throwable
t
)
{
if
(
logs
==
null
)
{
logs
=
new
LinkedList
<
LogDataEntity
>();
}
logs
.
add
(
new
LogDataEntity
.
Builder
()
.
add
(
new
KeyValuePair
(
"event"
,
"error"
))
.
add
(
new
KeyValuePair
(
"error.kind"
,
t
.
getClass
().
getName
()))
.
add
(
new
KeyValuePair
(
"message"
,
t
.
getMessage
()))
.
add
(
new
KeyValuePair
(
"stack"
,
ThrowableTransformer
.
INSTANCE
.
convert2String
(
t
,
4000
)))
.
build
());
return
this
;
}
AbstractSpan
log
(
Throwable
t
);
void
errorOccurred
();
/**
* @return true if the actual span is an entry span.
*/
public
abstract
boolean
isEntry
();
boolean
isEntry
();
/**
* @return true if the actual span is a local span.
*/
public
abstract
boolean
isLocal
();
boolean
isLocal
();
/**
* @return true if the actual span is an exit span.
*/
public
abstract
boolean
isExit
();
boolean
isExit
();
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java
浏览文件 @
1fd449cd
...
...
@@ -3,6 +3,8 @@ package org.skywalking.apm.agent.core.context.trace;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.util.KeyValuePair
;
import
org.skywalking.apm.agent.core.context.util.ThrowableTransformer
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
/**
* The <code>AbstractTracingSpan</code> represents a group of {@link AbstractSpan} implementations,
...
...
@@ -10,17 +12,51 @@ import org.skywalking.apm.agent.core.context.util.KeyValuePair;
*
* @author wusheng
*/
public
abstract
class
AbstractTracingSpan
extend
s
AbstractSpan
{
public
abstract
class
AbstractTracingSpan
implement
s
AbstractSpan
{
protected
int
spanId
;
protected
int
parentSpanId
;
protected
List
<
KeyValuePair
>
tags
;
protected
String
operationName
;
protected
int
operationId
;
/**
* The start time of this Span.
*/
protected
long
startTime
;
/**
* The end time of this Span.
*/
protected
long
endTime
;
/**
* Error has occurred in the scope of span.
*/
protected
boolean
errorOccurred
=
false
;
/**
* Log is a concept from OpenTracing spec.
* <p>
* {@see https://github.com/opentracing/specification/blob/master/specification.md#log-structured-data}
*/
protected
List
<
LogDataEntity
>
logs
;
protected
AbstractTracingSpan
(
int
spanId
,
int
parentSpanId
,
String
operationName
)
{
super
(
operationName
);
this
.
operationName
=
operationName
;
this
.
operationId
=
DictionaryUtil
.
nullValue
();
this
.
spanId
=
spanId
;
this
.
parentSpanId
=
parentSpanId
;
}
protected
AbstractTracingSpan
(
int
spanId
,
int
parentSpanId
,
int
operationId
)
{
this
.
operationName
=
null
;
this
.
operationId
=
operationId
;
this
.
spanId
=
spanId
;
this
.
parentSpanId
=
parentSpanId
;
}
/**
* Set a key:value tag on the Span.
*
* @return this Span instance, for chaining
*/
@Override
public
AbstractTracingSpan
tag
(
String
key
,
String
value
)
{
if
(
tags
==
null
)
{
...
...
@@ -41,4 +77,40 @@ public abstract class AbstractTracingSpan extends AbstractSpan {
owner
.
archive
(
this
);
return
true
;
}
public
AbstractSpan
start
()
{
this
.
startTime
=
System
.
currentTimeMillis
();
return
this
;
}
/**
* Record an exception event of the current walltime timestamp.
*
* @param t any subclass of {@link Throwable}, which occurs in this span.
* @return the Span, for chaining
*/
public
AbstractSpan
log
(
Throwable
t
)
{
if
(
logs
==
null
)
{
logs
=
new
LinkedList
<
LogDataEntity
>();
}
logs
.
add
(
new
LogDataEntity
.
Builder
()
.
add
(
new
KeyValuePair
(
"event"
,
"error"
))
.
add
(
new
KeyValuePair
(
"error.kind"
,
t
.
getClass
().
getName
()))
.
add
(
new
KeyValuePair
(
"message"
,
t
.
getMessage
()))
.
add
(
new
KeyValuePair
(
"stack"
,
ThrowableTransformer
.
INSTANCE
.
convert2String
(
t
,
4000
)))
.
build
());
return
this
;
}
public
void
errorOccurred
()
{
this
.
errorOccurred
=
true
;
}
public
int
getSpanId
()
{
return
spanId
;
}
public
int
getOperationId
()
{
return
operationId
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/EntrySpan.java
浏览文件 @
1fd449cd
...
...
@@ -12,10 +12,18 @@ package org.skywalking.apm.agent.core.context.trace;
*/
public
class
EntrySpan
extends
AbstractTracingSpan
{
private
int
stackDepth
;
private
int
currentMaxDepth
;
public
EntrySpan
(
int
spanId
,
int
parentSpanId
,
String
operationName
)
{
super
(
spanId
,
parentSpanId
,
operationName
);
this
.
stackDepth
=
0
;
this
.
currentMaxDepth
=
0
;
}
public
EntrySpan
(
int
spanId
,
int
parentSpanId
,
int
operationId
)
{
super
(
spanId
,
parentSpanId
,
operationId
);
this
.
stackDepth
=
0
;
this
.
currentMaxDepth
=
0
;
}
/**
...
...
@@ -23,7 +31,7 @@ public class EntrySpan extends AbstractTracingSpan {
*/
@Override
public
EntrySpan
start
()
{
if
(
++
stackDepth
==
1
)
{
if
(
(
currentMaxDepth
=
++
stackDepth
)
==
1
)
{
super
.
start
();
}
clearWhenRestart
();
...
...
@@ -32,7 +40,7 @@ public class EntrySpan extends AbstractTracingSpan {
@Override
public
EntrySpan
tag
(
String
key
,
String
value
)
{
if
(
stackDepth
==
1
)
{
if
(
stackDepth
==
currentMaxDepth
)
{
super
.
tag
(
key
,
value
);
}
return
this
;
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/ExitSpan.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.context.trace
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
/**
* The <code>ExitSpan</code> represents a service consumer point, such as Feign, Okhttp client for a Http service.
*
...
...
@@ -12,12 +14,28 @@ package org.skywalking.apm.agent.core.context.trace;
*/
public
class
ExitSpan
extends
AbstractTracingSpan
{
private
int
stackDepth
;
private
String
peerPoint
;
private
String
peer
;
private
int
peerId
;
public
ExitSpan
(
int
spanId
,
int
parentSpanId
,
String
operationName
,
String
peer
Point
)
{
public
ExitSpan
(
int
spanId
,
int
parentSpanId
,
String
operationName
,
String
peer
)
{
super
(
spanId
,
parentSpanId
,
operationName
);
this
.
stackDepth
=
0
;
this
.
peerPoint
=
peerPoint
;
this
.
peer
=
peer
;
this
.
peerId
=
DictionaryUtil
.
nullValue
();
}
public
ExitSpan
(
int
spanId
,
int
parentSpanId
,
int
operationId
,
int
peerId
)
{
super
(
spanId
,
parentSpanId
,
operationId
);
this
.
stackDepth
=
0
;
this
.
peer
=
null
;
this
.
peerId
=
peerId
;
}
public
ExitSpan
(
int
spanId
,
int
parentSpanId
,
int
operationId
,
String
peer
)
{
super
(
spanId
,
parentSpanId
,
operationId
);
this
.
stackDepth
=
0
;
this
.
peer
=
peer
;
this
.
peerId
=
DictionaryUtil
.
nullValue
();
}
/**
...
...
@@ -43,7 +61,7 @@ public class ExitSpan extends AbstractTracingSpan {
public
boolean
finish
(
TraceSegment
owner
)
{
if
(--
stackDepth
==
0
)
{
return
super
.
finish
(
owner
);
}
else
{
}
else
{
return
false
;
}
}
...
...
@@ -56,6 +74,14 @@ public class ExitSpan extends AbstractTracingSpan {
return
this
;
}
public
int
getPeerId
()
{
return
peerId
;
}
public
String
getPeer
()
{
return
peer
;
}
@Override
public
boolean
isEntry
()
{
return
false
;
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/LocalSpan.java
浏览文件 @
1fd449cd
...
...
@@ -7,6 +7,10 @@ package org.skywalking.apm.agent.core.context.trace;
*/
public
class
LocalSpan
extends
AbstractTracingSpan
{
public
LocalSpan
(
int
spanId
,
int
parentSpanId
,
int
operationId
)
{
super
(
spanId
,
parentSpanId
,
operationId
);
}
public
LocalSpan
(
int
spanId
,
int
parentSpanId
,
String
operationName
)
{
super
(
spanId
,
parentSpanId
,
operationName
);
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/LogDataEntity.java
浏览文件 @
1fd449cd
...
...
@@ -28,14 +28,14 @@ public class LogDataEntity {
logs
=
new
LinkedList
<
KeyValuePair
>();
}
public
Builder
add
(
KeyValuePair
...
fields
){
public
Builder
add
(
KeyValuePair
...
fields
)
{
for
(
KeyValuePair
field
:
fields
)
{
logs
.
add
(
field
);
}
return
this
;
}
public
LogDataEntity
build
(){
public
LogDataEntity
build
()
{
return
new
LogDataEntity
(
logs
);
}
}
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/NoopSpan.java
浏览文件 @
1fd449cd
...
...
@@ -8,19 +8,14 @@ import org.skywalking.apm.agent.core.context.IgnoredTracerContext;
*
* @author wusheng
*/
public
class
NoopSpan
extend
s
AbstractSpan
{
public
class
NoopSpan
implement
s
AbstractSpan
{
public
NoopSpan
()
{
super
(
null
);
}
@Override
public
void
start
()
{
super
.
start
();
}
@Override
public
AbstractSpan
log
(
Throwable
t
)
{
return
super
.
log
(
t
)
;
return
this
;
}
public
void
finish
(){
...
...
@@ -29,7 +24,7 @@ public class NoopSpan extends AbstractSpan {
@Override
public
AbstractSpan
tag
(
String
key
,
String
value
)
{
return
null
;
return
this
;
}
@Override
public
boolean
isEntry
()
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegment.java
浏览文件 @
1fd449cd
...
...
@@ -8,7 +8,6 @@ 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.NewDistributedTraceId
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryManager
;
import
org.skywalking.apm.agent.core.dictionary.IDictionaryCompressible
;
import
org.skywalking.apm.agent.core.dictionary.PossibleFound
;
import
org.skywalking.apm.logging.ILog
;
import
org.skywalking.apm.logging.LogManager
;
...
...
@@ -20,9 +19,10 @@ import org.skywalking.apm.logging.LogManager;
* TraceSegment} means the segment, which exists in current {@link Thread}. And the distributed trace is formed by multi
* {@link TraceSegment}s, because the distributed trace crosses multi-processes, multi-threads.
* <p>
* Created by wusheng on 2017/2/17.
*
* @author wusheng
*/
public
class
TraceSegment
implements
IDictionaryCompressible
{
public
class
TraceSegment
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
TraceSegment
.
class
);
private
static
final
String
ID_TYPE
=
"Segment"
;
...
...
@@ -89,14 +89,20 @@ public class TraceSegment implements IDictionaryCompressible {
* and generate a new segment id.
*/
public
TraceSegment
()
{
DictionaryManager
.
findApplicationCodeSection
()
.
find
(
Config
.
Agent
.
APPLICATION_CODE
,
this
)
.
ifFound
(
new
PossibleFound
.
Setter
()
{
@Override
public
void
set
(
int
value
)
{
applicationId
=
value
;
this
.
applicationId
=
(
Integer
)
DictionaryManager
.
findApplicationCodeSection
()
.
find
(
Config
.
Agent
.
APPLICATION_CODE
)
.
doInCondition
(
new
PossibleFound
.
FoundAndObtain
()
{
@Override
public
Object
doProcess
(
int
applicationId
)
{
return
applicationId
;
}
},
new
PossibleFound
.
NotFoundAndObtain
()
{
@Override
public
Object
doProcess
()
{
throw
new
IllegalStateException
(
"Application id must not NULL."
);
}
}
}
);
);
this
.
startTime
=
System
.
currentTimeMillis
();
this
.
traceSegmentId
=
GlobalIdGenerator
.
generate
(
ID_TYPE
);
this
.
spans
=
new
LinkedList
<
AbstractTracingSpan
>();
...
...
@@ -164,6 +170,10 @@ public class TraceSegment implements IDictionaryCompressible {
return
endTime
;
}
public
int
getApplicationId
()
{
return
applicationId
;
}
public
boolean
hasRef
()
{
return
!(
refs
==
null
||
refs
.
size
()
==
0
);
}
...
...
@@ -196,15 +206,4 @@ public class TraceSegment implements IDictionaryCompressible {
", relatedGlobalTraces="
+
relatedGlobalTraces
+
'}'
;
}
/**
* If compress is incomplete, this segment will be ignored.
*/
@Override
public
void
incomplete
(
String
notFoundKey
)
{
if
(
logger
.
isDebugEnable
())
{
logger
.
debug
(
"Segment[{}] ignored, cause by compress key [{}] not found."
,
this
.
traceSegmentId
,
notFoundKey
);
}
this
.
ignore
=
true
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.context.trace
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.ids.DistributedTraceId
;
/**
* {@link TraceSegmentRef} is like a pointer, which ref to another {@link TraceSegment},
* use {@link #spanId} point to the exact span of the ref {@link TraceSegment}.
...
...
@@ -7,9 +11,6 @@ package org.skywalking.apm.agent.core.context.trace;
* Created by wusheng on 2017/2/17.
*/
public
class
TraceSegmentRef
{
/**
* {@link TraceSegment#traceSegmentId}
*/
private
String
traceSegmentId
;
private
int
spanId
=
-
1
;
...
...
@@ -19,51 +20,16 @@ public class TraceSegmentRef {
private
String
peerHost
;
/**
*
Create a {@link TraceSegmentRef} instance, without any data.
*
{@link DistributedTraceId}
*/
public
TraceSegmentRef
()
{
}
public
String
getTraceSegmentId
()
{
return
traceSegmentId
;
}
public
void
setTraceSegmentId
(
String
traceSegmentId
)
{
this
.
traceSegmentId
=
traceSegmentId
;
}
public
int
getSpanId
()
{
return
spanId
;
}
public
void
setSpanId
(
int
spanId
)
{
this
.
spanId
=
spanId
;
}
public
String
getApplicationCode
()
{
return
applicationCode
;
}
private
List
<
DistributedTraceId
>
distributedTraceIds
;
public
void
setApplicationCode
(
String
applicationCode
)
{
this
.
applicationCode
=
applicationCode
;
}
public
String
getPeerHost
()
{
return
peerHost
;
}
public
void
setPeerHost
(
String
peerHost
)
{
this
.
peerHost
=
peerHost
;
}
@Override
public
String
toString
()
{
return
"TraceSegmentRef{"
+
"traceSegmentId='"
+
traceSegmentId
+
'\''
+
", spanId="
+
spanId
+
", applicationCode='"
+
applicationCode
+
'\''
+
", peerHost='"
+
peerHost
+
'\''
+
'}'
;
public
TraceSegmentRef
(
ContextCarrier
carrier
)
{
this
.
traceSegmentId
=
carrier
.
getTraceSegmentId
();
this
.
spanId
=
carrier
.
getSpanId
();
this
.
applicationCode
=
carrier
.
getApplicationCode
();
this
.
peerHost
=
carrier
.
getPeerHost
();
this
.
distributedTraceIds
=
carrier
.
getDistributedTraceIds
();
}
@Override
...
...
@@ -73,13 +39,17 @@ public class TraceSegmentRef {
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
TraceSegmentRef
that
=
(
TraceSegmentRef
)
o
;
TraceSegmentRef
ref
=
(
TraceSegmentRef
)
o
;
return
traceSegmentId
!=
null
?
traceSegmentId
.
equals
(
that
.
traceSegmentId
)
:
that
.
traceSegmentId
==
null
;
if
(
spanId
!=
ref
.
spanId
)
return
false
;
return
traceSegmentId
.
equals
(
ref
.
traceSegmentId
);
}
@Override
public
int
hashCode
()
{
return
traceSegmentId
!=
null
?
traceSegmentId
.
hashCode
()
:
0
;
int
result
=
traceSegmentId
.
hashCode
();
result
=
31
*
result
+
spanId
;
return
result
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/ApplicationDictionary.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
import
io.netty.util.internal.ConcurrentSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* Map of application id to application code, which is from the collector side.
*
...
...
@@ -7,8 +12,16 @@ package org.skywalking.apm.agent.core.dictionary;
*/
public
enum
ApplicationDictionary
{
INSTANCE
;
private
Map
<
String
,
Integer
>
applicationDictionary
=
new
ConcurrentHashMap
<
String
,
Integer
>();
private
Set
<
String
>
unRegisterApplication
=
new
ConcurrentSet
<
String
>();
public
PossibleFound
find
(
String
applicationCode
,
IDictionaryCompressible
compressedOwner
)
{
public
PossibleFound
find
(
String
applicationCode
)
{
Integer
applicationId
=
applicationDictionary
.
get
(
applicationCode
);
if
(
applicationId
!=
null
)
{
return
new
Found
(
applicationId
);
}
else
{
unRegisterApplication
.
add
(
applicationCode
);
return
new
NotFound
();
}
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryManager.java
浏览文件 @
1fd449cd
...
...
@@ -5,9 +5,16 @@ package org.skywalking.apm.agent.core.dictionary;
*/
public
class
DictionaryManager
{
/**
* @return {@link ApplicationDictionary} to find application
Id
* @return {@link ApplicationDictionary} to find application
id for application code and network address.
*/
public
static
ApplicationDictionary
findApplicationCodeSection
(){
public
static
ApplicationDictionary
findApplicationCodeSection
()
{
return
ApplicationDictionary
.
INSTANCE
;
}
/**
* @return {@link OperationNameDictionary} to find service id.
*/
public
static
OperationNameDictionary
findOperationNameCodeSection
()
{
return
OperationNameDictionary
.
INSTANCE
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryUtil.java
0 → 100644
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
/**
* @author wusheng
*/
public
class
DictionaryUtil
{
public
static
int
nullValue
()
{
return
-
1
;
}
public
static
boolean
isNull
(
int
value
)
{
return
value
==
nullValue
();
}
public
static
boolean
isNull
(
String
text
)
{
return
text
==
null
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/DictionaryValueHolder.java
0 → 100644
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
/**
* @author wusheng
*/
public
class
DictionaryValueHolder
{
private
int
value
=
DictionaryUtil
.
nullValue
();
public
int
getValue
()
{
return
value
;
}
public
void
setValue
(
int
value
)
{
this
.
value
=
value
;
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/Found.java
0 → 100644
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
/**
* @author wusheng
*/
public
class
Found
extends
PossibleFound
{
public
Found
(
int
value
)
{
super
(
value
);
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/IDictionaryCompressible.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.dictionary
;
/**
* The <code>IDictionaryCompressible</code> implementation are objects which supported compressing by dictionary.
*
*
* @author wusheng
*/
public
interface
IDictionaryCompressible
{
/**
* The Dictionary notifies, when compress key isn't found,
* means compress fail this time.
*/
void
incomplete
(
String
notFoundKey
);
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/NotFound.java
0 → 100644
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
/**
* @author wusheng
*/
public
class
NotFound
extends
PossibleFound
{
public
NotFound
()
{
super
();
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/OperationNameDictionary.java
0 → 100644
浏览文件 @
1fd449cd
package
org.skywalking.apm.agent.core.dictionary
;
import
io.netty.util.internal.ConcurrentSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author wusheng
*/
public
enum
OperationNameDictionary
{
INSTANCE
;
private
Map
<
OperationNameKey
,
Integer
>
operationNameDictionary
=
new
ConcurrentHashMap
<
OperationNameKey
,
Integer
>();
private
Set
<
OperationNameKey
>
unRegisterOperationName
=
new
ConcurrentSet
<
OperationNameKey
>();
public
PossibleFound
find
(
int
applicationId
,
String
operationName
)
{
OperationNameKey
key
=
new
OperationNameKey
(
applicationId
,
operationName
);
Integer
operationId
=
operationNameDictionary
.
get
(
key
);
if
(
operationId
!=
null
)
{
return
new
Found
(
applicationId
);
}
else
{
unRegisterOperationName
.
add
(
key
);
return
new
NotFound
();
}
}
private
class
OperationNameKey
{
private
int
applicationId
;
private
String
operationName
;
public
OperationNameKey
(
int
applicationId
,
String
operationName
)
{
this
.
applicationId
=
applicationId
;
this
.
operationName
=
operationName
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
OperationNameKey
key
=
(
OperationNameKey
)
o
;
if
(
applicationId
!=
key
.
applicationId
)
return
false
;
return
operationName
.
equals
(
key
.
operationName
);
}
@Override
public
int
hashCode
()
{
int
result
=
applicationId
;
result
=
31
*
result
+
operationName
.
hashCode
();
return
result
;
}
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/dictionary/PossibleFound.java
浏览文件 @
1fd449cd
...
...
@@ -5,7 +5,7 @@ package org.skywalking.apm.agent.core.dictionary;
*
* @author wusheng
*/
public
class
PossibleFound
{
public
abstract
class
PossibleFound
{
private
boolean
found
;
private
int
value
;
...
...
@@ -18,13 +18,35 @@ public class PossibleFound {
this
.
found
=
false
;
}
public
void
ifFound
(
Setter
setter
)
{
public
void
doInCondition
(
Found
condition1
,
NotFound
condition2
)
{
if
(
found
)
{
setter
.
set
(
value
);
condition1
.
doProcess
(
value
);
}
else
{
condition2
.
doProcess
();
}
}
public
interface
Setter
{
void
set
(
int
value
);
public
Object
doInCondition
(
FoundAndObtain
condition1
,
NotFoundAndObtain
condition2
)
{
if
(
found
)
{
return
condition1
.
doProcess
(
value
);
}
else
{
return
condition2
.
doProcess
();
}
}
public
interface
Found
{
void
doProcess
(
int
value
);
}
public
interface
NotFound
{
void
doProcess
();
}
public
interface
FoundAndObtain
{
Object
doProcess
(
int
value
);
}
public
interface
NotFoundAndObtain
{
Object
doProcess
();
}
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/queue/TraceSegmentProcessQueue.java
浏览文件 @
1fd449cd
...
...
@@ -8,7 +8,6 @@ import java.util.LinkedList;
import
java.util.List
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.boot.StatusBootService
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.context.TracingContextListener
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.logging.ILog
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/trace/LeafSpanTestCase.java
浏览文件 @
1fd449cd
...
...
@@ -2,11 +2,7 @@ package org.skywalking.apm.agent.core.context.trace;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.agent.core.tags.BooleanTagReader
;
import
org.skywalking.apm.agent.core.tags.IntTagReader
;
import
org.skywalking.apm.agent.core.tags.StringTagReader
;
import
org.skywalking.apm.agent.core.context.tag.BooleanTag
;
import
org.skywalking.apm.agent.core.context.tag.IntTag
;
import
org.skywalking.apm.agent.core.context.tag.StringTag
;
/**
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/trace/SpanTestCase.java
浏览文件 @
1fd449cd
...
...
@@ -4,7 +4,6 @@ import java.lang.reflect.Field;
import
java.util.List
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.skywalking.apm.agent.core.tags.BooleanTagReader
;
import
org.skywalking.apm.agent.core.tags.StringTagReader
;
import
org.skywalking.apm.agent.core.context.tag.Tags
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/sampling/SamplingTracerContextTestCase.java
浏览文件 @
1fd449cd
...
...
@@ -7,7 +7,6 @@ import org.junit.Test;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.ContextManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.context.TracingContextListener
;
import
org.skywalking.apm.agent.core.context.tag.Tags
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/BooleanTagReader.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.tags
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.BooleanTag
;
import
org.skywalking.apm.agent.core.context.tag.BooleanTagItem
;
/**
* @author wusheng
*/
public
class
BooleanTagReader
{
public
static
Boolean
get
(
Span
span
,
BooleanTag
tag
)
{
List
<
BooleanTagItem
>
tagsWithBoolList
=
null
;
try
{
Field
tagsWithBool
=
Span
.
class
.
getDeclaredField
(
"tagsWithBool"
);
tagsWithBool
.
setAccessible
(
true
);
tagsWithBoolList
=
(
List
<
BooleanTagItem
>)
tagsWithBool
.
get
(
span
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchFieldException
e
)
{
e
.
printStackTrace
();
}
for
(
BooleanTagItem
item
:
tagsWithBoolList
)
{
if
(
tag
.
key
().
equals
(
item
.
getKey
()))
{
return
item
.
getValue
();
}
}
return
tag
.
defaultValue
();
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/IntTagReader.java
已删除
100644 → 0
浏览文件 @
48b2164f
package
org.skywalking.apm.agent.core.tags
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.IntTag
;
import
org.skywalking.apm.agent.core.context.tag.IntTagItem
;
/**
* @author wusheng
*/
public
class
IntTagReader
{
public
static
Integer
get
(
Span
span
,
IntTag
tag
)
{
List
<
IntTagItem
>
tagsWithIntList
=
null
;
try
{
Field
tagsWithInt
=
Span
.
class
.
getDeclaredField
(
"tagsWithInt"
);
tagsWithInt
.
setAccessible
(
true
);
tagsWithIntList
=
(
List
<
IntTagItem
>)
tagsWithInt
.
get
(
span
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchFieldException
e
)
{
e
.
printStackTrace
();
}
for
(
IntTagItem
item
:
tagsWithIntList
)
{
if
(
tag
.
key
().
equals
(
item
.
getKey
()))
{
return
item
.
getValue
();
}
}
return
null
;
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/tags/StringTagReader.java
浏览文件 @
1fd449cd
...
...
@@ -3,7 +3,6 @@ package org.skywalking.apm.agent.core.tags;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.StringTag
;
import
org.skywalking.apm.agent.core.context.tag.StringTagItem
;
/**
* @author wusheng
...
...
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -18,7 +18,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -14,7 +14,6 @@ import org.mockito.Mock;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.powermock.api.mockito.PowerMockito;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
浏览文件 @
1fd449cd
...
...
@@ -12,7 +12,6 @@ import org.mockito.Matchers;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
浏览文件 @
1fd449cd
...
...
@@ -8,7 +8,6 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
浏览文件 @
1fd449cd
...
...
@@ -10,7 +10,6 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
浏览文件 @
1fd449cd
...
...
@@ -13,7 +13,6 @@ import org.mockito.Matchers;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jedis/v2/JedisMethodInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -16,7 +16,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import
org.powermock.api.mockito.PowerMockito
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBWriteMethodInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -17,7 +17,6 @@ import org.mockito.runners.MockitoJUnitRunner;
import
org.powermock.api.mockito.PowerMockito
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -12,7 +12,6 @@ import org.junit.runner.RunWith;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -13,7 +13,6 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.mockito.Mock;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
...
...
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java
浏览文件 @
1fd449cd
...
...
@@ -11,7 +11,6 @@ import org.mockito.Mock;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.boot.ServiceManager
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/context/MockTracingContextListener.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.sniffer.mock.context
;
import
org.junit.Assert
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.agent.core.context.TracingContextListener
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
浏览文件 @
1fd449cd
package
org.skywalking.apm.sniffer.mock.trace
;
import
org.skywalking.apm.agent.core.context.TracerContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracingContextListener
;
import
org.skywalking.apm.sniffer.mock.trace.builders.trace.*
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/BooleanTagReader.java
浏览文件 @
1fd449cd
...
...
@@ -2,8 +2,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.BooleanTag
;
import
org.skywalking.apm.agent.core.context.tag.BooleanTagItem
;
/**
* @author wusheng
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/IntTagReader.java
浏览文件 @
1fd449cd
...
...
@@ -2,8 +2,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.IntTag
;
import
org.skywalking.apm.agent.core.context.tag.IntTagItem
;
/**
* @author wusheng
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/StringTagReader.java
浏览文件 @
1fd449cd
...
...
@@ -3,7 +3,6 @@ package org.skywalking.apm.sniffer.mock.trace.tags;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.tag.StringTag
;
import
org.skywalking.apm.agent.core.context.tag.StringTagItem
;
/**
* @author wusheng
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录