Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
c85db8c4
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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 搜索 >>
未验证
提交
c85db8c4
编写于
11月 19, 2017
作者:
wu-sheng
提交者:
GitHub
11月 19, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into feature/split-agent-module
上级
eaa02545
1996e6ed
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
250 addition
and
15 deletion
+250
-15
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/DiscoveryRestServiceClient.java
...ing/apm/agent/core/remote/DiscoveryRestServiceClient.java
+3
-12
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/pom.xml
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/pom.xml
+42
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/skywalking/apm/plugin/spring/patch/CreateAopProxyInterceptor.java
...ng/apm/plugin/spring/patch/CreateAopProxyInterceptor.java
+56
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/skywalking/apm/plugin/spring/patch/define/AopProxyFactoryInstrumentation.java
...n/spring/patch/define/AopProxyFactoryInstrumentation.java
+70
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def
...ugins/core-patch/src/main/resources/skywalking-plugin.def
+1
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/test/java/org/skywalking/apm/plugin/spring/patch/CreateAopProxyInterceptorTest.java
...pm/plugin/spring/patch/CreateAopProxyInterceptorTest.java
+73
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
+1
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/async/RestRequestInterceptor.java
...gin/spring/resttemplate/async/RestRequestInterceptor.java
+3
-2
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java
...esttemplate/async/define/RestTemplateInstrumentation.java
+1
-1
未找到文件。
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/remote/DiscoveryRestServiceClient.java
浏览文件 @
c85db8c4
...
...
@@ -141,21 +141,12 @@ public class DiscoveryRestServiceClient implements Runnable {
*/
private
void
findBackupServer
()
{
selectedServer
++;
if
(
selectedServer
=
=
serverList
.
length
)
{
if
(
selectedServer
>
=
serverList
.
length
)
{
selectedServer
=
0
;
}
}
/**
* Try to sleep, and ignore the {@link InterruptedException}
*
* @param millis the length of time to sleep in milliseconds
*/
private
void
try2Sleep
(
long
millis
)
{
try
{
Thread
.
sleep
(
millis
);
}
catch
(
InterruptedException
e
)
{
if
(
serverList
.
length
==
0
)
{
selectedServer
=
-
1
;
}
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/pom.xml
0 → 100644
浏览文件 @
c85db8c4
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2017, OpenSkywalking Organization All rights reserved.
~
~ Licensed 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.
~
~ Project repository: https://github.com/OpenSkywalking/skywalking
-->
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
spring-plugins
</artifactId>
<groupId>
org.skywalking
</groupId>
<version>
3.2.5-2017
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-spring-core-patch
</artifactId>
<name>
core-patch
</name>
<dependencies>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-aop
</artifactId>
<version>
3.2.9.RELEASE
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/skywalking/apm/plugin/spring/patch/CreateAopProxyInterceptor.java
0 → 100644
浏览文件 @
c85db8c4
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.spring.patch
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.springframework.aop.framework.AdvisedSupport
;
/**
* {@link CreateAopProxyInterceptor} check that the bean has been implement {@link EnhancedInstance}. <p/>
* if yes, true will be returned.
*
* @author zhang xin
*/
public
class
CreateAopProxyInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
AdvisedSupport
advisedSupport
=
(
AdvisedSupport
)
allArguments
[
0
];
if
(
EnhancedInstance
.
class
.
isAssignableFrom
(
advisedSupport
.
getTargetClass
()))
{
return
true
;
}
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/java/org/skywalking/apm/plugin/spring/patch/define/AopProxyFactoryInstrumentation.java
0 → 100644
浏览文件 @
c85db8c4
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.spring.patch.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
import
org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
/**
* {@link AopProxyFactoryInstrumentation} indicate that spring core patch plugin intercepts the {@link
* org.springframework.aop.framework.DefaultAopProxyFactory#hasNoUserSuppliedProxyInterfaces} method by using {@link
* org.skywalking.apm.plugin.spring.patch.CreateAopProxyInterceptor} class.
*
* @author zhangxin
*/
public
class
AopProxyFactoryInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
private
static
final
String
ENHANCE_CLASS
=
"org.springframework.aop.framework.DefaultAopProxyFactory"
;
public
static
final
String
ENHANCE_METHOD
=
"hasNoUserSuppliedProxyInterfaces"
;
public
static
final
String
INTERCEPT_CLASS
=
"org.skywalking.apm.plugin.spring.patch.CreateAopProxyInterceptor"
;
@Override
protected
final
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
protected
final
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
ENHANCE_METHOD
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
INTERCEPT_CLASS
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
}
};
}
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
ENHANCE_CLASS
);
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
c85db8c4
spring-core-patch=org.skywalking.apm.plugin.spring.patch.define.AopProxyFactoryInstrumentation
apm-sniffer/apm-sdk-plugin/spring-plugins/core-patch/src/test/java/org/skywalking/apm/plugin/spring/patch/CreateAopProxyInterceptorTest.java
0 → 100644
浏览文件 @
c85db8c4
/*
* Copyright 2017, OpenSkywalking Organization All rights reserved.
*
* Licensed 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.
*
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.skywalking.apm.plugin.spring.patch
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.springframework.aop.framework.AdvisedSupport
;
import
static
org
.
hamcrest
.
core
.
Is
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
CreateAopProxyInterceptorTest
{
private
CreateAopProxyInterceptor
interceptor
;
@Mock
private
EnhancedInstance
enhancedInstance
;
@Mock
private
AdvisedSupport
advisedSupport
;
@Before
public
void
setUp
()
{
interceptor
=
new
CreateAopProxyInterceptor
();
}
@Test
public
void
testInterceptNormalObject
()
throws
Throwable
{
doReturn
(
Object
.
class
).
when
(
advisedSupport
).
getTargetClass
();
assertThat
(
false
,
is
(
interceptor
.
afterMethod
(
enhancedInstance
,
null
,
new
Object
[]
{
advisedSupport
},
new
Class
[]
{
Object
.
class
},
false
)));
}
@Test
public
void
testInterceptEnhanceInstanceObject
()
throws
Throwable
{
doReturn
(
MockClass
.
class
).
when
(
advisedSupport
).
getTargetClass
();
assertThat
(
true
,
is
(
interceptor
.
afterMethod
(
enhancedInstance
,
null
,
new
Object
[]
{
advisedSupport
},
new
Class
[]
{
Object
.
class
},
false
)));
}
private
class
MockClass
implements
EnhancedInstance
{
@Override
public
Object
getSkyWalkingDynamicField
()
{
return
null
;
}
@Override
public
void
setSkyWalkingDynamicField
(
Object
value
)
{
}
}
}
apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
浏览文件 @
c85db8c4
...
...
@@ -34,6 +34,7 @@
<module>
mvc-annotation-4.x-plugin
</module>
<module>
spring-cloud
</module>
<module>
mvc-annotation-3.x-plugin
</module>
<module>
core-patch
</module>
</modules>
<packaging>
pom
</packaging>
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/s
pringframework/http/client
/RestRequestInterceptor.java
→
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/s
kywalking/apm/plugin/spring/resttemplate/async
/RestRequestInterceptor.java
浏览文件 @
c85db8c4
...
...
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
package
org.s
pringframework.http.client
;
package
org.s
kywalking.apm.plugin.spring.resttemplate.async
;
import
java.lang.reflect.Method
;
import
org.skywalking.apm.agent.core.context.CarrierItem
;
...
...
@@ -24,6 +24,7 @@ import org.skywalking.apm.agent.core.context.ContextCarrier;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor
;
import
org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult
;
import
org.springframework.http.client.AsyncClientHttpRequest
;
public
class
RestRequestInterceptor
implements
InstanceMethodsAroundInterceptor
{
...
...
@@ -36,7 +37,7 @@ public class RestRequestInterceptor implements InstanceMethodsAroundInterceptor
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
A
bstractAsyncClientHttpRequest
clientHttpRequest
=
(
Abstract
AsyncClientHttpRequest
)
ret
;
A
syncClientHttpRequest
clientHttpRequest
=
(
AsyncClientHttpRequest
)
ret
;
if
(
ret
!=
null
)
{
Object
[]
cacheValues
=
(
Object
[])
objInst
.
getSkyWalkingDynamicField
();
ContextCarrier
contextCarrier
=
(
ContextCarrier
)
cacheValues
[
1
];
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java
浏览文件 @
c85db8c4
...
...
@@ -47,7 +47,7 @@ public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePlug
private
static
final
String
DO_EXECUTE_METHOD_NAME
=
"doExecute"
;
private
static
final
String
DO_EXECUTE_INTERCEPTOR
=
"org.skywalking.apm.plugin.spring.resttemplate.async.RestExecuteInterceptor"
;
private
static
final
String
CREATE_REQUEST_METHOD_NAME
=
"createAsyncRequest"
;
private
static
final
String
CREATE_REQUEST_INTERCEPTOR
=
"org.s
pringframework.http.client
.RestRequestInterceptor"
;
private
static
final
String
CREATE_REQUEST_INTERCEPTOR
=
"org.s
kywalking.apm.plugin.spring.resttemplate.async
.RestRequestInterceptor"
;
@Override
protected
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录