Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
润土的好友猹
SkyWalking
提交
21696f13
S
SkyWalking
项目概览
润土的好友猹
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
9
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
21696f13
编写于
3月 08, 2017
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix http client plugin test failure issue
上级
c4b61098
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
6 deletion
+22
-6
skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
...ng/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
+20
-4
skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
...lugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
+2
-2
未找到文件。
skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/main/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptor.java
浏览文件 @
21696f13
...
...
@@ -16,6 +16,9 @@ import org.apache.http.HttpRequest;
import
org.apache.http.HttpResponse
;
import
org.apache.http.StatusLine
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
/**
* {@link HttpClientExecuteInterceptor} transport the trace context by call {@link HttpRequest#setHeader(Header)},
* The current span tag the {@link Tags#ERROR} if {@link StatusLine#getStatusCode()} is not equals 200.
...
...
@@ -36,13 +39,12 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
}
HttpHost
httpHost
=
(
HttpHost
)
allArguments
[
0
];
HttpRequest
httpRequest
=
(
HttpRequest
)
allArguments
[
1
];
Span
span
=
ContextManager
.
INSTANCE
.
createSpan
(
httpRequest
.
getRequestLine
().
getUri
());
Span
span
=
createSpan
(
httpRequest
);
Tags
.
PEER_PORT
.
set
(
span
,
httpHost
.
getPort
());
Tags
.
PEER_HOST
.
set
(
span
,
httpHost
.
getHostName
());
Tags
.
SPAN_KIND
.
set
(
span
,
Tags
.
SPAN_KIND_CLIENT
);
Tags
.
COMPONENT
.
set
(
span
,
COMPONENT_NAME
);
Tags
.
URL
.
set
(
span
,
generateURL
(
http
Host
,
http
Request
));
Tags
.
URL
.
set
(
span
,
generateURL
(
httpRequest
));
Tags
.
SPAN_LAYER
.
asHttp
(
span
);
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
...
...
@@ -55,10 +57,24 @@ public class HttpClientExecuteInterceptor implements InstanceMethodsAroundInterc
*
* @return request URL
*/
private
String
generateURL
(
Http
Host
httpHost
,
Http
Request
httpRequest
)
{
private
String
generateURL
(
HttpRequest
httpRequest
)
{
return
httpRequest
.
getRequestLine
().
getUri
();
}
/**
* Create span.
*/
private
Span
createSpan
(
HttpRequest
httpRequest
)
{
Span
span
;
try
{
URL
url
=
new
URL
(
httpRequest
.
getRequestLine
().
getUri
());
span
=
ContextManager
.
INSTANCE
.
createSpan
(
url
.
getPath
());
}
catch
(
MalformedURLException
e
)
{
span
=
ContextManager
.
INSTANCE
.
createSpan
(
httpRequest
.
getRequestLine
().
getUri
());
}
return
span
;
}
@Override
public
Object
afterMethod
(
EnhancedClassInstanceContext
context
,
InstanceMethodInvokeContext
interceptorContext
,
Object
ret
)
{
...
...
skywalking-sniffer/skywalking-sdk-plugin/httpClient-4.x-plugin/src/test/java/com/a/eye/skywalking/plugin/httpClient/v4/HttpClientExecuteInterceptorTest.java
浏览文件 @
21696f13
...
...
@@ -77,7 +77,7 @@ public class HttpClientExecuteInterceptorTest {
@Override
public
String
getUri
()
{
return
"/test-web/test"
;
return
"
http://127.0.0.1:8080
/test-web/test"
;
}
});
when
(
httpHost
.
getPort
()).
thenReturn
(
8080
);
...
...
@@ -151,7 +151,7 @@ public class HttpClientExecuteInterceptorTest {
private
void
assertHttpSpan
(
Span
span
)
{
assertThat
(
span
.
getOperationName
(),
is
(
"/test-web/test"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Http"
));
assertThat
(
Tags
.
COMPONENT
.
get
(
span
),
is
(
"Http
Client
"
));
assertThat
(
Tags
.
PEER_HOST
.
get
(
span
),
is
(
"127.0.0.1"
));
assertThat
(
Tags
.
PEER_PORT
.
get
(
span
),
is
(
8080
));
assertThat
(
Tags
.
URL
.
get
(
span
),
is
(
"http://127.0.0.1:8080/test-web/test"
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录