Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
903a2a17
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
903a2a17
编写于
6月 09, 2017
作者:
wu-sheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix all compile issues.
上级
14f9154b
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
149 addition
and
97 deletion
+149
-97
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
...org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
+14
-10
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
+16
-13
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java
...lking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java
+2
-2
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
+11
-9
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
+11
-9
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
...alking/apm/plugin/motan/MotanConsumerInterceptorTest.java
+10
-8
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
...alking/apm/plugin/motan/MotanProviderInterceptorTest.java
+7
-5
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
+15
-12
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
+10
-7
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
+10
-7
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
+12
-12
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/SpanLogReader.java
.../org/skywalking/apm/sniffer/mock/trace/SpanLogReader.java
+26
-0
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
+5
-3
未找到文件。
apm-sniffer/apm-sdk-plugin/dubbo-plugin/src/test/java/org/skywalking/apm/plugin/dubbo/DubboInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -5,6 +5,8 @@ import com.alibaba.dubbo.rpc.Invocation;
import
com.alibaba.dubbo.rpc.Invoker
;
import
com.alibaba.dubbo.rpc.Result
;
import
com.alibaba.dubbo.rpc.RpcContext
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.hamcrest.CoreMatchers
;
import
org.junit.After
;
import
org.junit.Assert
;
...
...
@@ -25,6 +27,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptR
import
org.skywalking.apm.plugin.dubbox.BugFixActive
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -39,7 +43,7 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic;
import
static
org
.
powermock
.
api
.
mockito
.
PowerMockito
.
when
;
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
(
{
RpcContext
.
class
,
BugFixActive
.
class
})
@PrepareForTest
({
RpcContext
.
class
,
BugFixActive
.
class
})
public
class
DubboInterceptorTest
{
private
MockTracerContextListener
mockTracerContextListener
;
...
...
@@ -172,12 +176,13 @@ public class DubboInterceptorTest {
assertProvider
();
}
private
void
assertConsumerTraceSegmentInErrorCase
(
TraceSegment
traceSegment
)
{
private
void
assertConsumerTraceSegmentInErrorCase
(
TraceSegment
traceSegment
)
{
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
assertConsumerSpan
(
traceSegment
.
getSpans
().
get
(
0
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertErrorLog
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertErrorLog
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
private
void
assertErrorLog
(
LogData
logData
)
{
...
...
@@ -210,18 +215,18 @@ public class DubboInterceptorTest {
private
void
assertProviderSpan
(
Span
span
)
{
assertCommonsAttribute
(
span
);
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_SERVER
));
}
private
void
assertConsumerSpan
(
Span
span
)
{
assertCommonsAttribute
(
span
);
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_CLIENT
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_CLIENT
));
}
private
void
assertCommonsAttribute
(
Span
span
)
{
assertThat
(
Tags
.
SPAN_LAYER
.
isRPCFramework
(
span
),
is
(
true
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
DubboInterceptor
.
DUBBO_COMPONENT
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"dubbo://127.0.0.1:20880/org.skywalking.apm.test.TestDubboService.test(String)"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"rpc"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
DubboInterceptor
.
DUBBO_COMPONENT
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
URL
),
is
(
"dubbo://127.0.0.1:20880/org.skywalking.apm.test.TestDubboService.test(String)"
));
assertThat
(
span
.
getOperationName
(),
is
(
"org.skywalking.apm.test.TestDubboService.test(String)"
));
}
...
...
@@ -229,5 +234,4 @@ public class DubboInterceptorTest {
public
void
tearDown
()
throws
Exception
{
TracerContext
.
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
浏览文件 @
903a2a17
...
...
@@ -19,6 +19,9 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
import
org.skywalking.apm.trace.tag.Tags
;
...
...
@@ -76,7 +79,7 @@ public class DefaultHttpClientInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
false
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
false
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
}
});
}
...
...
@@ -94,19 +97,19 @@ public class DefaultHttpClientInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
true
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
true
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
}
});
}
private
void
assertSpan
(
Span
span
)
{
Assert
.
assertEquals
(
"http"
,
Tags
.
SPAN_LAYER
.
get
(
span
));
Assert
.
assertEquals
(
"GET"
,
Tags
.
HTTP
.
METHOD
.
get
(
span
));
Assert
.
assertEquals
(
"skywalking.org"
,
Tags
.
PEER_HOST
.
get
(
span
));
Assert
.
assertEquals
(-
1
,
Tags
.
PEER_PORT
.
get
(
span
).
intValue
());
Assert
.
assertEquals
(
"FeignDefaultHttp"
,
Tags
.
COMPONENT
.
get
(
span
));
Assert
.
assertEquals
(
"client"
,
Tags
.
SPAN_KIND
.
get
(
span
));
Assert
.
assertEquals
(
""
,
Tags
.
URL
.
get
(
span
));
Assert
.
assertEquals
(
"http"
,
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
));
Assert
.
assertEquals
(
"GET"
,
StringTagReader
.
get
(
span
,
Tags
.
HTTP
.
METHOD
));
Assert
.
assertEquals
(
"skywalking.org"
,
span
.
getPeerHost
(
));
Assert
.
assertEquals
(-
1
,
span
.
getPort
());
Assert
.
assertEquals
(
"FeignDefaultHttp"
,
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
));
Assert
.
assertEquals
(
"client"
,
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
));
Assert
.
assertEquals
(
""
,
StringTagReader
.
get
(
span
,
Tags
.
URL
));
}
@Test
...
...
@@ -124,11 +127,11 @@ public class DefaultHttpClientInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
true
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
true
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
get
(
0
).
getLogs
(
).
size
());
Assert
.
assertEquals
(
true
,
finishedSegment
.
getSpans
().
get
(
0
).
getLogs
(
).
get
(
0
).
getFields
().
containsKey
(
"stack"
));
Assert
.
assertEquals
(
"testException"
,
finishedSegment
.
getSpans
().
get
(
0
).
getLogs
(
).
get
(
0
).
getFields
().
get
(
"message"
));
Assert
.
assertEquals
(
1
,
SpanLogReader
.
getLogs
(
finishedSegment
.
getSpans
().
get
(
0
)
).
size
());
Assert
.
assertEquals
(
true
,
SpanLogReader
.
getLogs
(
finishedSegment
.
getSpans
().
get
(
0
)
).
get
(
0
).
getFields
().
containsKey
(
"stack"
));
Assert
.
assertEquals
(
"testException"
,
SpanLogReader
.
getLogs
(
finishedSegment
.
getSpans
().
get
(
0
)
).
get
(
0
).
getFields
().
get
(
"message"
));
}
});
}
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/main/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptor.java
浏览文件 @
903a2a17
...
...
@@ -67,8 +67,8 @@ public class MongoDBMethodInterceptor implements InstanceMethodsAroundIntercepto
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
Span
span
=
ContextManager
.
activeSpan
();
span
.
setPeerHost
(
context
.
get
(
MONGODB_HOST
,
String
.
class
));
span
.
setPort
(
context
.
get
(
MONGODB_PORT
,
Integer
.
class
));
span
.
setPeerHost
(
(
String
)
context
.
get
(
MONGODB_HOST
));
span
.
setPort
(
(
Integer
)
context
.
get
(
MONGODB_PORT
));
ContextManager
.
stopSpan
();
return
ret
;
}
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBMethodInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -21,6 +21,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -53,7 +55,7 @@ public class MongoDBMethodInterceptorTest {
Config
.
Plugin
.
MongoDB
.
TRACE_PARAM
=
true
;
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_HOST
,
String
.
class
)).
thenReturn
(
"127.0.0.1"
);
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_HOST
)).
thenReturn
(
"127.0.0.1"
);
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_PORT
)).
thenReturn
(
27017
);
when
(
methodInvokeContext
.
methodName
()).
thenReturn
(
"find"
);
...
...
@@ -96,8 +98,8 @@ public class MongoDBMethodInterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertRedisSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertLogData
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertLogData
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
});
}
...
...
@@ -111,12 +113,12 @@ public class MongoDBMethodInterceptorTest {
private
void
assertRedisSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"MongoDB/FindOperation"
));
assertThat
(
Tags
.
PEER_HOST
.
get
(
span
),
is
(
"127.0.0.1"
));
assertThat
(
Tags
.
PEER_PORT
.
get
(
span
),
is
(
27017
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"MongoDB"
));
assertThat
(
Tags
.
DB_STATEMENT
.
get
(
span
),
is
(
"FindOperation { \"name\" : \"by\" }"
));
assertThat
(
Tags
.
DB_TYPE
.
get
(
span
),
is
(
"MongoDB"
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isDB
(
span
));
assertThat
(
span
.
getPeerHost
(
),
is
(
"127.0.0.1"
));
assertThat
(
span
.
getPort
(
),
is
(
27017
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"MongoDB"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
DB_STATEMENT
),
is
(
"FindOperation { \"name\" : \"by\" }"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
DB_TYPE
),
is
(
"MongoDB"
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"db"
));
}
@After
...
...
apm-sniffer/apm-sdk-plugin/mongodb-3.x-plugin/src/test/java/org/skywalking/apm/plugin/mongodb/v3/MongoDBWriteMethodInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -22,6 +22,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -56,7 +58,7 @@ public class MongoDBWriteMethodInterceptorTest {
Config
.
Plugin
.
MongoDB
.
TRACE_PARAM
=
true
;
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_HOST
,
String
.
class
)).
thenReturn
(
"127.0.0.1"
);
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_HOST
)).
thenReturn
(
"127.0.0.1"
);
when
(
classInstanceContext
.
get
(
MongoDBMethodInterceptor
.
MONGODB_PORT
)).
thenReturn
(
27017
);
when
(
methodInvokeContext
.
methodName
()).
thenReturn
(
"find"
);
...
...
@@ -96,12 +98,12 @@ public class MongoDBWriteMethodInterceptorTest {
private
void
assertRedisSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"MongoDB/DeleteOperation"
));
assertThat
(
Tags
.
PEER_HOST
.
get
(
span
),
is
(
"127.0.0.1"
));
assertThat
(
Tags
.
PEER_PORT
.
get
(
span
),
is
(
27017
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"MongoDB"
));
assertThat
(
Tags
.
DB_STATEMENT
.
get
(
span
),
is
(
"DeleteOperation { \"name\" : \"by\" },"
));
assertThat
(
Tags
.
DB_TYPE
.
get
(
span
),
is
(
"MongoDB"
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isDB
(
span
));
assertThat
(
span
.
getPeerHost
(
),
is
(
"127.0.0.1"
));
assertThat
(
span
.
getPort
(
),
is
(
27017
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"MongoDB"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
DB_STATEMENT
),
is
(
"DeleteOperation { \"name\" : \"by\" },"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
DB_TYPE
),
is
(
"MongoDB"
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"db"
));
}
@Test
...
...
@@ -117,8 +119,8 @@ public class MongoDBWriteMethodInterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertRedisSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertLogData
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertLogData
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
});
}
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanConsumerInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -17,6 +17,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.EnhancedClassInstanceCon
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -97,8 +99,8 @@ public class MotanConsumerInterceptorTest {
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertMotanConsumerSpan
(
span
);
verify
(
request
,
times
(
1
)).
setAttachment
(
anyString
(),
anyString
());
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
LogData
logData
=
span
.
getLogs
(
).
get
(
0
);
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
LogData
logData
=
SpanLogReader
.
getLogs
(
span
).
get
(
0
);
assertLogData
(
logData
);
}
});
...
...
@@ -124,12 +126,12 @@ public class MotanConsumerInterceptorTest {
private
void
assertMotanConsumerSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"org.skywalking.apm.test.TestService.test(java.lang.String, java.lang.Object)"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Motan"
));
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_CLIENT
));
assertThat
(
Tags
.
PEER_HOST
.
get
(
span
),
is
(
"127.0.0.1"
));
assertThat
(
Tags
.
PEER_PORT
.
get
(
span
),
is
(
34000
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isRPCFramework
(
span
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"motan://127.0.0.1:34000/default_rpc/org.skywalking.apm.test.TestService/1.0/service"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"Motan"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_CLIENT
));
assertThat
(
span
.
getPeerHost
(
),
is
(
"127.0.0.1"
));
assertThat
(
span
.
getPort
(
),
is
(
34000
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"rpc"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
URL
),
is
(
"motan://127.0.0.1:34000/default_rpc/org.skywalking.apm.test.TestService/1.0/service"
));
}
@After
...
...
apm-sniffer/apm-sdk-plugin/motan-plugin/src/test/java/org/skywalking/apm/plugin/motan/MotanProviderInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -18,6 +18,8 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvok
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -133,8 +135,8 @@ public class MotanProviderInterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertMotanProviderSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
LogData
logData
=
span
.
getLogs
(
).
get
(
0
);
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
LogData
logData
=
SpanLogReader
.
getLogs
(
span
).
get
(
0
);
assertLogData
(
logData
);
}
});
...
...
@@ -155,9 +157,9 @@ public class MotanProviderInterceptorTest {
private
void
assertMotanProviderSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"org.skywalking.apm.test.TestService.test(java.lang.String, java.lang.Object)"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Motan"
));
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isRPCFramework
(
span
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"Motan"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"rpc"
));
}
@After
...
...
apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/test/java/org/skywalking/apm/plugin/okhttp/v3/RealCallInterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -17,6 +17,9 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ConstructorInvok
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodInvokeContext
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.BooleanTagReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
import
org.skywalking.apm.trace.tag.Tags
;
...
...
@@ -83,7 +86,7 @@ public class RealCallInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
false
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
false
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
}
});
}
...
...
@@ -102,19 +105,19 @@ public class RealCallInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
true
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
true
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
}
});
}
private
void
assertSpan
(
Span
span
)
{
Assert
.
assertEquals
(
"http"
,
Tags
.
SPAN_LAYER
.
get
(
span
));
Assert
.
assertEquals
(
"GET"
,
Tags
.
HTTP
.
METHOD
.
get
(
span
));
Assert
.
assertEquals
(
"skywalking.org"
,
Tags
.
PEER_HOST
.
get
(
span
));
Assert
.
assertEquals
(
80
,
Tags
.
PEER_PORT
.
get
(
span
).
intValue
());
Assert
.
assertEquals
(
"OKHttp"
,
Tags
.
COMPONENT
.
get
(
span
));
Assert
.
assertEquals
(
"client"
,
Tags
.
SPAN_KIND
.
get
(
span
));
Assert
.
assertEquals
(
"/"
,
Tags
.
URL
.
get
(
span
));
Assert
.
assertEquals
(
"http"
,
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
));
Assert
.
assertEquals
(
"GET"
,
StringTagReader
.
get
(
span
,
Tags
.
HTTP
.
METHOD
));
Assert
.
assertEquals
(
"skywalking.org"
,
span
.
getPeerHost
(
));
Assert
.
assertEquals
(
80
,
span
.
getPort
());
Assert
.
assertEquals
(
"OKHttp"
,
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
));
Assert
.
assertEquals
(
"client"
,
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
));
Assert
.
assertEquals
(
"/"
,
StringTagReader
.
get
(
span
,
Tags
.
URL
));
}
@Test
...
...
@@ -133,10 +136,10 @@ public class RealCallInterceptorTest {
@Override
public
void
call
(
TraceSegment
finishedSegment
)
{
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
size
());
assertSpan
(
finishedSegment
.
getSpans
().
get
(
0
));
Assert
.
assertEquals
(
true
,
Tags
.
ERROR
.
get
(
finishedSegment
.
getSpans
().
get
(
0
)
));
Assert
.
assertEquals
(
true
,
BooleanTagReader
.
get
(
finishedSegment
.
getSpans
().
get
(
0
),
Tags
.
ERROR
));
Assert
.
assertEquals
(
1
,
finishedSegment
.
getSpans
().
get
(
0
).
getLogs
(
).
size
());
Assert
.
assertEquals
(
true
,
finishedSegment
.
getSpans
().
get
(
0
).
getLogs
(
).
get
(
0
).
getFields
().
containsKey
(
"stack"
));
Assert
.
assertEquals
(
1
,
SpanLogReader
.
getLogs
(
finishedSegment
.
getSpans
().
get
(
0
)
).
size
());
Assert
.
assertEquals
(
true
,
SpanLogReader
.
getLogs
(
finishedSegment
.
getSpans
().
get
(
0
)
).
get
(
0
).
getFields
().
containsKey
(
"stack"
));
}
});
}
...
...
apm-sniffer/apm-sdk-plugin/resin-3.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v3/ResinV3InterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -16,6 +16,9 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodIn
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -116,8 +119,8 @@ public class ResinV3InterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertHttpSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertSpanLog
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertSpanLog
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
});
}
...
...
@@ -136,11 +139,11 @@ public class ResinV3InterceptorTest {
private
void
assertHttpSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"/test/testRequestURL"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Resin"
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
Tags
.
STATUS_CODE
.
get
(
span
),
is
(
200
));
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isHttp
(
span
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"Resin"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
URL
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
IntTagReader
.
get
(
span
,
Tags
.
STATUS_CODE
),
is
(
200
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"http"
));
}
@After
...
...
apm-sniffer/apm-sdk-plugin/resin-4.x-plugin/src/test/java/org/skywalking/apm/plugin/resin/v4/ResinV4InterceptorTest.java
浏览文件 @
903a2a17
...
...
@@ -16,6 +16,9 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodIn
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
...
...
@@ -115,8 +118,8 @@ public class ResinV4InterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertHttpSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertSpanLog
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertSpanLog
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
});
}
...
...
@@ -135,11 +138,11 @@ public class ResinV4InterceptorTest {
private
void
assertHttpSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"/test/testRequestURL"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Resin"
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
Tags
.
STATUS_CODE
.
get
(
span
),
is
(
200
));
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isHttp
(
span
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"Resin"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
URL
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
IntTagReader
.
get
(
span
,
Tags
.
STATUS_CODE
),
is
(
200
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"http"
));
}
@After
...
...
apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/test/java/org/skywalking/apm/plugin/tomcat78x/TomcatInterceptorTest.java
浏览文件 @
903a2a17
package
org.skywalking.apm.plugin.tomcat78x
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.hamcrest.CoreMatchers
;
import
org.junit.After
;
import
org.junit.Before
;
...
...
@@ -14,19 +16,18 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodIn
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.skywalking.apm.sniffer.mock.context.MockTracerContextListener
;
import
org.skywalking.apm.sniffer.mock.context.SegmentAssert
;
import
org.skywalking.apm.sniffer.mock.trace.SpanLogReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.IntTagReader
;
import
org.skywalking.apm.sniffer.mock.trace.tags.StringTagReader
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
import
org.skywalking.apm.trace.TraceSegment
;
import
org.skywalking.apm.trace.TraceSegmentRef
;
import
org.skywalking.apm.trace.tag.Tags
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
...
...
@@ -110,8 +111,8 @@ public class TomcatInterceptorTest {
assertThat
(
traceSegment
.
getSpans
().
size
(),
is
(
1
));
Span
span
=
traceSegment
.
getSpans
().
get
(
0
);
assertHttpSpan
(
span
);
assertThat
(
span
.
getLogs
(
).
size
(),
is
(
1
));
assertSpanLog
(
span
.
getLogs
(
).
get
(
0
));
assertThat
(
SpanLogReader
.
getLogs
(
span
).
size
(),
is
(
1
));
assertSpanLog
(
SpanLogReader
.
getLogs
(
span
).
get
(
0
));
}
});
}
...
...
@@ -130,16 +131,15 @@ public class TomcatInterceptorTest {
private
void
assertHttpSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"/test/testRequestURL"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Tomcat"
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
Tags
.
STATUS_CODE
.
get
(
span
),
is
(
200
));
assertThat
(
Tags
.
SPAN_KIND
.
get
(
span
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
rue
(
Tags
.
SPAN_LAYER
.
isHttp
(
span
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
COMPONENT
),
is
(
"Tomcat"
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
URL
),
is
(
"http://localhost:8080/test/testRequestURL"
));
assertThat
(
IntTagReader
.
get
(
span
,
Tags
.
STATUS_CODE
),
is
(
200
));
assertThat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_KIND
),
is
(
Tags
.
SPAN_KIND_SERVER
));
assertT
hat
(
StringTagReader
.
get
(
span
,
Tags
.
SPAN_LAYER
.
SPAN_LAYER_TAG
),
is
(
"http"
));
}
@After
public
void
tearDown
()
throws
Exception
{
TracerContext
.
ListenerManager
.
remove
(
new
MockTracerContextListener
());
}
}
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/SpanLogReader.java
0 → 100644
浏览文件 @
903a2a17
package
org.skywalking.apm.sniffer.mock.trace
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
org.skywalking.apm.trace.LogData
;
import
org.skywalking.apm.trace.Span
;
/**
* @author wusheng
*/
public
class
SpanLogReader
{
public
static
List
<
LogData
>
getLogs
(
Span
span
)
{
Field
logs
=
null
;
try
{
logs
=
Span
.
class
.
getDeclaredField
(
"logs"
);
}
catch
(
NoSuchFieldException
e
)
{
throw
new
RuntimeException
(
e
);
}
logs
.
setAccessible
(
true
);
try
{
return
(
List
<
LogData
>)
logs
.
get
(
span
);
}
catch
(
IllegalAccessException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
apm-sniffer/apm-sniffer-mock/src/main/java/org/skywalking/apm/sniffer/mock/trace/tags/BooleanTagReader.java
浏览文件 @
903a2a17
...
...
@@ -22,9 +22,11 @@ public class BooleanTagReader {
e
.
printStackTrace
();
}
for
(
BooleanTagItem
item
:
tagsWithBoolList
)
{
if
(
tag
.
key
().
equals
(
item
.
getKey
()))
{
return
item
.
getValue
();
if
(
tagsWithBoolList
!=
null
)
{
for
(
BooleanTagItem
item
:
tagsWithBoolList
)
{
if
(
tag
.
key
().
equals
(
item
.
getKey
()))
{
return
item
.
getValue
();
}
}
}
return
tag
.
defaultValue
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录