Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wufeng无峰
incubator-skywalking
提交
19f2a561
I
incubator-skywalking
项目概览
wufeng无峰
/
incubator-skywalking
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
incubator-skywalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
19f2a561
编写于
6月 04, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prepare for improving sampling performance.
上级
5b853ec3
变更
27
隐藏空白更改
内联
并排
Showing
27 changed file
with
115 addition
and
88 deletion
+115
-88
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracingContext.java
...alking/apm/agent/core/context/AbstractTracingContext.java
+26
-0
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
...org/skywalking/apm/agent/core/context/ContextCarrier.java
+2
-2
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
-11
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracerContextListener.java
...walking/apm/agent/core/context/TracerContextListener.java
+3
-3
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracingContext.java
...org/skywalking/apm/agent/core/context/TracingContext.java
+7
-6
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/queue/TraceSegmentProcessQueue.java
...alking/apm/agent/core/queue/TraceSegmentProcessQueue.java
+2
-2
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTestCase.java
...alking/apm/agent/core/context/ContextManagerTestCase.java
+2
-2
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/TracingContextTestCase.java
...alking/apm/agent/core/context/TracingContextTestCase.java
+9
-9
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
...org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
+3
-3
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
+2
-2
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
+3
-3
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
...g/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
+3
-3
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
+3
-3
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
+3
-3
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
...g/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
+3
-3
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
+3
-3
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
+3
-3
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
+3
-3
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
...alking/apm/plugin/motan/MotanConsumerInterceptorTest.java
+3
-3
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
...alking/apm/plugin/motan/MotanProviderInterceptorTest.java
+3
-3
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
+2
-2
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
+3
-3
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
+3
-3
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
+3
-3
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/context/MockTracerContextListener.java
...g/apm/sniffer/mock/context/MockTracerContextListener.java
+3
-3
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
...ng/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
+3
-3
apm-sniffer/apm-sniffer-mock/src/test/java/org/skywalking/apm/sniffer/mock/MockTracingContextListenerTestCase.java
.../apm/sniffer/mock/MockTracingContextListenerTestCase.java
+1
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/AbstractTracingContext.java
0 → 100644
浏览文件 @
19f2a561
package
org.skywalking.apm.agent.core.context
;
import
org.skywalking.apm.trace.Span
;
/**
* The <code>AbstractTracingContext</code> provides the major methods of all context implementations.
*
* @author wusheng
*/
public
interface
AbstractTracingContext
{
Span
createSpan
(
String
operationName
,
boolean
isLeaf
);
Span
createSpan
(
String
operationName
,
long
startTime
,
boolean
isLeaf
);
Span
activeSpan
();
void
stopSpan
(
Span
span
,
Long
endTime
);
void
stopSpan
(
Span
span
);
void
inject
(
ContextCarrier
carrier
);
AbstractTracingContext
extract
(
ContextCarrier
carrier
);
String
getGlobalTraceId
();
}
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextCarrier.java
浏览文件 @
19f2a561
...
...
@@ -12,8 +12,8 @@ import java.util.LinkedList;
import
java.util.List
;
/**
* {@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.
*/
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/ContextManager.java
浏览文件 @
19f2a561
...
...
@@ -5,38 +5,38 @@ import org.skywalking.apm.trace.Span;
import
org.skywalking.apm.trace.TraceSegment
;
/**
* {@link Trac
er
Context} controls the whole context of {@link TraceSegment}. Any {@link TraceSegment} relates to
* {@link Trac
ing
Context} 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 Trac
er
Context}'s major methods: {@link
* Trac
erContext#createSpan(String)}, {@link TracerContext#activeSpan()}, {@link Tracer
Context#stopSpan(Span)}
* Also, {@link ContextManager} delegates to all {@link Trac
ing
Context}'s major methods: {@link
* Trac
ingContext#createSpan(String, boolean)}, {@link TracingContext#activeSpan()}, {@link Tracing
Context#stopSpan(Span)}
* <p>
* Created by wusheng on 2017/2/17.
*/
public
class
ContextManager
implements
TracerContextListener
,
BootService
{
private
static
ThreadLocal
<
TracerContext
>
CONTEXT
=
new
ThreadLocal
<
Tracer
Context
>();
private
static
ThreadLocal
<
AbstractTracingContext
>
CONTEXT
=
new
ThreadLocal
<
AbstractTracing
Context
>();
private
static
Tracer
Context
get
()
{
Tracer
Context
segment
=
CONTEXT
.
get
();
private
static
AbstractTracing
Context
get
()
{
AbstractTracing
Context
segment
=
CONTEXT
.
get
();
if
(
segment
==
null
)
{
segment
=
new
Trac
er
Context
();
segment
=
new
Trac
ing
Context
();
CONTEXT
.
set
(
segment
);
}
return
segment
;
}
/**
* @see {@link Trac
er
Context#inject(ContextCarrier)}
* @see {@link Trac
ing
Context#inject(ContextCarrier)}
*/
public
static
void
inject
(
ContextCarrier
carrier
)
{
get
().
inject
(
carrier
);
}
/**
* @see {@link Trac
er
Context#extract(ContextCarrier)}
* @see {@link Trac
ing
Context#extract(ContextCarrier)}
*/
public
static
void
extract
(
ContextCarrier
carrier
)
{
get
().
extract
(
carrier
);
...
...
@@ -46,7 +46,7 @@ public class ContextManager implements TracerContextListener, BootService {
* @return the first global trace id if exist. Otherwise, "N/A".
*/
public
static
String
getGlobalTraceId
()
{
Tracer
Context
segment
=
CONTEXT
.
get
();
AbstractTracing
Context
segment
=
CONTEXT
.
get
();
if
(
segment
==
null
)
{
return
"N/A"
;
}
else
{
...
...
@@ -88,7 +88,7 @@ public class ContextManager implements TracerContextListener, BootService {
@Override
public
void
bootUp
()
{
Trac
er
Context
.
ListenerManager
.
add
(
this
);
Trac
ing
Context
.
ListenerManager
.
add
(
this
);
}
@Override
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/TracerContextListener.java
浏览文件 @
19f2a561
...
...
@@ -3,8 +3,8 @@ package org.skywalking.apm.agent.core.context;
import
org.skywalking.apm.trace.TraceSegment
;
/**
* {@link TracerContextListener} is a status change listener of {@link Trac
er
Context}.
* Add a {@link TracerContextListener} implementation through {@link Trac
er
Context}
* {@link TracerContextListener} is a status change listener of {@link Trac
ing
Context}.
* Add a {@link TracerContextListener} implementation through {@link Trac
ing
Context}
* <p>
* All this class's methods will be called concurrently. Make sure all implementations are thread-safe.
* <p>
...
...
@@ -12,7 +12,7 @@ import org.skywalking.apm.trace.TraceSegment;
*/
public
interface
TracerContextListener
{
/**
* This method will be called, after the {@link Trac
er
Context#finish()}
* This method will be called, after the {@link Trac
ing
Context#finish()}
*
* @param traceSegment finished {@link TraceSegment}
*/
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/Trac
er
Context.java
→
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/Trac
ing
Context.java
浏览文件 @
19f2a561
...
...
@@ -12,12 +12,12 @@ import java.util.LinkedList;
import
java.util.List
;
/**
* {@link Trac
er
Context} maintains the context.
* {@link Trac
ing
Context} maintains the context.
* You manipulate (create/finish/get) spans and (inject/extract) context.
* <p>
* Created by wusheng on 2017/2/17.
*/
public
final
class
Trac
er
Context
{
public
final
class
Trac
ingContext
implements
AbstractTracing
Context
{
private
TraceSegment
segment
;
/**
...
...
@@ -34,7 +34,7 @@ public final class TracerContext {
/**
* Create a {@link TraceSegment} and init {@link #spanIdGenerator} as 0;
*/
Trac
er
Context
()
{
Trac
ing
Context
()
{
this
.
segment
=
new
TraceSegment
(
Config
.
Agent
.
APPLICATION_CODE
);
ServiceManager
.
INSTANCE
.
findService
(
SamplingService
.
class
).
trySampling
(
this
.
segment
);
this
.
spanIdGenerator
=
0
;
...
...
@@ -106,7 +106,7 @@ public final class TracerContext {
/**
* @return the current trace id.
*/
String
getGlobalTraceId
()
{
public
String
getGlobalTraceId
()
{
return
segment
.
getRelatedGlobalTraces
().
get
(
0
).
get
();
}
...
...
@@ -138,7 +138,7 @@ public final class TracerContext {
}
/**
* Give a snapshot of this {@link Trac
er
Context},
* Give a snapshot of this {@link Trac
ing
Context},
* and save current state to the given {@link ContextCarrier}.
*
* @param carrier holds the snapshot
...
...
@@ -165,12 +165,13 @@ public final class TracerContext {
* @param carrier holds the snapshot, if get this {@link ContextCarrier} from remote, make sure {@link
* ContextCarrier#deserialize(String)} called.
*/
public
void
extract
(
ContextCarrier
carrier
)
{
public
AbstractTracingContext
extract
(
ContextCarrier
carrier
)
{
if
(
carrier
.
isValid
())
{
this
.
segment
.
ref
(
getRef
(
carrier
));
ServiceManager
.
INSTANCE
.
findService
(
SamplingService
.
class
).
setSampleWhenExtract
(
this
.
segment
,
carrier
);
this
.
segment
.
relatedGlobalTraces
(
carrier
.
getDistributedTraceIds
());
}
return
this
;
}
private
TraceSegmentRef
getRef
(
ContextCarrier
carrier
)
{
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/queue/TraceSegmentProcessQueue.java
浏览文件 @
19f2a561
...
...
@@ -6,7 +6,7 @@ import com.lmax.disruptor.dsl.Disruptor;
import
com.lmax.disruptor.util.DaemonThreadFactory
;
import
org.skywalking.apm.agent.core.conf.Config
;
import
org.skywalking.apm.agent.core.boot.StatusBootService
;
import
org.skywalking.apm.agent.core.context.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.agent.core.context.TracerContextListener
;
import
org.skywalking.apm.logging.ILog
;
import
org.skywalking.apm.logging.LogManager
;
...
...
@@ -40,7 +40,7 @@ public class TraceSegmentProcessQueue extends StatusBootService implements Trace
@Override
protected
void
bootUpWithStatus
()
{
Trac
er
Context
.
ListenerManager
.
add
(
this
);
Trac
ing
Context
.
ListenerManager
.
add
(
this
);
disruptor
.
start
();
}
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTestCase.java
浏览文件 @
19f2a561
...
...
@@ -25,7 +25,7 @@ public class ContextManagerTestCase {
Assert
.
assertEquals
(
span
,
ContextManager
.
activeSpan
());
Trac
er
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
ContextManager
.
stopSpan
();
TraceSegment
segment
=
TestTracerContextListener
.
INSTANCE
.
finishedSegmentCarrier
[
0
];
...
...
@@ -35,6 +35,6 @@ public class ContextManagerTestCase {
@After
public
void
reset
()
{
Trac
er
Context
.
ListenerManager
.
remove
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
remove
(
TestTracerContextListener
.
INSTANCE
);
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/Trac
er
ContextTestCase.java
→
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/Trac
ing
ContextTestCase.java
浏览文件 @
19f2a561
...
...
@@ -15,15 +15,15 @@ import java.util.List;
/**
* Created by wusheng on 2017/2/19.
*/
public
class
Trac
er
ContextTestCase
{
public
class
Trac
ing
ContextTestCase
{
@Test
public
void
testSpanLifeCycle
()
{
Trac
erContext
context
=
new
Tracer
Context
();
Trac
ingContext
context
=
new
Tracing
Context
();
Span
span
=
context
.
createSpan
(
"/serviceA"
,
false
);
Assert
.
assertEquals
(
span
,
context
.
activeSpan
());
Trac
er
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
final
TraceSegment
[]
finishedSegmentCarrier
=
TestTracerContextListener
.
INSTANCE
.
finishedSegmentCarrier
;
context
.
stopSpan
(
span
);
...
...
@@ -34,13 +34,13 @@ public class TracerContextTestCase {
@Test
public
void
testChildOfSpan
()
{
Trac
erContext
context
=
new
Tracer
Context
();
Trac
ingContext
context
=
new
Tracing
Context
();
Span
serviceSpan
=
context
.
createSpan
(
"/serviceA"
,
false
);
Span
dbSpan
=
context
.
createSpan
(
"db/preparedStatement/execute"
,
false
);
Assert
.
assertEquals
(
dbSpan
,
context
.
activeSpan
());
Trac
er
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
final
TraceSegment
[]
finishedSegmentCarrier
=
TestTracerContextListener
.
INSTANCE
.
finishedSegmentCarrier
;
try
{
...
...
@@ -59,7 +59,7 @@ public class TracerContextTestCase {
@Test
public
void
testInject
()
{
Trac
erContext
context
=
new
Tracer
Context
();
Trac
ingContext
context
=
new
Tracing
Context
();
Span
serviceSpan
=
context
.
createSpan
(
"/serviceA"
,
false
);
Span
dbSpan
=
context
.
createSpan
(
"db/preparedStatement/execute"
,
false
);
Tags
.
PEER_HOST
.
set
(
dbSpan
,
"127.0.0.1"
);
...
...
@@ -85,11 +85,11 @@ public class TracerContextTestCase {
Assert
.
assertTrue
(
carrier
.
isValid
());
Trac
erContext
context
=
new
Tracer
Context
();
Trac
ingContext
context
=
new
Tracing
Context
();
context
.
extract
(
carrier
);
Span
span
=
context
.
createSpan
(
"/serviceC"
,
false
);
Trac
er
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
add
(
TestTracerContextListener
.
INSTANCE
);
final
TraceSegment
[]
finishedSegmentCarrier
=
TestTracerContextListener
.
INSTANCE
.
finishedSegmentCarrier
;
context
.
stopSpan
(
span
);
...
...
@@ -100,6 +100,6 @@ public class TracerContextTestCase {
@After
public
void
reset
()
{
Trac
er
Context
.
ListenerManager
.
remove
(
TestTracerContextListener
.
INSTANCE
);
Trac
ing
Context
.
ListenerManager
.
remove
(
TestTracerContextListener
.
INSTANCE
);
}
}
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -18,7 +18,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -67,7 +67,7 @@ public class DubboInterceptorTest {
dubboInterceptor
=
new
DubboInterceptor
();
testParam
=
new
RequestParamForTestBelow283
();
mockTracerContextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
mockStatic
(
RpcContext
.
class
);
mockStatic
(
BugFixActive
.
class
);
...
...
@@ -227,7 +227,7 @@ public class DubboInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -14,7 +14,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -60,7 +60,7 @@ public class DefaultHttpClientInterceptorTest {
ServiceManager
.
INSTANCE
.
boot
();
defaultHttpClientInterceptor
=
new
DefaultHttpClientInterceptor
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
}
@Test
...
...
apm-sniffer/apm-sdk-plugin/httpClient-4.x-plugin/src/test/java/org/skywalking/apm/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -10,7 +10,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -77,7 +77,7 @@ public class HttpClientExecuteInterceptorTest {
});
when
(
httpHost
.
getPort
()).
thenReturn
(
8080
);
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
}
@Test
...
...
@@ -153,7 +153,7 @@ public class HttpClientExecuteInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
浏览文件 @
19f2a561
...
...
@@ -10,7 +10,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.trace.Span
;
...
...
@@ -74,7 +74,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
swConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306/test"
,
new
Properties
(),
jdbcConnection
);
multiHostConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test"
,
new
Properties
(),
jdbcConnection
);
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
when
(
jdbcConnection
.
prepareCall
(
anyString
())).
thenReturn
(
mysqlCallableStatement
);
when
(
jdbcConnection
.
prepareCall
(
anyString
(),
anyInt
(),
anyInt
(),
anyInt
())).
thenReturn
(
mysqlCallableStatement
);
...
...
@@ -724,7 +724,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
浏览文件 @
19f2a561
...
...
@@ -8,7 +8,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -48,7 +48,7 @@ public class SWConnectionTest extends AbstractStatementTest {
swConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306/test"
,
new
Properties
(),
jdbcConnection
);
multiHostConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test"
,
new
Properties
(),
jdbcConnection
);
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
when
(
jdbcConnection
.
prepareStatement
(
anyString
())).
thenReturn
(
mysqlPreparedStatement
);
}
...
...
@@ -350,7 +350,7 @@ public class SWConnectionTest extends AbstractStatementTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
浏览文件 @
19f2a561
...
...
@@ -9,7 +9,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.trace.Span
;
...
...
@@ -46,7 +46,7 @@ public class SWStatementTest extends AbstractStatementTest {
swConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306/test"
,
new
Properties
(),
jdbcConnection
);
multiHostConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test"
,
new
Properties
(),
jdbcConnection
);
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
when
(
jdbcConnection
.
createStatement
()).
thenReturn
(
mysqlStatement
);
when
(
jdbcConnection
.
createStatement
(
anyInt
(),
anyInt
())).
thenReturn
(
mysqlStatement
);
...
...
@@ -299,6 +299,6 @@ public class SWStatementTest extends AbstractStatementTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
浏览文件 @
19f2a561
...
...
@@ -10,7 +10,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.trace.Span
;
...
...
@@ -75,7 +75,7 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
swConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306/test"
,
new
Properties
(),
jdbcConnection
);
multiHostConnection
=
new
SWConnection
(
"jdbc:mysql://127.0.0.1:3306,127.0.0.1:3309/test"
,
new
Properties
(),
jdbcConnection
);
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
when
(
jdbcConnection
.
prepareStatement
(
anyString
())).
thenReturn
(
mysqlPreparedStatement
);
when
(
jdbcConnection
.
prepareStatement
(
anyString
(),
anyInt
(),
anyInt
(),
anyInt
())).
thenReturn
(
mysqlPreparedStatement
);
...
...
@@ -558,6 +558,6 @@ public class SwPreparedStatementTest extends AbstractStatementTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/skywalking/apm/plugin/jedis/v2/JedisMethodInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -9,7 +9,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -43,7 +43,7 @@ public class JedisMethodInterceptorTest {
interceptor
=
new
JedisMethodInterceptor
();
mockTracerContextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
when
(
classInstanceContext
.
get
(
KEY_OF_REDIS_HOST
,
String
.
class
)).
thenReturn
(
"127.0.0.1"
);
when
(
classInstanceContext
.
get
(
KEY_OF_REDIS_PORT
)).
thenReturn
(
6379
);
...
...
@@ -140,7 +140,7 @@ public class JedisMethodInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -16,7 +16,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -49,7 +49,7 @@ public class MongoDBMethodInterceptorTest {
interceptor
=
new
MongoDBMethodInterceptor
();
mockTracerContextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Config
.
Plugin
.
MongoDB
.
TRACE_PARAM
=
true
;
...
...
@@ -121,7 +121,7 @@ public class MongoDBMethodInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBWriteMethodInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -17,7 +17,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -52,7 +52,7 @@ public class MongoDBWriteMethodInterceptorTest {
interceptor
=
new
MongoDBMethodInterceptor
();
mockTracerContextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Config
.
Plugin
.
MongoDB
.
TRACE_PARAM
=
true
;
...
...
@@ -132,7 +132,7 @@ public class MongoDBWriteMethodInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
mockTracerContextListener
);
}
}
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -12,7 +12,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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.MockTracerContextListener
;
...
...
@@ -52,7 +52,7 @@ public class MotanConsumerInterceptorTest {
invokeInterceptor
=
new
MotanConsumerInterceptor
();
url
=
URL
.
valueOf
(
"motan://127.0.0.1:34000/org.skywalking.apm.test.TestService"
);
Trac
er
Context
.
ListenerManager
.
add
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
contextListener
);
when
(
instanceContext
.
get
(
"REQUEST_URL"
)).
thenReturn
(
url
);
when
(
interceptorContext
.
allArguments
()).
thenReturn
(
new
Object
[]
{
request
});
...
...
@@ -134,6 +134,6 @@ public class MotanConsumerInterceptorTest {
@After
public
void
tearDown
()
{
Trac
er
Context
.
ListenerManager
.
remove
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
contextListener
);
}
}
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -12,7 +12,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -57,7 +57,7 @@ public class MotanProviderInterceptorTest {
contextListener
=
new
MockTracerContextListener
();
url
=
URL
.
valueOf
(
"motan://127.0.0.1:34000/org.skywalking.apm.test.TestService"
);
Trac
er
Context
.
ListenerManager
.
add
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
contextListener
);
when
(
instanceContext
.
get
(
"REQUEST_URL"
)).
thenReturn
(
url
);
when
(
interceptorContext
.
allArguments
()).
thenReturn
(
new
Object
[]
{
request
});
...
...
@@ -162,6 +162,6 @@ public class MotanProviderInterceptorTest {
@After
public
void
tearDown
()
{
Trac
er
Context
.
ListenerManager
.
remove
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
contextListener
);
}
}
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -11,7 +11,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -60,7 +60,7 @@ public class RealCallInterceptorTest {
ServiceManager
.
INSTANCE
.
boot
();
realCallInterceptor
=
new
RealCallInterceptor
();
Trac
er
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
mockTracerContextListener
);
}
@Test
...
...
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -10,7 +10,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -57,7 +57,7 @@ public class ResinV3InterceptorTest {
interceptor
=
new
ResinV3Interceptor
();
contextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
contextListener
);
when
(
request
.
getPageURI
()).
thenReturn
(
"/test/testRequestURL"
);
when
(
request
.
getScheme
()).
thenReturn
(
"http"
);
...
...
@@ -145,6 +145,6 @@ public class ResinV3InterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
Trac
ing
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
}
}
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -10,7 +10,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -55,7 +55,7 @@ public class ResinV4InterceptorTest {
interceptor
=
new
ResinV4Interceptor
();
contextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
contextListener
);
when
(
request
.
getPageURI
()).
thenReturn
(
"/test/testRequestURL"
);
when
(
request
.
getScheme
()).
thenReturn
(
"http"
);
...
...
@@ -144,6 +144,6 @@ public class ResinV4InterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
Trac
ing
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
}
}
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java
浏览文件 @
19f2a561
...
...
@@ -8,7 +8,7 @@ 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.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
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
;
...
...
@@ -54,7 +54,7 @@ public class TomcatInterceptorTest {
tomcatInterceptor
=
new
TomcatInterceptor
();
contextListener
=
new
MockTracerContextListener
();
Trac
er
Context
.
ListenerManager
.
add
(
contextListener
);
Trac
ing
Context
.
ListenerManager
.
add
(
contextListener
);
when
(
request
.
getRequestURI
()).
thenReturn
(
"/test/testRequestURL"
);
when
(
request
.
getRequestURL
()).
thenReturn
(
new
StringBuffer
(
"http://localhost:8080/test/testRequestURL"
));
...
...
@@ -139,7 +139,7 @@ public class TomcatInterceptorTest {
@After
public
void
tearDown
()
throws
Exception
{
Trac
er
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
Trac
ing
Context
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
}
}
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/context/MockTracerContextListener.java
浏览文件 @
19f2a561
package
org.skywalking.apm.sniffer.mock.context
;
import
org.junit.Assert
;
import
org.skywalking.apm.agent.core.context.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.agent.core.context.TracerContextListener
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -10,8 +10,8 @@ import java.util.Collections;
import
java.util.List
;
/**
* This is mock tracer context listener, which should be added by calling {@link Trac
er
Context.ListenerManager#add(TracerContextListener)}.
* This mock listener will hold all finished trace, which all are generated by {@link Trac
er
Context#finish()}.
* This is mock tracer context listener, which should be added by calling {@link Trac
ing
Context.ListenerManager#add(TracerContextListener)}.
* This mock listener will hold all finished trace, which all are generated by {@link Trac
ing
Context#finish()}.
* <p>
* Created by wusheng on 2017/2/20.
*/
...
...
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/TraceSegmentBuilderFactory.java
浏览文件 @
19f2a561
package
org.skywalking.apm.sniffer.mock.trace
;
import
org.skywalking.apm.agent.core.context.Trac
er
Context
;
import
org.skywalking.apm.agent.core.context.Trac
ing
Context
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.trace.builders.trace.*
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -53,10 +53,10 @@ public enum TraceSegmentBuilderFactory {
private
TraceSegment
build
(
TraceSegmentBuilder
builder
)
{
MockTracerContextListener
listener
=
new
MockTracerContextListener
();
try
{
Trac
er
Context
.
ListenerManager
.
add
(
listener
);
Trac
ing
Context
.
ListenerManager
.
add
(
listener
);
return
builder
.
build
(
listener
);
}
finally
{
Trac
er
Context
.
ListenerManager
.
remove
(
listener
);
Trac
ing
Context
.
ListenerManager
.
remove
(
listener
);
}
}
...
...
apm-sniffer/apm-sniffer-mock/src/test/java/org/skywalking/apm/sniffer/mock/MockTrac
er
ContextListenerTestCase.java
→
apm-sniffer/apm-sniffer-mock/src/test/java/org/skywalking/apm/sniffer/mock/MockTrac
ing
ContextListenerTestCase.java
浏览文件 @
19f2a561
...
...
@@ -12,7 +12,7 @@ import org.skywalking.apm.trace.TraceSegment;
/**
* Created by wusheng on 2017/2/21.
*/
public
class
MockTrac
er
ContextListenerTestCase
{
public
class
MockTrac
ing
ContextListenerTestCase
{
@BeforeClass
public
static
void
setup
()
{
ServiceManager
.
INSTANCE
.
boot
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录