Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
77019ba6
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 搜索 >>
提交
77019ba6
编写于
11月 16, 2019
作者:
V
viswaramamoorthy
提交者:
wu-sheng
11月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rabbitmq instrument consumer class correctly to get duration reported accurately (#3761)
上级
554df44a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
12 addition
and
11 deletion
+12
-11
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java
...king/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java
+2
-2
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/define/RabbitMQConsumerInstrumentation.java
...ugin/rabbitmq/define/RabbitMQConsumerInstrumentation.java
+7
-6
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptorTest.java
.../apm/plugin/rabbitmq/RabbitMQConsumerInterceptorTest.java
+3
-3
未找到文件。
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java
浏览文件 @
77019ba6
...
...
@@ -40,8 +40,8 @@ public class RabbitMQConsumerInterceptor implements InstanceMethodsAroundInterce
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
String
url
=
(
String
)
objInst
.
getSkyWalkingDynamicField
();
Envelope
envelope
=
(
Envelope
)
allArguments
[
2
];
AMQP
.
BasicProperties
properties
=
(
AMQP
.
BasicProperties
)
allArguments
[
3
];
Envelope
envelope
=
(
Envelope
)
allArguments
[
1
];
AMQP
.
BasicProperties
properties
=
(
AMQP
.
BasicProperties
)
allArguments
[
2
];
AbstractSpan
activeSpan
=
ContextManager
.
createEntrySpan
(
OPERATE_NAME_PREFIX
+
"Topic/"
+
envelope
.
getExchange
()
+
"Queue/"
+
envelope
.
getRoutingKey
()
+
CONSUMER_OPERATE_NAME_SUFFIX
,
null
).
start
(
System
.
currentTimeMillis
());
Tags
.
MQ_BROKER
.
set
(
activeSpan
,
url
);
Tags
.
MQ_TOPIC
.
set
(
activeSpan
,
envelope
.
getExchange
());
...
...
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/define/RabbitMQConsumerInstrumentation.java
浏览文件 @
77019ba6
...
...
@@ -21,17 +21,18 @@ package org.apache.skywalking.apm.plugin.rabbitmq.define;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.DeclaredInstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
org.apache.skywalking.apm.agent.core.plugin.match.
MultiClassName
Match
;
import
org.apache.skywalking.apm.agent.core.plugin.match.
Hierarchy
Match
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
public
class
RabbitMQConsumerInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
static
final
String
INTERCEPTOR_CLASS
=
"org.apache.skywalking.apm.plugin.rabbitmq.RabbitMQConsumerInterceptor"
;
public
static
final
String
ENHANCE_CLASS_PRODUCER
=
"com.rabbitmq.client.
impl.ConsumerDispatch
er"
;
public
static
final
String
ENHANCE_CLASS_PRODUCER
=
"com.rabbitmq.client.
Consum
er"
;
public
static
final
String
ENHANCE_METHOD_DISPATCH
=
"handleDelivery"
;
public
static
final
String
INTERCEPTOR_CONSTRUCTOR
=
"org.apache.skywalking.apm.plugin.rabbitmq.RabbitMQProducerAndConsumerConstructorInterceptor"
;
@Override
...
...
@@ -52,9 +53,9 @@ public class RabbitMQConsumerInstrumentation extends ClassInstanceMethodsEnhance
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
new
Declared
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD_DISPATCH
).
and
(
takesArgumentWithType
(
3
,
"com.rabbitmq.client.AMQP$BasicProperties"
));
return
named
(
ENHANCE_METHOD_DISPATCH
).
and
(
takesArgumentWithType
(
2
,
"com.rabbitmq.client.AMQP$BasicProperties"
));
}
...
...
@@ -63,7 +64,7 @@ public class RabbitMQConsumerInstrumentation extends ClassInstanceMethodsEnhance
}
@Override
public
boolean
isOverrideArgs
()
{
return
tru
e
;
return
fals
e
;
}
}
};
...
...
@@ -71,6 +72,6 @@ public class RabbitMQConsumerInstrumentation extends ClassInstanceMethodsEnhance
@Override
protected
ClassMatch
enhanceClass
()
{
return
MultiClassNameMatch
.
byMultiClassMatch
(
ENHANCE_CLASS_PRODUCER
);
return
HierarchyMatch
.
byHierarchyMatch
(
new
String
[]
{
ENHANCE_CLASS_PRODUCER
}
);
}
}
apm-sniffer/apm-sdk-plugin/rabbitmq-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptorTest.java
浏览文件 @
77019ba6
...
...
@@ -74,7 +74,7 @@ public class RabbitMQConsumerInterceptorTest {
Map
<
String
,
Object
>
headers
=
new
HashMap
<
String
,
Object
>();
headers
.
put
(
"sw6"
,
"1-MS4xLjE1NDM5NzU1OTEwMTQwMDAx-MS4xLjE1NDM5NzU1OTA5OTcwMDAw-0-1-1-IzEyNy4wLjAuMTo1Mjcy-I1JhYmJpdE1RL1RvcGljL1F1ZXVlL3JhYmJpdG1xLXRlc3QvUHJvZHVjZXI=-I1JhYmJpdE1RL1RvcGljL1F1ZXVlL3JhYmJpdG1xLXRlc3QvUHJvZHVjZXI="
);
AMQP
.
BasicProperties
.
Builder
propsBuilder
=
new
AMQP
.
BasicProperties
.
Builder
();
Object
[]
arguments
=
new
Object
[]
{
0
,
0
,
envelope
,
propsBuilder
.
headers
(
headers
).
build
()};
Object
[]
arguments
=
new
Object
[]
{
0
,
envelope
,
propsBuilder
.
headers
(
headers
).
build
()};
rabbitMQConsumerInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
rabbitMQConsumerInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
...
...
@@ -86,7 +86,7 @@ public class RabbitMQConsumerInterceptorTest {
public
void
testRabbitMQConsumerInterceptorWithNilHeaders
()
throws
Throwable
{
Envelope
envelope
=
new
Envelope
(
1111
,
false
,
""
,
"rabbitmq-test"
);
AMQP
.
BasicProperties
.
Builder
propsBuilder
=
new
AMQP
.
BasicProperties
.
Builder
();
Object
[]
arguments
=
new
Object
[]
{
0
,
0
,
envelope
,
propsBuilder
.
headers
(
null
).
build
()};
Object
[]
arguments
=
new
Object
[]
{
0
,
envelope
,
propsBuilder
.
headers
(
null
).
build
()};
rabbitMQConsumerInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
rabbitMQConsumerInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
...
...
@@ -99,7 +99,7 @@ public class RabbitMQConsumerInterceptorTest {
Envelope
envelope
=
new
Envelope
(
1111
,
false
,
""
,
"rabbitmq-test"
);
Map
<
String
,
Object
>
headers
=
new
HashMap
<
String
,
Object
>();
AMQP
.
BasicProperties
.
Builder
propsBuilder
=
new
AMQP
.
BasicProperties
.
Builder
();
Object
[]
arguments
=
new
Object
[]
{
0
,
0
,
envelope
,
propsBuilder
.
headers
(
headers
).
build
()};
Object
[]
arguments
=
new
Object
[]
{
0
,
envelope
,
propsBuilder
.
headers
(
headers
).
build
()};
rabbitMQConsumerInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
rabbitMQConsumerInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
arguments
,
null
,
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录