Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
107eaacf
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,发现更多精彩内容 >>
提交
107eaacf
编写于
2月 27, 2018
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjust hystrix plugin buried point
上级
851ee0fe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
244 addition
and
30 deletion
+244
-30
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java
...ugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java
+53
-0
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
...g/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
+57
-0
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
...walking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
+105
-29
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/define/HystrixCommandInstrumentation.java
...ugin/hystrix/v1/define/HystrixCommandInstrumentation.java
+29
-1
未找到文件。
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandGetFallbackInterceptor.java
0 → 100644
浏览文件 @
107eaacf
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
public
class
HystrixCommandGetFallbackInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
EnhanceRequireObjectCache
enhanceRequireObjectCache
=
(
EnhanceRequireObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
ContextSnapshot
snapshot
=
enhanceRequireObjectCache
.
getContextSnapshot
();
AbstractSpan
activeSpan
=
ContextManager
.
createLocalSpan
(
enhanceRequireObjectCache
.
getOperationNamePrefix
()
+
"/Fallback"
);
activeSpan
.
setComponent
(
ComponentsDefine
.
HYSTRIX
);
ContextManager
.
continued
(
snapshot
);
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/HystrixCommandRunInterceptor.java
0 → 100644
浏览文件 @
107eaacf
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
public
class
HystrixCommandRunInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
// create a local span, and continued, The `execution method` running in other thread if the
// hystrix strategy is `THREAD`.
EnhanceRequireObjectCache
enhanceRequireObjectCache
=
(
EnhanceRequireObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
ContextSnapshot
snapshot
=
enhanceRequireObjectCache
.
getContextSnapshot
();
AbstractSpan
activeSpan
=
ContextManager
.
createLocalSpan
(
enhanceRequireObjectCache
.
getOperationNamePrefix
()
+
"/Execution"
);
activeSpan
.
setComponent
(
ComponentsDefine
.
HYSTRIX
);
ContextManager
.
continued
(
snapshot
);
// Because of `fall back` method running in other thread. so we need capture concurrent span for tracing.
enhanceRequireObjectCache
.
setContextSnapshot
(
ContextManager
.
capture
());
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ContextManager
.
stopSpan
();
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/SWExecutionHookWrapper.java
浏览文件 @
107eaacf
...
...
@@ -18,13 +18,12 @@
package
org.apache.skywalking.apm.plugin.hystrix.v1
;
import
com.netflix.hystrix.HystrixCommand
;
import
com.netflix.hystrix.HystrixInvokable
;
import
com.netflix.hystrix.exception.HystrixRuntimeException
;
import
com.netflix.hystrix.strategy.executionhook.HystrixCommandExecutionHook
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
/**
* {@link SWExecutionHookWrapper} wrapper the HystrixCommandExecutionHook object for tracing.
...
...
@@ -48,57 +47,134 @@ public class SWExecutionHookWrapper extends HystrixCommandExecutionHook {
@Override
public
<
T
>
void
onExecutionStart
(
HystrixInvokable
<
T
>
commandInstance
)
{
// create a local span, and continued, The `execution method` running in other thread if the
// hystrix strategy is `THREAD`.
EnhancedInstance
enhancedInstance
=
(
EnhancedInstance
)
commandInstance
;
EnhanceRequireObjectCache
enhanceRequireObjectCache
=
(
EnhanceRequireObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
ContextSnapshot
snapshot
=
enhanceRequireObjectCache
.
getContextSnapshot
();
AbstractSpan
activeSpan
=
ContextManager
.
createLocalSpan
(
enhanceRequireObjectCache
.
getOperationNamePrefix
()
+
"/Execution"
);
activeSpan
.
setComponent
(
ComponentsDefine
.
HYSTRIX
);
ContextManager
.
continued
(
snapshot
);
actual
.
onExecutionStart
(
commandInstance
);
// Because of `fall back` method running in other thread. so we need capture concurrent span for tracing.
enhanceRequireObjectCache
.
setContextSnapshot
(
ContextManager
.
capture
());
}
@Override
public
<
T
>
Exception
onExecutionError
(
HystrixInvokable
<
T
>
commandInstance
,
Exception
e
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
e
);
ContextManager
.
stopSpan
();
return
actual
.
onExecutionError
(
commandInstance
,
e
);
}
@Override
public
<
T
>
void
onExecutionSuccess
(
HystrixInvokable
<
T
>
commandInstance
)
{
ContextManager
.
stopSpan
();
actual
.
onExecutionSuccess
(
commandInstance
);
}
@Override
public
<
T
>
void
onFallbackStart
(
HystrixInvokable
<
T
>
commandInstance
)
{
EnhancedInstance
enhancedInstance
=
(
EnhancedInstance
)
commandInstance
;
EnhanceRequireObjectCache
enhanceRequireObjectCache
=
(
EnhanceRequireObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
ContextSnapshot
snapshot
=
enhanceRequireObjectCache
.
getContextSnapshot
();
AbstractSpan
activeSpan
=
ContextManager
.
createLocalSpan
(
enhanceRequireObjectCache
.
getOperationNamePrefix
()
+
"/Fallback"
);
activeSpan
.
setComponent
(
ComponentsDefine
.
HYSTRIX
);
ContextManager
.
continued
(
snapshot
);
actual
.
onFallbackStart
(
commandInstance
);
}
@Override
public
<
T
>
Exception
onFallbackError
(
HystrixInvokable
<
T
>
commandInstance
,
Exception
e
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
e
);
ContextManager
.
stopSpan
();
return
actual
.
onFallbackError
(
commandInstance
,
e
);
}
@Override
public
<
T
>
void
onFallbackSuccess
(
HystrixInvokable
<
T
>
commandInstance
)
{
ContextManager
.
stopSpan
();
actual
.
onFallbackSuccess
(
commandInstance
);
}
@Override
public
<
T
>
Exception
onRunError
(
HystrixInvokable
<
T
>
commandInstance
,
Exception
e
)
{
return
actual
.
onRunError
(
commandInstance
,
e
);
}
@Override
public
<
T
>
Exception
onRunError
(
HystrixCommand
<
T
>
commandInstance
,
Exception
e
)
{
return
actual
.
onRunError
(
commandInstance
,
e
);
}
@Override
public
<
T
>
Exception
onError
(
HystrixInvokable
<
T
>
commandInstance
,
HystrixRuntimeException
.
FailureType
failureType
,
Exception
e
)
{
return
actual
.
onError
(
commandInstance
,
failureType
,
e
);
}
@Override
public
<
T
>
void
onSuccess
(
HystrixInvokable
<
T
>
commandInstance
)
{
actual
.
onSuccess
(
commandInstance
);
}
@Override
public
<
T
>
T
onEmit
(
HystrixInvokable
<
T
>
commandInstance
,
T
value
)
{
return
actual
.
onEmit
(
commandInstance
,
value
);
}
@Override
public
<
T
>
T
onExecutionEmit
(
HystrixInvokable
<
T
>
commandInstance
,
T
value
)
{
return
actual
.
onExecutionEmit
(
commandInstance
,
value
);
}
@Override
public
<
T
>
T
onFallbackEmit
(
HystrixInvokable
<
T
>
commandInstance
,
T
value
)
{
return
actual
.
onFallbackEmit
(
commandInstance
,
value
);
}
@Override
public
<
T
>
void
onCacheHit
(
HystrixInvokable
<
T
>
commandInstance
)
{
actual
.
onCacheHit
(
commandInstance
);
}
@Override
public
<
T
>
void
onThreadComplete
(
HystrixInvokable
<
T
>
commandInstance
)
{
actual
.
onThreadComplete
(
commandInstance
);
}
@Override
public
<
T
>
void
onThreadStart
(
HystrixInvokable
<
T
>
commandInstance
)
{
actual
.
onThreadStart
(
commandInstance
);
}
@Override
public
<
T
>
Exception
onError
(
HystrixCommand
<
T
>
commandInstance
,
HystrixRuntimeException
.
FailureType
failureType
,
Exception
e
)
{
return
actual
.
onError
(
commandInstance
,
failureType
,
e
);
}
@Override
public
<
T
>
Exception
onFallbackError
(
HystrixCommand
<
T
>
commandInstance
,
Exception
e
)
{
return
actual
.
onFallbackError
(
commandInstance
,
e
);
}
@Override
public
<
T
>
T
onComplete
(
HystrixCommand
<
T
>
commandInstance
,
T
response
)
{
return
actual
.
onComplete
(
commandInstance
,
response
);
}
@Override
public
<
T
>
T
onComplete
(
HystrixInvokable
<
T
>
commandInstance
,
T
response
)
{
return
actual
.
onComplete
(
commandInstance
,
response
);
}
@Override
public
<
T
>
T
onFallbackSuccess
(
HystrixCommand
<
T
>
commandInstance
,
T
fallbackResponse
)
{
return
actual
.
onFallbackSuccess
(
commandInstance
,
fallbackResponse
);
}
@Override
public
<
T
>
T
onFallbackSuccess
(
HystrixInvokable
<
T
>
commandInstance
,
T
fallbackResponse
)
{
return
actual
.
onFallbackSuccess
(
commandInstance
,
fallbackResponse
);
}
@Override
public
<
T
>
T
onRunSuccess
(
HystrixCommand
<
T
>
commandInstance
,
T
response
)
{
return
actual
.
onRunSuccess
(
commandInstance
,
response
);
}
@Override
public
<
T
>
T
onRunSuccess
(
HystrixInvokable
<
T
>
commandInstance
,
T
response
)
{
return
actual
.
onRunSuccess
(
commandInstance
,
response
);
}
@Override
public
<
T
>
void
onFallbackStart
(
HystrixCommand
<
T
>
commandInstance
)
{
actual
.
onFallbackStart
(
commandInstance
);
}
@Override
public
<
T
>
void
onRunStart
(
HystrixCommand
<
T
>
commandInstance
)
{
actual
.
onRunStart
(
commandInstance
);
}
@Override
public
<
T
>
void
onRunStart
(
HystrixInvokable
<
T
>
commandInstance
)
{
actual
.
onRunStart
(
commandInstance
);
}
@Override
public
<
T
>
void
onStart
(
HystrixCommand
<
T
>
commandInstance
)
{
EnhancedInstance
enhancedInstance
=
(
EnhancedInstance
)
commandInstance
;
EnhanceRequireObjectCache
enhanceRequireObjectCache
=
(
EnhanceRequireObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
enhanceRequireObjectCache
.
setContextSnapshot
(
ContextManager
.
capture
());
actual
.
onStart
(
commandInstance
);
}
@Override
public
<
T
>
void
onThreadComplete
(
HystrixCommand
<
T
>
commandInstance
)
{
actual
.
onThreadComplete
(
commandInstance
);
}
@Override
public
<
T
>
void
onThreadStart
(
HystrixCommand
<
T
>
commandInstance
)
{
actual
.
onThreadStart
(
commandInstance
);
}
}
apm-sniffer/apm-sdk-plugin/hystrix-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hystrix/v1/define/HystrixCommandInstrumentation.java
浏览文件 @
107eaacf
...
...
@@ -26,6 +26,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInst
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
HierarchyMatch
.
byHierarchyMatch
;
/**
...
...
@@ -55,7 +56,34 @@ public class HystrixCommandInstrumentation extends ClassInstanceMethodsEnhancePl
}
@Override
protected
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[
0
];
return
new
InstanceMethodsInterceptPoint
[]{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"run"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.hystrix.v1.HystrixCommandRunInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"getFallback"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.hystrix.v1.HystrixCommandGetFallbackInterceptor"
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录