Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
8820287f
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
8820287f
编写于
7月 23, 2021
作者:
A
ArjenDavid-sjtu
提交者:
GitHub
7月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve okhttp plugin performance by optimizing Class.getDeclaredField(). (#7364)
Simple polish only.
上级
a7abb1f5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
16 deletion
+42
-16
CHANGES.md
CHANGES.md
+1
-0
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/AsyncCallInterceptor.java
...alking/apm/plugin/okhttp/common/AsyncCallInterceptor.java
+21
-8
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/RealCallInterceptor.java
...walking/apm/plugin/okhttp/common/RealCallInterceptor.java
+20
-8
未找到文件。
CHANGES.md
浏览文件 @
8820287f
...
...
@@ -39,6 +39,7 @@ Release Notes.
*
Remove plugins for ShardingSphere legacy version.
*
Update agent plugin for ElasticJob GA version
*
Remove the logic of generating instance name in
`KafkaServiceManagementServiceClient`
class.
*
Improve
`okhttp`
plugin performance by optimizing Class.getDeclaredField().
#### OAP-Backend
...
...
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/AsyncCallInterceptor.java
浏览文件 @
8820287f
...
...
@@ -44,6 +44,19 @@ import java.lang.reflect.Method;
* called.
*/
public
class
AsyncCallInterceptor
implements
InstanceConstructorInterceptor
,
InstanceMethodsAroundInterceptor
{
private
static
Field
FIELD_HEADERS_OF_REQUEST
;
static
{
try
{
final
Field
field
=
Request
.
class
.
getDeclaredField
(
"headers"
);
field
.
setAccessible
(
true
);
FIELD_HEADERS_OF_REQUEST
=
field
;
}
catch
(
Exception
ignore
)
{
FIELD_HEADERS_OF_REQUEST
=
null
;
}
}
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
/**
...
...
@@ -73,15 +86,15 @@ public class AsyncCallInterceptor implements InstanceConstructorInterceptor, Ins
Tags
.
URL
.
set
(
span
,
requestUrl
.
uri
().
toString
());
SpanLayer
.
asHttp
(
span
);
Field
headersField
=
Request
.
class
.
getDeclaredField
(
"headers"
);
headersField
.
setAccessible
(
true
);
Headers
.
Builder
headerBuilder
=
request
.
headers
().
newBuilder
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headerBuilder
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
if
(
FIELD_HEADERS_OF_REQUEST
!=
null
)
{
Headers
.
Builder
headerBuilder
=
request
.
headers
().
newBuilder
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headerBuilder
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
FIELD_HEADERS_OF_REQUEST
.
set
(
request
,
headerBuilder
.
build
());
}
headersField
.
set
(
request
,
headerBuilder
.
build
());
}
...
...
apm-sniffer/apm-sdk-plugin/okhttp-common/src/main/java/org/apache/skywalking/apm/plugin/okhttp/common/RealCallInterceptor.java
浏览文件 @
8820287f
...
...
@@ -42,6 +42,18 @@ import java.lang.reflect.Method;
*/
public
class
RealCallInterceptor
implements
InstanceMethodsAroundInterceptor
,
InstanceConstructorInterceptor
{
private
static
Field
FIELD_HEADERS_OF_REQUEST
;
static
{
try
{
final
Field
field
=
Request
.
class
.
getDeclaredField
(
"headers"
);
field
.
setAccessible
(
true
);
FIELD_HEADERS_OF_REQUEST
=
field
;
}
catch
(
Exception
ignore
)
{
FIELD_HEADERS_OF_REQUEST
=
null
;
}
}
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
objInst
.
setSkyWalkingDynamicField
(
allArguments
[
1
]);
...
...
@@ -69,15 +81,15 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In
Tags
.
URL
.
set
(
span
,
requestUrl
.
uri
().
toString
());
SpanLayer
.
asHttp
(
span
);
Field
headersField
=
Request
.
class
.
getDeclaredField
(
"headers"
);
headersField
.
setAccessible
(
true
);
Headers
.
Builder
headerBuilder
=
request
.
headers
().
newBuilder
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headerBuilder
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
if
(
FIELD_HEADERS_OF_REQUEST
!=
null
)
{
Headers
.
Builder
headerBuilder
=
request
.
headers
().
newBuilder
();
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headerBuilder
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
FIELD_HEADERS_OF_REQUEST
.
set
(
request
,
headerBuilder
.
build
());
}
headersField
.
set
(
request
,
headerBuilder
.
build
());
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录