Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
killuaz丶x
SkyWalking
提交
8c3d4fe2
S
SkyWalking
项目概览
killuaz丶x
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
1
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,发现更多精彩内容 >>
提交
8c3d4fe2
编写于
12月 31, 2017
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Agent] Make operation name of fegin plugin more scenes
上级
8399452e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
13 deletion
+16
-13
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
...pm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
+12
-9
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
...lugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
+4
-4
未找到文件。
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java
浏览文件 @
8c3d4fe2
...
@@ -16,7 +16,6 @@
...
@@ -16,7 +16,6 @@
*
*
*/
*/
package
org.apache.skywalking.apm.plugin.feign.http.v9
;
package
org.apache.skywalking.apm.plugin.feign.http.v9
;
import
feign.Request
;
import
feign.Request
;
...
@@ -52,9 +51,9 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
...
@@ -52,9 +51,9 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
private
static
final
String
COMPONENT_NAME
=
"FeignDefaultHttp"
;
private
static
final
String
COMPONENT_NAME
=
"FeignDefaultHttp"
;
/**
/**
* Get the {@link feign.Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
* Get the {@link feign.Request} from {@link EnhancedInstance}, then create {@link AbstractSpan} and set host,
port,
*
port, kind, component, url from {@link feign.Request}.
*
kind, component, url from {@link feign.Request}. Through the reflection of the way, set the http header of
*
Through the reflection of the way, set the http header of
context data into {@link feign.Request#headers}.
* context data into {@link feign.Request#headers}.
*
*
* @param method
* @param method
* @param result change this result, if you want to truncate the method.
* @param result change this result, if you want to truncate the method.
...
@@ -66,11 +65,16 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
...
@@ -66,11 +65,16 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
URL
url
=
new
URL
(
request
.
url
());
URL
url
=
new
URL
(
request
.
url
());
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
String
remotePeer
=
url
.
getHost
()
+
":"
+
url
.
getPort
();
int
port
=
url
.
getPort
()
==
-
1
?
80
:
url
.
getPort
();
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
request
.
url
(),
contextCarrier
,
remotePeer
);
String
remotePeer
=
url
.
getHost
()
+
":"
+
port
;
String
operationName
=
url
.
getPath
();
if
(
operationName
==
null
||
operationName
.
length
()
==
0
)
{
operationName
=
"/"
;
}
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
operationName
,
contextCarrier
,
remotePeer
);
span
.
setComponent
(
ComponentsDefine
.
FEIGN
);
span
.
setComponent
(
ComponentsDefine
.
FEIGN
);
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
method
());
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
method
());
Tags
.
URL
.
set
(
span
,
url
.
getPath
());
Tags
.
URL
.
set
(
span
,
request
.
url
());
SpanLayer
.
asHttp
(
span
);
SpanLayer
.
asHttp
(
span
);
Field
headersField
=
Request
.
class
.
getDeclaredField
(
"headers"
);
Field
headersField
=
Request
.
class
.
getDeclaredField
(
"headers"
);
...
@@ -94,8 +98,7 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
...
@@ -94,8 +98,7 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc
/**
/**
* Get the status code from {@link Response}, when status code greater than 400, it means there was some errors in
* Get the status code from {@link Response}, when status code greater than 400, it means there was some errors in
* the server.
* the server. Finish the {@link AbstractSpan}.
* Finish the {@link AbstractSpan}.
*
*
* @param method
* @param method
* @param ret the method's original return value.
* @param ret the method's original return value.
...
...
apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptorTest.java
浏览文件 @
8c3d4fe2
...
@@ -87,7 +87,7 @@ public class DefaultHttpClientInterceptorTest {
...
@@ -87,7 +87,7 @@ public class DefaultHttpClientInterceptorTest {
public
void
setUp
()
throws
Exception
{
public
void
setUp
()
throws
Exception
{
Map
<
String
,
Collection
<
String
>>
headers
=
new
LinkedHashMap
<
String
,
Collection
<
String
>>();
Map
<
String
,
Collection
<
String
>>
headers
=
new
LinkedHashMap
<
String
,
Collection
<
String
>>();
request
=
Request
.
create
(
"GET"
,
"http://skywalking.org"
,
headers
,
"Test"
.
getBytes
(),
Charset
.
forName
(
"UTF-8"
));
request
=
Request
.
create
(
"GET"
,
"http://skywalking.org
/
"
,
headers
,
"Test"
.
getBytes
(),
Charset
.
forName
(
"UTF-8"
));
Request
.
Options
options
=
new
Request
.
Options
();
Request
.
Options
options
=
new
Request
.
Options
();
allArguments
=
new
Object
[]
{
request
,
options
};
allArguments
=
new
Object
[]
{
request
,
options
};
argumentTypes
=
new
Class
[]
{
request
.
getClass
(),
options
.
getClass
()};
argumentTypes
=
new
Class
[]
{
request
.
getClass
(),
options
.
getClass
()};
...
@@ -112,7 +112,7 @@ public class DefaultHttpClientInterceptorTest {
...
@@ -112,7 +112,7 @@ public class DefaultHttpClientInterceptorTest {
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
assertThat
(
tags
.
size
(),
is
(
2
));
assertThat
(
tags
.
size
(),
is
(
2
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
""
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
"
http://skywalking.org/
"
));
Assert
.
assertEquals
(
false
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
Assert
.
assertEquals
(
false
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
}
}
...
@@ -135,7 +135,7 @@ public class DefaultHttpClientInterceptorTest {
...
@@ -135,7 +135,7 @@ public class DefaultHttpClientInterceptorTest {
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
assertThat
(
tags
.
size
(),
is
(
3
));
assertThat
(
tags
.
size
(),
is
(
3
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
""
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
"
http://skywalking.org/
"
));
assertThat
(
tags
.
get
(
2
).
getValue
(),
is
(
"404"
));
assertThat
(
tags
.
get
(
2
).
getValue
(),
is
(
"404"
));
Assert
.
assertEquals
(
true
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
Assert
.
assertEquals
(
true
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
...
@@ -166,7 +166,7 @@ public class DefaultHttpClientInterceptorTest {
...
@@ -166,7 +166,7 @@ public class DefaultHttpClientInterceptorTest {
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
List
<
KeyValuePair
>
tags
=
SpanHelper
.
getTags
(
finishedSpan
);
assertThat
(
tags
.
size
(),
is
(
2
));
assertThat
(
tags
.
size
(),
is
(
2
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
0
).
getValue
(),
is
(
"GET"
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
""
));
assertThat
(
tags
.
get
(
1
).
getValue
(),
is
(
"
http://skywalking.org/
"
));
Assert
.
assertEquals
(
true
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
Assert
.
assertEquals
(
true
,
SpanHelper
.
getErrorOccurred
(
finishedSpan
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录