Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
7b99019c
S
SkyWalking
项目概览
gdyjdao
/
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,发现更多精彩内容 >>
未验证
提交
7b99019c
编写于
6月 12, 2020
作者:
X
Xin,Zhang
提交者:
GitHub
6月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactory spring gateway plugin (#4878)
上级
dacacf7b
变更
70
隐藏空白更改
内联
并排
Showing
70 changed file
with
1869 addition
and
496 deletion
+1869
-496
.github/workflows/plugins-test.0.yaml
.github/workflows/plugins-test.0.yaml
+2
-1
CHANGES.md
CHANGES.md
+2
-0
apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
.../webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
+12
-10
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml
...lugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml
+55
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java
...ring/cloud/gateway/v20x/HttpClientRequestInterceptor.java
+116
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpclientRequestHeadersInterceptor.java
...oud/gateway/v20x/HttpclientRequestHeadersInterceptor.java
+62
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java
...ing/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java
+71
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/Constants.java
...pm/plugin/spring/cloud/gateway/v20x/define/Constants.java
+32
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/EnhanceCacheObject.java
.../spring/cloud/gateway/v20x/define/EnhanceCacheObject.java
+38
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientInstrumentation.java
.../cloud/gateway/v20x/define/HttpClientInstrumentation.java
+63
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientRequestInstrumentation.java
...gateway/v20x/define/HttpClientRequestInstrumentation.java
+22
-24
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/NettyRoutingFilterInstrumentation.java
...ateway/v20x/define/NettyRoutingFilterInstrumentation.java
+65
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/resources/skywalking-plugin.def
...way-2.0.x-plugin/src/main/resources/skywalking-plugin.def
+19
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
...lugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
+8
-2
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java
...ng/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java
+0
-94
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerConstructorInterceptor.java
...teway/v21x/HttpClientFinalizerConstructorInterceptor.java
+34
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerResponseConnectionInterceptor.java
...21x/HttpClientFinalizerResponseConnectionInterceptor.java
+69
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java
...loud/gateway/v21x/HttpClientFinalizerSendInterceptor.java
+97
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerURIInterceptor.java
...cloud/gateway/v21x/HttpClientFinalizerURIInterceptor.java
+46
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsSendInterceptor.java
...oud/gateway/v21x/HttpClientOperationsSendInterceptor.java
+0
-84
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsStatusInterceptor.java
...d/gateway/v21x/HttpClientOperationsStatusInterceptor.java
+0
-59
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
...ing/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
+40
-50
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/TcpClientConstructorInterceptor.java
...g/cloud/gateway/v21x/TcpClientConstructorInterceptor.java
+29
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/SWTransmitter.java
...ugin/spring/cloud/gateway/v21x/context/SWTransmitter.java
+0
-58
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/AbstractGateway210EnhancePluginDefine.java
...ay/v21x/define/AbstractGateway210EnhancePluginDefine.java
+30
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/Constants.java
...pm/plugin/spring/cloud/gateway/v21x/define/Constants.java
+36
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/EnhanceObjectCache.java
.../spring/cloud/gateway/v21x/define/EnhanceObjectCache.java
+50
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientFinalizerInstrumentation.java
...teway/v21x/define/HttpClientFinalizerInstrumentation.java
+41
-31
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java
...ateway/v21x/define/NettyRoutingFilterInstrumentation.java
+22
-31
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/TcpClientInstrumentation.java
...g/cloud/gateway/v21x/define/TcpClientInstrumentation.java
+57
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def
...way-2.1.x-plugin/src/main/resources/skywalking-plugin.def
+2
-3
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
...ins/optional-spring-plugins/optional-spring-cloud/pom.xml
+1
-0
docs/en/guides/Plugin-test.md
docs/en/guides/Plugin-test.md
+1
-1
docs/en/setup/service-agent/java-agent/Supported-list.md
docs/en/setup/service-agent/java-agent/Supported-list.md
+1
-1
test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
...scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
+28
-18
test/plugin/scenarios/gateway-2.0.x-scenario/configuration.yml
...plugin/scenarios/gateway-2.0.x-scenario/configuration.yml
+1
-1
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/bin/startup.sh
...narios/gateway-2.0.x-scenario/gateway-dist/bin/startup.sh
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/pom.xml
...gin/scenarios/gateway-2.0.x-scenario/gateway-dist/pom.xml
+1
-1
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/src/main/assembly/assembly.xml
....0.x-scenario/gateway-dist/src/main/assembly/assembly.xml
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/pom.xml
.../gateway-2.0.x-scenario/gateway-projectA-scenario/pom.xml
+1
-7
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
...king/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
...walking/apm/testcase/sc/gateway/projectA/Application.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test1Filter.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test2Filter.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
...ng/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
...eway-projectA-scenario/src/main/resources/application.yml
+0
-9
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/pom.xml
.../gateway-2.0.x-scenario/gateway-projectB-scenario/pom.xml
+1
-1
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
...walking/apm/testcase/sc/gateway/projectB/Application.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
...stcase/sc/gateway/projectB/controller/TestController.java
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
...ojectB-scenario/src/main/resources/application.properties
+0
-0
test/plugin/scenarios/gateway-2.0.x-scenario/pom.xml
test/plugin/scenarios/gateway-2.0.x-scenario/pom.xml
+4
-4
test/plugin/scenarios/gateway-2.0.x-scenario/support-version.list
...gin/scenarios/gateway-2.0.x-scenario/support-version.list
+3
-3
test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
...scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
+92
-0
test/plugin/scenarios/gateway-2.1.x-scenario/configuration.yml
...plugin/scenarios/gateway-2.1.x-scenario/configuration.yml
+22
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh
...narios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh
+24
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml
...gin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml
+54
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/src/main/assembly/assembly.xml
....1.x-scenario/gateway-dist/src/main/assembly/assembly.xml
+46
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml
.../gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml
+67
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
...king/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
+12
-3
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
...walking/apm/testcase/sc/gateway/projectA/Application.java
+29
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test1Filter.java
+38
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test2Filter.java
+39
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
...ng/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
+35
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
...eway-projectA-scenario/src/main/resources/application.yml
+27
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml
.../gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml
+57
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
...walking/apm/testcase/sc/gateway/projectB/Application.java
+31
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
...stcase/sc/gateway/projectB/controller/TestController.java
+36
-0
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
...ojectB-scenario/src/main/resources/application.properties
+17
-0
test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml
test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml
+58
-0
test/plugin/scenarios/gateway-2.1.x-scenario/support-version.list
...gin/scenarios/gateway-2.1.x-scenario/support-version.list
+23
-0
未找到文件。
.github/workflows/plugins-test.0.yaml
浏览文件 @
7b99019c
...
...
@@ -51,7 +51,8 @@ jobs:
-
{
name
:
'
finagle-17.10.x-scenario'
,
title
:
'
Finagle
17.10.0-20.1.0(19)'
}
-
{
name
:
'
finagle-6.25.x-scenario'
,
title
:
'
Finagle
6.25.0-6.43.0
(18)'
}
-
{
name
:
'
finagle-6.44.x-scenario'
,
title
:
'
Finagle
6.44.0-7.1.0
(4)'
}
-
{
name
:
'
gateway-scenario'
,
title
:
'
Spring-Cloud-Gateway
2.1.x
(3)'
}
-
{
name
:
'
gateway-2.1.x-scenario'
,
title
:
'
Spring-Cloud-Gateway
2.1.x
(7)'
}
-
{
name
:
'
gateway-2.0.x-scenario'
,
title
:
'
Spring-Cloud-Gateway
2.0.x
(3)'
}
-
{
name
:
'
grpc-scenario'
,
title
:
'
gRPC
1.6.0-1.25.0
(22)'
}
-
{
name
:
'
gson-scenario'
,
title
:
'
Gson
(7)'
}
steps
:
...
...
CHANGES.md
浏览文件 @
7b99019c
...
...
@@ -22,6 +22,8 @@ Release Notes.
*
Support Correlation protocol v1.
*
Fix Finagle plugin bug, in processing Noop Span.
*
Make
`CommandService`
daemon to avoid blocking target application shutting down gracefully.
*
Refactor spring cloud gateway plugin and support tracing spring cloud gateway 2.2.x
#### OAP-Backend
*
Support meter system for Prometheus adoption. In future releases, we will add native meter APIs and MicroMeter(Sleuth) system.
...
...
apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
浏览文件 @
7b99019c
...
...
@@ -41,17 +41,10 @@ import org.springframework.web.util.pattern.PathPattern;
import
reactor.core.publisher.Mono
;
public
class
DispatcherHandlerHandleMethodInterceptor
implements
InstanceMethodsAroundInterceptor
{
private
static
final
String
DEFAULT_OPERATION_NAME
=
"WEBFLUX.handle"
;
@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
{
MethodInterceptResult
result
)
throws
Throwable
{
EnhancedInstance
instance
=
getInstance
(
allArguments
[
0
]);
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
...
...
@@ -67,7 +60,7 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
}
}
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
DEFAULT_OPERATION_NAME
,
carrier
);
AbstractSpan
span
=
ContextManager
.
createEntrySpan
(
exchange
.
getRequest
().
getURI
().
getPath
()
,
carrier
);
span
.
setComponent
(
ComponentsDefine
.
SPRING_WEBFLUX
);
SpanLayer
.
asHttp
(
span
);
Tags
.
URL
.
set
(
span
,
exchange
.
getRequest
().
getURI
().
toString
());
...
...
@@ -76,6 +69,15 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
span
.
prepareForAsync
();
ContextManager
.
stopSpan
(
span
);
objInst
.
setSkyWalkingDynamicField
(
span
);
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
AbstractSpan
span
=
(
AbstractSpan
)
objInst
.
getSkyWalkingDynamicField
();
return
((
Mono
)
ret
).
doFinally
(
s
->
{
try
{
Object
pathPattern
=
exchange
.
getAttribute
(
HandlerMapping
.
BEST_MATCHING_PATTERN_ATTRIBUTE
);
...
...
@@ -99,7 +101,7 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
public
static
EnhancedInstance
getInstance
(
Object
o
)
{
...
...
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
optional-spring-cloud
</artifactId>
<version>
8.0.0-SNAPSHOT
</version>
</parent>
<artifactId>
apm-spring-cloud-gateway-2.0.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
gateway-2.0.x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
<spring-cloud-starter-gateway.version>
2.1.1.RELEASE
</spring-cloud-starter-gateway.version>
<compiler.version>
1.8
</compiler.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-gateway
</artifactId>
<version>
${spring-cloud-starter-gateway.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
io.projectreactor.ipc
</groupId>
<artifactId>
reactor-netty
</artifactId>
<version>
0.7.5.RELEASE
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.function.BiConsumer
;
import
java.util.function.Function
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
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.plugin.spring.cloud.gateway.v20x.define.EnhanceCacheObject
;
import
org.reactivestreams.Publisher
;
import
reactor.core.publisher.Mono
;
import
reactor.ipc.netty.http.client.HttpClientRequest
;
import
reactor.ipc.netty.http.client.HttpClientResponse
;
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
public
class
HttpClientRequestInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
MethodInterceptResult
result
)
throws
Throwable
{
AbstractSpan
span
=
ContextManager
.
activeSpan
();
URL
url
=
new
URL
((
String
)
allArguments
[
1
]);
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
AbstractSpan
abstractSpan
=
ContextManager
.
createExitSpan
(
"SpringCloudGateway/sendRequest"
,
contextCarrier
,
getPeer
(
url
));
abstractSpan
.
prepareForAsync
();
Tags
.
URL
.
set
(
abstractSpan
,
String
.
valueOf
(
allArguments
[
1
]));
abstractSpan
.
setComponent
(
SPRING_CLOUD_GATEWAY
);
ContextManager
.
stopSpan
(
abstractSpan
);
Function
<?
super
HttpClientRequest
,
?
extends
Publisher
<
Void
>>
handler
=
(
Function
<?
super
HttpClientRequest
,
?
extends
Publisher
<
Void
>>)
allArguments
[
2
];
allArguments
[
2
]
=
new
Function
<
HttpClientRequest
,
Publisher
<
Void
>>()
{
@Override
public
Publisher
<
Void
>
apply
(
final
HttpClientRequest
httpClientRequest
)
{
//
CarrierItem
next
=
contextCarrier
.
items
();
if
(
httpClientRequest
instanceof
EnhancedInstance
)
{
((
EnhancedInstance
)
httpClientRequest
).
setSkyWalkingDynamicField
(
next
);
}
return
handler
.
apply
(
httpClientRequest
);
}
};
objInst
.
setSkyWalkingDynamicField
(
new
EnhanceCacheObject
(
span
,
abstractSpan
));
}
@Override
public
Object
afterMethod
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
Object
ret
)
throws
Throwable
{
EnhanceCacheObject
enhanceCacheObject
=
(
EnhanceCacheObject
)
objInst
.
getSkyWalkingDynamicField
();
Mono
<
HttpClientResponse
>
responseMono
=
(
Mono
<
HttpClientResponse
>)
ret
;
return
responseMono
.
doAfterSuccessOrError
(
new
BiConsumer
<
HttpClientResponse
,
Throwable
>()
{
@Override
public
void
accept
(
final
HttpClientResponse
httpClientResponse
,
final
Throwable
throwable
)
{
AbstractSpan
abstractSpan
=
enhanceCacheObject
.
getSendSpan
();
if
(
abstractSpan
!=
null
)
{
if
(
throwable
!=
null
)
{
abstractSpan
.
errorOccurred
().
log
(
throwable
);
}
else
if
(
httpClientResponse
.
status
().
code
()
>
400
)
{
abstractSpan
.
errorOccurred
();
}
Tags
.
STATUS_CODE
.
set
(
abstractSpan
,
String
.
valueOf
(
httpClientResponse
.
status
().
code
()));
abstractSpan
.
asyncFinish
();
}
objInst
.
setSkyWalkingDynamicField
(
null
);
enhanceCacheObject
.
getFilterSpan
().
asyncFinish
();
}
});
}
private
String
getPeer
(
URL
url
)
{
return
url
.
getHost
()
+
":"
+
url
.
getPort
();
}
@Override
public
void
handleMethodException
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpclientRequestHeadersInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x
;
import
io.netty.handler.codec.http.HttpHeaders
;
import
java.lang.reflect.Method
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
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
;
public
class
HttpclientRequestHeadersInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
MethodInterceptResult
result
)
throws
Throwable
{
CarrierItem
next
=
(
CarrierItem
)
objInst
.
getSkyWalkingDynamicField
();
if
(
next
!=
null
)
{
HttpHeaders
headers
=
(
HttpHeaders
)
allArguments
[
0
];
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
headers
.
remove
(
next
.
getHeadKey
());
headers
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
}
}
@Override
public
Object
afterMethod
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
Object
ret
)
throws
Throwable
{
return
ret
;
}
@Override
public
void
handleMethodException
(
final
EnhancedInstance
objInst
,
final
Method
method
,
final
Object
[]
allArguments
,
final
Class
<?>[]
argumentsTypes
,
final
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x
;
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.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchangeDecorator
;
import
org.springframework.web.server.adapter.DefaultServerWebExchange
;
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
public
class
NettyRoutingFilterInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
EnhancedInstance
enhancedInstance
=
getInstance
(
exchange
);
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
"SpringCloudGateway/RoutingFilter"
);
if
(
enhancedInstance
!=
null
&&
enhancedInstance
.
getSkyWalkingDynamicField
()
!=
null
)
{
ContextManager
.
continued
((
ContextSnapshot
)
enhancedInstance
.
getSkyWalkingDynamicField
());
}
span
.
setComponent
(
SPRING_CLOUD_GATEWAY
);
span
.
prepareForAsync
();
}
public
static
EnhancedInstance
getInstance
(
Object
o
)
{
EnhancedInstance
instance
=
null
;
if
(
o
instanceof
DefaultServerWebExchange
)
{
instance
=
(
EnhancedInstance
)
o
;
}
else
if
(
o
instanceof
ServerWebExchangeDecorator
)
{
ServerWebExchange
delegate
=
((
ServerWebExchangeDecorator
)
o
).
getDelegate
();
return
getInstance
(
delegate
);
}
return
instance
;
}
@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/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/Constants.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x.define
;
public
interface
Constants
{
// NettyRoutingFilter
String
INTERCEPT_CLASS_NETTY_ROUTING_FILTER
=
"org.springframework.cloud.gateway.filter.NettyRoutingFilter"
;
String
NETTY_ROUTING_FILTER_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.NettyRoutingFilterInterceptor"
;
// HttpClient
String
INTERCEPT_CLASS_HTTP_CLIENT
=
"reactor.ipc.netty.http.client.HttpClient"
;
String
REQUEST_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.HttpClientRequestInterceptor"
;
// HttpClientRequest
String
INTERCEPT_CLASS_HTTP_CLIENT_REQUEST
=
"reactor.ipc.netty.http.client.HttpClientRequest"
;
String
HTTPCLIENT_REQUEST_HEADERS_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.HttpclientRequestHeadersInterceptor"
;
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/EnhanceCacheObject.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x.define
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
public
class
EnhanceCacheObject
{
private
final
AbstractSpan
filterSpan
;
private
final
AbstractSpan
sendSpan
;
public
EnhanceCacheObject
(
final
AbstractSpan
filterSpan
,
final
AbstractSpan
sendSpan
)
{
this
.
filterSpan
=
filterSpan
;
this
.
sendSpan
=
sendSpan
;
}
public
AbstractSpan
getFilterSpan
()
{
return
filterSpan
;
}
public
AbstractSpan
getSendSpan
()
{
return
sendSpan
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientInstrumentation.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x.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.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
HttpClientInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
Constants
.
INTERCEPT_CLASS_HTTP_CLIENT
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"request"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
REQUEST_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
true
;
}
}
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.
1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/FilteringWebHandler
Instrumentation.java
→
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.
0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientRequest
Instrumentation.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v2
1
x.define
;
package
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v2
0
x.define
;
import
net.bytebuddy.description.method.MethodDescription
;
import
net.bytebuddy.matcher.ElementMatcher
;
...
...
@@ -26,9 +25,14 @@ 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
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
HierarchyMatch
.
byHierarchyMatch
;
public
class
HttpClientRequestInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
FilteringWebHandlerInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byHierarchyMatch
(
Constants
.
INTERCEPT_CLASS_HTTP_CLIENT_REQUEST
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
...
...
@@ -41,12 +45,12 @@ public class FilteringWebHandlerInstrumentation extends ClassInstanceMethodsEnha
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"h
andle
"
);
return
named
(
"h
eaders
"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.FilteringWebHandlerInterceptor"
;
return
Constants
.
HTTPCLIENT_REQUEST_HEADERS_INTERCEPTOR
;
}
@Override
...
...
@@ -56,10 +60,4 @@ public class FilteringWebHandlerInstrumentation extends ClassInstanceMethodsEnha
}
};
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
"org.springframework.cloud.gateway.handler.FilteringWebHandler"
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/NettyRoutingFilterInstrumentation.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v20x.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.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
NettyRoutingFilterInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
Constants
.
INTERCEPT_CLASS_NETTY_ROUTING_FILTER
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]
{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"filter"
).
and
(
takesArgumentWithType
(
0
,
"org.springframework.web.server.ServerWebExchange"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
Constants
.
NETTY_ROUTING_FILTER_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
true
;
}
}
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
7b99019c
# 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.
spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.NettyRoutingFilterInstrumentation
spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.HttpClientInstrumentation
spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.HttpClientRequestInstrumentation
\ No newline at end of file
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
浏览文件 @
7b99019c
...
...
@@ -26,10 +26,10 @@
<version>
8.0.0-SNAPSHOT
</version>
</parent>
<artifactId>
apm-spring-cloud-gateway-2.x-plugin
</artifactId>
<artifactId>
apm-spring-cloud-gateway-2.
1.
x-plugin
</artifactId>
<packaging>
jar
</packaging>
<name>
gateway-2.x-plugin
</name>
<name>
gateway-2.
1.
x-plugin
</name>
<url>
http://maven.apache.org
</url>
<properties>
...
...
@@ -44,6 +44,12 @@
<version>
${spring-cloud-starter-gateway.version}
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
io.projectreactor.netty
</groupId>
<artifactId>
reactor-netty
</artifactId>
<version>
0.8.11.RELEASE
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</project>
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java
已删除
100644 → 0
浏览文件 @
dacacf7b
/*
* 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.spring.cloud.gateway.v21x
;
import
static
org
.
springframework
.
cloud
.
gateway
.
support
.
ServerWebExchangeUtils
.
GATEWAY_ROUTE_ATTR
;
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.tag.Tags
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer
;
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
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter
;
import
org.springframework.cloud.gateway.route.Route
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
public
class
FilteringWebHandlerInterceptor
implements
InstanceMethodsAroundInterceptor
{
private
static
final
String
SPRING_CLOUD_GATEWAY_ROUTE_PREFIX
=
"GATEWAY/"
;
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
EnhancedInstance
instance
=
NettyRoutingFilterInterceptor
.
getInstance
(
allArguments
[
0
]);
if
(
instance
==
null
)
{
return
;
}
ContextSnapshot
contextSnapshot
=
(
ContextSnapshot
)
instance
.
getSkyWalkingDynamicField
();
if
(
contextSnapshot
==
null
)
{
return
;
}
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
String
operationName
=
SPRING_CLOUD_GATEWAY_ROUTE_PREFIX
;
Route
route
=
exchange
.
getRequiredAttribute
(
GATEWAY_ROUTE_ATTR
);
operationName
=
operationName
+
route
.
getId
();
SWTransmitter
transmitter
=
new
SWTransmitter
(
contextSnapshot
,
operationName
);
instance
.
setSkyWalkingDynamicField
(
transmitter
);
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
EnhancedInstance
instance
=
NettyRoutingFilterInterceptor
.
getInstance
(
allArguments
[
0
]);
if
(
instance
==
null
)
{
return
ret
;
}
SWTransmitter
swTransmitter
=
(
SWTransmitter
)
instance
.
getSkyWalkingDynamicField
();
if
(
swTransmitter
==
null
)
{
return
ret
;
}
Mono
<
Void
>
mono
=
(
Mono
)
ret
;
return
mono
.
doFinally
(
d
->
{
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
HttpStatus
statusCode
=
exchange
.
getResponse
().
getStatusCode
();
if
(
statusCode
==
HttpStatus
.
TOO_MANY_REQUESTS
)
{
AbstractSpan
localSpan
=
ContextManager
.
createLocalSpan
(
swTransmitter
.
getOperationName
());
Tags
.
STATUS_CODE
.
set
(
localSpan
,
statusCode
.
toString
());
SpanLayer
.
asHttp
(
localSpan
);
localSpan
.
setComponent
(
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
);
ContextManager
.
continued
(
swTransmitter
.
getSnapshot
());
ContextManager
.
stopSpan
(
localSpan
);
}
});
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/
DefaultHttpHeaders
Interceptor.java
→
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/
HttpClientFinalizerConstructor
Interceptor.java
浏览文件 @
7b99019c
/*
* 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
*
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.
*
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.spring.cloud.gateway.v21x
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.
context.Constants
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.
define.EnhanceObjectCache
;
public
class
DefaultHttpHeaders
Interceptor
implements
InstanceConstructorInterceptor
{
public
class
HttpClientFinalizerConstructor
Interceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
Object
transmitter
=
ContextManager
.
getRuntimeContext
().
get
(
Constants
.
SPRING_CLOUD_GATEWAY_TRANSMITTER
);
if
(
transmitter
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
transmitter
);
ContextManager
.
getRuntimeContext
().
remove
(
Constants
.
SPRING_CLOUD_GATEWAY_TRANSMITTER
);
EnhancedInstance
tcpClient
=
(
EnhancedInstance
)
allArguments
[
0
];
if
(
tcpClient
.
getSkyWalkingDynamicField
()
==
null
)
{
tcpClient
.
setSkyWalkingDynamicField
(
new
EnhanceObjectCache
());
}
objInst
.
setSkyWalkingDynamicField
(
tcpClient
.
getSkyWalkingDynamicField
());
}
}
\ No newline at end of file
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerResponseConnectionInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x
;
import
java.lang.reflect.Method
;
import
java.util.function.BiFunction
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
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.plugin.spring.cloud.gateway.v21x.define.EnhanceObjectCache
;
import
org.reactivestreams.Publisher
;
import
reactor.netty.Connection
;
import
reactor.netty.http.client.HttpClientResponse
;
public
class
HttpClientFinalizerResponseConnectionInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
BiFunction
<?
super
HttpClientResponse
,
?
super
Connection
,
?
extends
Publisher
>
finalReceiver
=
(
BiFunction
<?
super
HttpClientResponse
,
?
super
Connection
,
?
extends
Publisher
>)
allArguments
[
0
];
EnhanceObjectCache
cache
=
(
EnhanceObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
allArguments
[
0
]
=
new
BiFunction
<
HttpClientResponse
,
Connection
,
Publisher
>()
{
@Override
public
Publisher
apply
(
final
HttpClientResponse
response
,
final
Connection
connection
)
{
Publisher
publisher
=
finalReceiver
.
apply
(
response
,
connection
);
// receive the response. Stop the span.
if
(
cache
.
getSpan
()
!=
null
)
{
if
(
response
.
status
().
code
()
>=
400
)
{
cache
.
getSpan
().
errorOccurred
();
}
Tags
.
STATUS_CODE
.
set
(
cache
.
getSpan
(),
String
.
valueOf
(
response
.
status
().
code
()));
cache
.
getSpan
().
asyncFinish
();
}
if
(
cache
.
getSpan1
()
!=
null
)
{
cache
.
getSpan1
().
asyncFinish
();
}
return
publisher
;
}
};
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.function.BiFunction
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
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.plugin.spring.cloud.gateway.v21x.define.EnhanceObjectCache
;
import
org.apache.skywalking.apm.util.StringUtil
;
import
org.reactivestreams.Publisher
;
import
reactor.netty.NettyOutbound
;
import
reactor.netty.http.client.HttpClientRequest
;
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
public
class
HttpClientFinalizerSendInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
EnhanceObjectCache
enhanceObjectCache
=
(
EnhanceObjectCache
)
objInst
.
getSkyWalkingDynamicField
();
AbstractSpan
span
=
ContextManager
.
activeSpan
();
span
.
prepareForAsync
();
if
(!
StringUtil
.
isEmpty
(
enhanceObjectCache
.
getUrl
()))
{
URL
url
=
new
URL
(
enhanceObjectCache
.
getUrl
());
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
AbstractSpan
abstractSpan
=
ContextManager
.
createExitSpan
(
"SpringCloudGateway/sendRequest"
,
contextCarrier
,
getPeer
(
url
));
Tags
.
URL
.
set
(
abstractSpan
,
enhanceObjectCache
.
getUrl
());
abstractSpan
.
prepareForAsync
();
abstractSpan
.
setComponent
(
SPRING_CLOUD_GATEWAY
);
ContextManager
.
stopSpan
(
abstractSpan
);
ContextManager
.
stopSpan
(
span
);
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>
finalSender
=
(
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>)
allArguments
[
0
];
allArguments
[
0
]
=
new
BiFunction
<
HttpClientRequest
,
NettyOutbound
,
Publisher
<
Void
>>()
{
@Override
public
Publisher
<
Void
>
apply
(
HttpClientRequest
request
,
NettyOutbound
outbound
)
{
Publisher
publisher
=
finalSender
.
apply
(
request
,
outbound
);
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
request
.
requestHeaders
().
remove
(
next
.
getHeadKey
());
request
.
requestHeaders
().
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
return
publisher
;
}
};
enhanceObjectCache
.
setCacheSpan
(
abstractSpan
);
}
enhanceObjectCache
.
setSpan1
(
span
);
}
private
String
getPeer
(
URL
url
)
{
return
url
.
getHost
()
+
":"
+
url
.
getPort
();
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
((
EnhancedInstance
)
ret
).
setSkyWalkingDynamicField
(
objInst
.
getSkyWalkingDynamicField
());
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClient
OperationsHeaders
Interceptor.java
→
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClient
FinalizerURI
Interceptor.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v21x
;
import
org.apache.skywalking.apm.agent.core.logging.api.ILog
;
import
org.apache.skywalking.apm.agent.core.logging.api.LogManager
;
import
java.lang.reflect.Method
;
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.plugin.spring.cloud.gateway.v21x.define.EnhanceObjectCache
;
import
java.lang.reflect.Method
;
public
class
HttpClientOperationsHeadersInterceptor
implements
InstanceMethodsAroundInterceptor
{
private
static
final
ILog
logger
=
LogManager
.
getLogger
(
HttpClientOperationsHeadersInterceptor
.
class
);
public
class
HttpClientFinalizerURIInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
MethodInterceptResult
result
)
throws
Throwable
{
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
Object
transmitter
=
((
EnhancedInstance
)
allArguments
[
0
]).
getSkyWalkingDynamicField
();
if
(
transmitter
!=
null
)
{
objInst
.
setSkyWalkingDynamicField
(
transmitter
);
((
EnhancedInstance
)
allArguments
[
0
]).
setSkyWalkingDynamicField
(
null
);
Object
ret
)
throws
Throwable
{
if
(
ret
instanceof
EnhancedInstance
)
{
EnhanceObjectCache
enhanceObjectCache
=
(
EnhanceObjectCache
)
((
EnhancedInstance
)
ret
).
getSkyWalkingDynamicField
();
enhanceObjectCache
.
setUrl
(
String
.
valueOf
(
allArguments
[
0
]));
}
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsSendInterceptor.java
已删除
100644 → 0
浏览文件 @
dacacf7b
/*
* 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.spring.cloud.gateway.v21x
;
import
io.netty.handler.codec.http.HttpHeaders
;
import
org.apache.skywalking.apm.agent.core.context.CarrierItem
;
import
org.apache.skywalking.apm.agent.core.context.ContextCarrier
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer
;
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
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter
;
import
reactor.netty.channel.ChannelOperations
;
import
reactor.netty.http.client.HttpClientRequest
;
import
java.lang.reflect.Method
;
import
java.net.InetSocketAddress
;
public
class
HttpClientOperationsSendInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
SWTransmitter
transmitter
=
(
SWTransmitter
)
objInst
.
getSkyWalkingDynamicField
();
if
(
transmitter
!=
null
)
{
HttpClientRequest
request
=
(
HttpClientRequest
)
objInst
;
HttpHeaders
header
=
request
.
requestHeaders
();
ChannelOperations
channelOpt
=
(
ChannelOperations
)
objInst
;
InetSocketAddress
remote
=
(
InetSocketAddress
)
(
channelOpt
.
channel
().
remoteAddress
());
String
peer
=
remote
.
getHostName
()
+
":"
+
remote
.
getPort
();
AbstractSpan
span
=
ContextManager
.
createExitSpan
(
transmitter
.
getOperationName
(),
peer
);
ContextManager
.
continued
(
transmitter
.
getSnapshot
());
ContextCarrier
contextCarrier
=
new
ContextCarrier
();
ContextManager
.
inject
(
contextCarrier
);
span
.
setComponent
(
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
);
Tags
.
URL
.
set
(
span
,
peer
+
request
.
uri
());
Tags
.
HTTP
.
METHOD
.
set
(
span
,
request
.
method
().
name
());
SpanLayer
.
asHttp
(
span
);
CarrierItem
next
=
contextCarrier
.
items
();
while
(
next
.
hasNext
())
{
next
=
next
.
next
();
header
.
set
(
next
.
getHeadKey
(),
next
.
getHeadValue
());
}
transmitter
.
setSpanGateway
(
span
.
prepareForAsync
());
ContextManager
.
stopSpan
(
span
);
}
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsStatusInterceptor.java
已删除
100644 → 0
浏览文件 @
dacacf7b
/*
* 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.spring.cloud.gateway.v21x
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.tag.Tags
;
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.plugin.spring.cloud.gateway.v21x.context.SWTransmitter
;
import
java.lang.reflect.Method
;
public
class
HttpClientOperationsStatusInterceptor
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
{
SWTransmitter
transmitter
=
(
SWTransmitter
)
objInst
.
getSkyWalkingDynamicField
();
if
(
transmitter
!=
null
)
{
HttpResponseStatus
response
=
(
HttpResponseStatus
)
ret
;
if
(
response
.
code
()
>=
400
)
{
Tags
.
STATUS_CODE
.
set
(
transmitter
.
getSpanGateway
().
errorOccurred
(),
String
.
valueOf
(
response
.
code
()));
}
transmitter
.
getSpanGateway
().
asyncFinish
();
objInst
.
setSkyWalkingDynamicField
(
null
);
}
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v21x
;
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.plugin.spring.cloud.gateway.v21x.context.Constants
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter
;
import
org.springframework.web.server.ServerWebExchange
;
import
org.springframework.web.server.ServerWebExchangeDecorator
;
import
org.springframework.web.server.adapter.DefaultServerWebExchange
;
import
java.lang.reflect.Method
;
public
class
NettyRoutingFilterInterceptor
implements
InstanceMethodsAroundInterceptor
{
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
public
class
NettyRoutingFilterInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
EnhancedInstance
instance
=
NettyRoutingFilterInterceptor
.
getInstance
(
allArguments
[
0
]);
if
(
instance
!=
null
)
{
SWTransmitter
swTransmitter
=
(
SWTransmitter
)
instance
.
getSkyWalkingDynamicField
();
ContextManager
.
getRuntimeContext
().
put
(
Constants
.
SPRING_CLOUD_GATEWAY_TRANSMITTER
,
swTransmitter
);
}
}
MethodInterceptResult
result
)
throws
Throwable
{
ServerWebExchange
exchange
=
(
ServerWebExchange
)
allArguments
[
0
];
EnhancedInstance
enhancedInstance
=
getInstance
(
exchange
);
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
if
(
ContextManager
.
getRuntimeContext
().
get
(
Constants
.
SPRING_CLOUD_GATEWAY_TRANSMITTER
)
!=
null
)
{
ContextManager
.
getRuntimeContext
().
remove
(
Constants
.
SPRING_CLOUD_GATEWAY_TRANSMITTER
);
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
"SpringCloudGateway/RoutingFilter"
);
if
(
enhancedInstance
!=
null
&&
enhancedInstance
.
getSkyWalkingDynamicField
()
!=
null
)
{
ContextManager
.
continued
((
ContextSnapshot
)
enhancedInstance
.
getSkyWalkingDynamicField
());
}
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
span
.
setComponent
(
SPRING_CLOUD_GATEWAY
);
}
public
static
EnhancedInstance
getInstance
(
Object
o
)
{
EnhancedInstance
instance
=
null
;
if
(
o
instanceof
ServerWebExchangeDecorator
)
{
instance
=
getEnhancedInstance
((
ServerWebExchangeDecorator
)
o
);
}
else
if
(
o
instanceof
DefaultServerWebExchange
)
{
if
(
o
instanceof
DefaultServerWebExchange
)
{
instance
=
(
EnhancedInstance
)
o
;
}
else
if
(
o
instanceof
ServerWebExchangeDecorator
)
{
ServerWebExchange
delegate
=
((
ServerWebExchangeDecorator
)
o
).
getDelegate
();
return
getInstance
(
delegate
);
}
return
instance
;
}
private
static
EnhancedInstance
getEnhancedInstance
(
ServerWebExchangeDecorator
serverWebExchangeDecorator
)
{
Object
o
=
serverWebExchangeDecorator
.
getDelegate
();
if
(
o
instanceof
ServerWebExchangeDecorator
)
{
return
getEnhancedInstance
((
ServerWebExchangeDecorator
)
o
);
}
else
if
(
o
instanceof
DefaultServerWebExchange
)
{
return
(
EnhancedInstance
)
o
;
}
else
if
(
o
==
null
)
{
throw
new
NullPointerException
(
"The expected class DefaultServerWebExchange is null"
);
}
else
{
throw
new
RuntimeException
(
"Unknown parameter types:"
+
o
.
getClass
());
}
@Override
public
Object
afterMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Object
ret
)
throws
Throwable
{
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
errorOccurred
().
log
(
t
);
}
}
\ No newline at end of file
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/TcpClientConstructorInterceptor.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor
;
public
class
TcpClientConstructorInterceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/SWTransmitter.java
已删除
100644 → 0
浏览文件 @
dacacf7b
/*
* 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.spring.cloud.gateway.v21x.context
;
import
org.apache.skywalking.apm.agent.core.context.ContextSnapshot
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
public
class
SWTransmitter
{
private
AbstractSpan
spanGateway
;
private
ContextSnapshot
snapshot
;
private
String
operationName
;
public
SWTransmitter
(
ContextSnapshot
snapshot
,
String
operationName
)
{
this
.
snapshot
=
snapshot
;
this
.
operationName
=
operationName
;
}
public
AbstractSpan
getSpanGateway
()
{
return
spanGateway
;
}
public
void
setSpanGateway
(
AbstractSpan
spanGateway
)
{
this
.
spanGateway
=
spanGateway
;
}
public
ContextSnapshot
getSnapshot
()
{
return
snapshot
;
}
public
void
setSnapshot
(
ContextSnapshot
snapshot
)
{
this
.
snapshot
=
snapshot
;
}
public
String
getOperationName
()
{
return
operationName
;
}
public
void
setOperationName
(
String
operationName
)
{
this
.
operationName
=
operationName
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/AbstractGateway210EnhancePluginDefine.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
public
abstract
class
AbstractGateway210EnhancePluginDefine
extends
ClassInstanceMethodsEnhancePluginDefine
{
@Override
protected
String
[]
witnessClasses
()
{
return
new
String
[]
{
"org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor"
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/Constants.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x.define
;
public
interface
Constants
{
// HttpClientFinalizer
String
INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER
=
"reactor.netty.http.client.HttpClientFinalizer"
;
String
CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerConstructorInterceptor"
;
String
HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerSendInterceptor"
;
String
HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerURIInterceptor"
;
String
HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerResponseConnectionInterceptor"
;
// NettyRoutingFilter
String
INTERCEPT_CLASS_NETTY_ROUTING_FILTER
=
"org.springframework.cloud.gateway.filter.NettyRoutingFilter"
;
String
NETTY_ROUTING_FILTER_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.NettyRoutingFilterInterceptor"
;
// TcpClient
String
INTERCEPT_CLASS_TCP_CLIENT
=
"reactor.netty.tcp.TcpClient"
;
String
TCP_CLIENT_CONSTRUCTOR_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.TcpClientConstructorInterceptor"
;
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/EnhanceObjectCache.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.spring.cloud.gateway.v21x.define
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
public
class
EnhanceObjectCache
{
private
String
url
;
private
AbstractSpan
span
;
private
AbstractSpan
span1
;
public
String
getUrl
()
{
return
url
;
}
public
void
setUrl
(
String
url
)
{
this
.
url
=
url
;
}
public
void
setCacheSpan
(
AbstractSpan
span
)
{
this
.
span
=
span
;
}
public
AbstractSpan
getSpan
()
{
return
span
;
}
public
void
setSpan1
(
final
AbstractSpan
span
)
{
span1
=
span
;
}
public
AbstractSpan
getSpan1
()
{
return
span1
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClient
Operations
Instrumentation.java
→
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClient
Finalizer
Instrumentation.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v21x.define
;
...
...
@@ -22,18 +21,34 @@ 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.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
HttpClientOperationsInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
HttpClientFinalizerInstrumentation
extends
AbstractGateway210EnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
Constants
.
INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[
0
];
return
new
ConstructorInterceptPoint
[]
{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
takesArgumentWithType
(
0
,
"reactor.netty.tcp.TcpClient"
);
}
@Override
public
String
getConstructorInterceptor
()
{
return
Constants
.
CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR
;
}
}
};
}
@Override
...
...
@@ -42,28 +57,28 @@ public class HttpClientOperationsInstrumentation extends ClassInstanceMethodsEnh
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"
headers"
).
and
(
takesArgumentWithType
(
0
,
"io.netty.handler.codec.http.HttpHeaders"
)
);
return
named
(
"
send"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsHeadersInterceptor"
;
return
Constants
.
HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
fals
e
;
return
tru
e
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"
send"
).
and
(
takesArgumentWithType
(
0
,
"org.reactivestreams.Publisher"
)
);
return
named
(
"
uri"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsSendInterceptor"
;
return
Constants
.
HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR
;
}
@Override
...
...
@@ -74,24 +89,19 @@ public class HttpClientOperationsInstrumentation extends ClassInstanceMethodsEnh
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"
status
"
);
return
named
(
"
responseConnection
"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsStatusInterceptor"
;
return
Constants
.
HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
fals
e
;
return
tru
e
;
}
},
};
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
"reactor.netty.http.client.HttpClientOperations"
);
}
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v21x.define
;
...
...
@@ -22,14 +21,18 @@ 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.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
named
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
NettyRoutingFilterInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
NettyRoutingFilterInstrumentation
extends
AbstractGateway210EnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
Constants
.
INTERCEPT_CLASS_NETTY_ROUTING_FILTER
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
...
...
@@ -42,32 +45,20 @@ public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhan
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"filter"
).
and
(
takesArgumentWithType
(
0
,
"org.springframework.web.server.ServerWebExchange"
));
return
named
(
"filter"
).
and
(
takesArgumentWithType
(
0
,
"org.springframework.web.server.ServerWebExchange"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.NettyRoutingFilterInterceptor"
;
return
Constants
.
NETTY_ROUTING_FILTER_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
fals
e
;
return
tru
e
;
}
}
};
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
"org.springframework.cloud.gateway.filter.NettyRoutingFilter"
);
}
@Override
protected
final
String
[]
witnessClasses
()
{
return
new
String
[]
{
"org.springframework.cloud.gateway.handler.FilteringWebHandler"
,
"reactor.netty.http.client.HttpClientOperations"
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/
DefaultHttpHeaders
Instrumentation.java
→
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/
TcpClient
Instrumentation.java
浏览文件 @
7b99019c
/*
* 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
*
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.
* 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.spring.cloud.gateway.v21x.define
;
...
...
@@ -22,13 +21,17 @@ 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.InstanceMethodsInterceptPoint
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
import
org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
bytebuddy
.
ArgumentTypeNameMatch
.
takesArgumentWithType
;
import
static
net
.
bytebuddy
.
matcher
.
ElementMatchers
.
any
;
import
static
org
.
apache
.
skywalking
.
apm
.
agent
.
core
.
plugin
.
match
.
NameMatch
.
byName
;
public
class
DefaultHttpHeadersInstrumentation
extends
ClassInstanceMethodsEnhancePluginDefine
{
public
class
TcpClientInstrumentation
extends
AbstractGateway210EnhancePluginDefine
{
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
Constants
.
INTERCEPT_CLASS_TCP_CLIENT
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
...
...
@@ -36,12 +39,12 @@ public class DefaultHttpHeadersInstrumentation extends ClassInstanceMethodsEnhan
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
takesArgumentWithType
(
0
,
"io.netty.handler.codec.DefaultHeaders"
);
return
any
(
);
}
@Override
public
String
getConstructorInterceptor
()
{
return
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.DefaultHttpHeadersInterceptor"
;
return
Constants
.
TCP_CLIENT_CONSTRUCTOR_INTERCEPTOR
;
}
}
};
...
...
@@ -51,9 +54,4 @@ public class DefaultHttpHeadersInstrumentation extends ClassInstanceMethodsEnhan
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[
0
];
}
@Override
public
ClassMatch
enhanceClass
()
{
return
byName
(
"io.netty.handler.codec.http.DefaultHttpHeaders"
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def
浏览文件 @
7b99019c
...
...
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.DefaultHttpHeadersInstrumentation
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.HttpClientOperationsInstrumentation
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.HttpClientFinalizerInstrumentation
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.NettyRoutingFilterInstrumentation
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.FilteringWebHandlerInstrumentation
\ No newline at end of file
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.TcpClientInstrumentation
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
浏览文件 @
7b99019c
...
...
@@ -28,6 +28,7 @@
<artifactId>
optional-spring-cloud
</artifactId>
<modules>
<module>
gateway-2.0.x-plugin
</module>
<module>
gateway-2.1.x-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
docs/en/guides/Plugin-test.md
浏览文件 @
7b99019c
...
...
@@ -188,7 +188,7 @@ as the version number, it will be changed in the test for every version.
**Take following test cases as examples**
*
[
dubbo-2.7.x with JVM-container
](
../../../test/plugin/scenarios/dubbo-2.7.x-scenario/configuration.yml
)
*
[
jetty with JVM-container
](
../../../test/plugin/scenarios/jetty-scenario/configuration.yml
)
*
[
gateway with runningMode
](
../../../test/plugin/scenarios/gateway-scenario/configuration.yml
)
*
[
gateway with runningMode
](
../../../test/plugin/scenarios/gateway-
2.1.x-
scenario/configuration.yml
)
*
[
canal with docker-compose
](
../../../test/plugin/scenarios/canal-scenario/configuration.yml
)
### expectedData.yaml
...
...
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
7b99019c
...
...
@@ -24,7 +24,7 @@
*
[
Jetty Client
](
http://www.eclipse.org/jetty/
)
9
*
[
Apache httpcomponent AsyncClient
](
https://hc.apache.org/httpcomponents-asyncclient-dev/
)
4.x
*
HTTP Gateway
*
[
Spring Cloud Gateway
](
https://spring.io/projects/spring-cloud-gateway
)
2.
1
.x.RELEASE (Optional²)
*
[
Spring Cloud Gateway
](
https://spring.io/projects/spring-cloud-gateway
)
2.
0.2.RELEASE -> 2.2
.x.RELEASE (Optional²)
*
JDBC
*
Mysql Driver 5.x, 6.x, 8.x
*
Oracle Driver (Optional¹)
...
...
test/plugin/scenarios/gateway-scenario/config/expectedData.yaml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/config/expectedData.yaml
浏览文件 @
7b99019c
...
...
@@ -34,8 +34,8 @@ segmentItems:
-
{
key
:
url
,
value
:
not null
}
-
{
key
:
http.method
,
value
:
GET
}
refs
:
-
{
parentEndpoint
:
GATEWAY/provider_route
,
networkAddress
:
'
localhost:18070'
,
refType
:
CrossProcess
,
parentSpanId
:
0
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
-
{
parentEndpoint
:
SpringCloudGateway/RoutingFilter
,
networkAddress
:
'
localhost:18070'
,
refType
:
CrossProcess
,
parentSpanId
:
1
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
null
,
parentService
:
not null
,
traceId
:
not null
}
skipAnalysis
:
'
false'
-
serviceName
:
gateway-projectA-scenario
...
...
@@ -43,40 +43,50 @@ segmentItems:
segments
:
-
segmentId
:
not
null
spans
:
-
operationName
:
GATEWAY/provider_rout
e
-
operationName
:
/provider/b/testcas
e
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Http
startTime
:
nq
0
endTime
:
nq
0
componentId
:
6
1
componentId
:
6
7
isError
:
false
spanType
:
E
xit
spanType
:
E
ntry
peer
:
not
null
tags
:
-
{
key
:
url
,
value
:
not null
}
-
{
key
:
url
,
value
:
'
http://localhost:8080/provider/b/testcase'
}
-
{
key
:
http.method
,
value
:
GET
}
refs
:
-
{
parentEndpoint
:
WEBFLUX.handle
,
networkAddress
:
'
'
,
refType
:
CrossThread
,
parentSpanId
:
0
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
null
,
parentService
:
not null
,
traceId
:
not null
}
-
{
key
:
status_code
,
value
:
'
200'
}
skipAnalysis
:
'
false'
-
segmentId
:
not
null
spans
:
-
operationName
:
WEBFLUX.handle
-
operationName
:
SpringCloudGateway/sendRequest
operationId
:
0
parentSpanId
:
0
spanId
:
1
startTime
:
nq
0
endTime
:
nq
0
componentId
:
61
isError
:
false
spanType
:
Exit
peer
:
'
localhost:18070'
tags
:
-
{
key
:
url
,
value
:
not null
}
-
{
key
:
status_code
,
value
:
'
200'
}
skipAnalysis
:
'
false'
-
operationName
:
SpringCloudGateway/RoutingFilter
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Http
startTime
:
nq
0
endTime
:
nq
0
componentId
:
6
7
componentId
:
6
1
isError
:
false
spanType
:
Entry
spanType
:
Local
peer
:
'
'
tag
s
:
-
{
key
:
url
,
value
:
'
http://localhost:8080/provider/b/testcase'
}
-
{
key
:
http.method
,
value
:
GET
}
-
{
key
:
status_code
,
value
:
'
200'
}
ref
s
:
-
{
parentEndpoint
:
'
/provider/b/testcase'
,
networkAddress
:
'
'
,
refType
:
CrossThread
,
parentSpanId
:
0
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
null
,
parentService
:
not null
,
traceId
:
not null
}
skipAnalysis
:
'
false'
test/plugin/scenarios/gateway-scenario/configuration.yml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/configuration.yml
浏览文件 @
7b99019c
...
...
@@ -19,4 +19,4 @@ entryService: http://localhost:8080/provider/b/testcase
healthCheck
:
http://localhost:8080/provider/b/healthCheck
startScript
:
./bin/startup.sh
runningMode
:
with_optional
withPlugins
:
apm-spring-cloud-gateway-2.x-plugin-*.jar
withPlugins
:
apm-spring-cloud-gateway-2.
0.
x-plugin-*.jar
test/plugin/scenarios/gateway-scenario/gateway-dist/bin/startup.sh
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-dist/bin/startup.sh
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-dist/pom.xml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-dist/pom.xml
浏览文件 @
7b99019c
...
...
@@ -21,7 +21,7 @@
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-scenario
</artifactId>
<artifactId>
gateway-
2.0.x-
scenario
</artifactId>
<version>
5.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
test/plugin/scenarios/gateway-scenario/gateway-dist/src/main/assembly/assembly.xml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-dist/src/main/assembly/assembly.xml
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/pom.xml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/pom.xml
浏览文件 @
7b99019c
...
...
@@ -21,7 +21,7 @@
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-scenario
</artifactId>
<artifactId>
gateway-
2.0.x-
scenario
</artifactId>
<version>
5.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
@@ -34,12 +34,6 @@
<artifactId>
spring-cloud-starter-gateway
</artifactId>
<version>
${test.framework.version}
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<version>
2.1.2.RELEASE
</version>
</dependency>
</dependencies>
<build>
...
...
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/resources/application.yml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectA-scenario/src/main/resources/application.yml
浏览文件 @
7b99019c
...
...
@@ -25,12 +25,3 @@ spring:
uri
:
http://localhost:18070
predicates
:
-
Path=/provider/b/*
filters
:
-
name
:
RequestRateLimiter
args
:
redis-rate-limiter.replenishRate
:
1
redis-rate-limiter.burstCapacity
:
1
key-resolver
:
"
#{@apiKeyResolver}"
redis
:
host
:
127.0.0.1
port
:
6379
test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/pom.xml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectB-scenario/pom.xml
浏览文件 @
7b99019c
...
...
@@ -20,7 +20,7 @@
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>
gateway-scenario
</artifactId>
<artifactId>
gateway-
2.0.x-
scenario
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
<version>
5.0.0
</version>
</parent>
...
...
test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/resources/application.properties
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/gateway-projectB-scenario/src/main/resources/application.properties
浏览文件 @
7b99019c
文件已移动
test/plugin/scenarios/gateway-scenario/pom.xml
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/pom.xml
浏览文件 @
7b99019c
...
...
@@ -22,7 +22,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-scenario
</artifactId>
<artifactId>
gateway-
2.0.x-
scenario
</artifactId>
<packaging>
pom
</packaging>
<version>
5.0.0
</version>
<modules>
...
...
@@ -31,16 +31,16 @@
<module>
gateway-dist
</module>
</modules>
<name>
skywalking-gateway-scenario
</name>
<name>
skywalking-gateway-
2.0.x-
scenario
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<test.framework.version>
2.
1.1
.RELEASE
</test.framework.version>
<test.framework.version>
2.
0.2
.RELEASE
</test.framework.version>
<docker.image.version>
${test.framework.version}
</docker.image.version>
</properties>
<build>
<finalName>
gateway-scenario
</finalName>
<finalName>
gateway-
2.0.x-
scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
test/plugin/scenarios/gateway-scenario/support-version.list
→
test/plugin/scenarios/gateway-
2.0.x-
scenario/support-version.list
浏览文件 @
7b99019c
...
...
@@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
2.
1
.2.RELEASE
2.
1.1
.RELEASE
2.
1.0
.RELEASE
2.
0
.2.RELEASE
2.
0.3
.RELEASE
2.
0.4
.RELEASE
\ No newline at end of file
test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
0 → 100644
浏览文件 @
7b99019c
# 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.
segmentItems
:
-
serviceName
:
gateway-projectB-scenario
segmentSize
:
nq
0
segments
:
-
segmentId
:
not
null
spans
:
-
operationName
:
/provider/b/testcase
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Http
startTime
:
nq
0
endTime
:
nq
0
componentId
:
nq
0
isError
:
false
spanType
:
Entry
peer
:
'
'
tags
:
-
{
key
:
url
,
value
:
not null
}
-
{
key
:
http.method
,
value
:
GET
}
refs
:
-
{
parentEndpoint
:
SpringCloudGateway/RoutingFilter
,
networkAddress
:
'
localhost:18070'
,
refType
:
CrossProcess
,
parentSpanId
:
1
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
null
,
parentService
:
not null
,
traceId
:
not null
}
skipAnalysis
:
'
false'
-
serviceName
:
gateway-projectA-scenario
segmentSize
:
nq
0
segments
:
-
segmentId
:
not
null
spans
:
-
operationName
:
/provider/b/testcase
operationId
:
0
parentSpanId
:
-1
spanId
:
0
spanLayer
:
Http
startTime
:
nq
0
endTime
:
nq
0
componentId
:
67
isError
:
false
spanType
:
Entry
peer
:
not
null
tags
:
-
{
key
:
url
,
value
:
'
http://localhost:8080/provider/b/testcase'
}
-
{
key
:
http.method
,
value
:
GET
}
-
{
key
:
status_code
,
value
:
'
200'
}
skipAnalysis
:
'
false'
-
segmentId
:
not
null
spans
:
-
operationName
:
SpringCloudGateway/sendRequest
operationId
:
0
parentSpanId
:
0
spanId
:
1
startTime
:
nq
0
endTime
:
nq
0
componentId
:
61
isError
:
false
spanType
:
Exit
peer
:
'
localhost:18070'
tags
:
-
{
key
:
url
,
value
:
not null
}
-
{
key
:
status_code
,
value
:
'
200'
}
skipAnalysis
:
'
false'
-
operationName
:
SpringCloudGateway/RoutingFilter
operationId
:
0
parentSpanId
:
-1
spanId
:
0
startTime
:
nq
0
endTime
:
nq
0
componentId
:
61
isError
:
false
spanType
:
Local
peer
:
'
'
refs
:
-
{
parentEndpoint
:
'
/provider/b/testcase'
,
networkAddress
:
'
'
,
refType
:
CrossThread
,
parentSpanId
:
0
,
parentTraceSegmentId
:
not null
,
parentServiceInstance
:
not
null
,
parentService
:
not null
,
traceId
:
not null
}
skipAnalysis
:
'
false'
test/plugin/scenarios/gateway-2.1.x-scenario/configuration.yml
0 → 100644
浏览文件 @
7b99019c
# 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.
type
:
jvm
entryService
:
http://localhost:8080/provider/b/testcase
healthCheck
:
http://localhost:8080/provider/b/healthCheck
startScript
:
./bin/startup.sh
runningMode
:
with_optional
withPlugins
:
apm-spring-cloud-gateway-2.1.x-plugin-*.jar
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh
0 → 100644
浏览文件 @
7b99019c
#!/bin/bash
#
# 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.
home
=
"
$(
cd
"
$(
dirname
$0
)
"
;
pwd
)
"
java
-jar
${
agent_opts
}
"-Dskywalking.agent.service_name=gateway-projectA-scenario"
${
home
}
/../libs/gateway-projectA-scenario.jar &
sleep
1
java
-jar
${
agent_opts
}
"-Dskywalking.agent.service_name=gateway-projectB-scenario"
${
home
}
/../libs/gateway-projectB-scenario.jar &
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-2.1.x-scenario
</artifactId>
<version>
5.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
gateway-dist
</artifactId>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-assembly-plugin
</artifactId>
<executions>
<execution>
<id>
assemble
</id>
<phase>
package
</phase>
<goals>
<goal>
single
</goal>
</goals>
<configuration>
<descriptors>
<descriptor>
src/main/assembly/assembly.xml
</descriptor>
</descriptors>
<outputDirectory>
../target/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/src/main/assembly/assembly.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<assembly
xmlns=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"
>
<formats>
<format>
zip
</format>
</formats>
<fileSets>
<fileSet>
<directory>
./bin
</directory>
<fileMode>
0775
</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>
../gateway-projectA-scenario/target/gateway-projectA-scenario.jar
</source>
<outputDirectory>
./libs
</outputDirectory>
<fileMode>
0775
</fileMode>
</file>
<file>
<source>
../gateway-projectB-scenario/target/gateway-projectB-scenario.jar
</source>
<outputDirectory>
./libs
</outputDirectory>
<fileMode>
0775
</fileMode>
</file>
</files>
</assembly>
\ No newline at end of file
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-2.1.x-scenario
</artifactId>
<version>
5.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
gateway-projectA-scenario
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-gateway
</artifactId>
<version>
${test.framework.version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
gateway-projectA-scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
1.5.9.RELEASE
</version>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>
spring-snapshots
</id>
<url>
http://repo.spring.io/snapshot
</url>
</pluginRepository>
<pluginRepository>
<id>
spring-milestones
</id>
<url>
http://repo.spring.io/milestone
</url>
</pluginRepository>
</pluginRepositories>
</project>
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/Constants
.java
→
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver
.java
浏览文件 @
7b99019c
...
...
@@ -16,8 +16,17 @@
*
*/
package
org.apache.skywalking.apm.
plugin.spring.cloud.gateway.v21x.context
;
package
org.apache.skywalking.apm.
testcase.sc.gateway.projectA
;
public
interface
Constants
{
String
SPRING_CLOUD_GATEWAY_TRANSMITTER
=
"spring.cloud.gateway.transmitter"
;
import
org.springframework.cloud.gateway.filter.ratelimit.KeyResolver
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
@Component
public
class
ApiKeyResolver
implements
KeyResolver
{
public
Mono
<
String
>
resolve
(
ServerWebExchange
exchange
)
{
return
Mono
.
just
(
exchange
.
getRequest
().
getPath
().
value
());
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectA
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
@SpringBootApplication
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectA
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.core.Ordered
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
public
class
Test1Filter
implements
GlobalFilter
,
Ordered
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
ServerHttpRequest
buildRequest
=
exchange
.
getRequest
().
mutate
().
build
();
return
chain
.
filter
(
exchange
.
mutate
().
request
(
buildRequest
).
build
());
}
@Override
public
int
getOrder
()
{
return
0
;
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectA
;
import
org.springframework.cloud.gateway.filter.GatewayFilterChain
;
import
org.springframework.cloud.gateway.filter.GlobalFilter
;
import
org.springframework.core.Ordered
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
public
class
Test2Filter
implements
GlobalFilter
,
Ordered
{
@Override
public
Mono
<
Void
>
filter
(
ServerWebExchange
exchange
,
GatewayFilterChain
chain
)
{
ServerHttpRequest
buildRequest
=
exchange
.
getRequest
().
mutate
().
build
();
return
chain
.
filter
(
exchange
.
mutate
().
request
(
buildRequest
).
build
());
}
@Override
public
int
getOrder
()
{
return
1
;
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectA
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
TestFilterConfig
{
@Bean
public
Test1Filter
test1Filter
()
{
return
new
Test1Filter
();
}
@Bean
public
Test2Filter
test2Filter
()
{
return
new
Test2Filter
();
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
0 → 100644
浏览文件 @
7b99019c
#
# 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.
#
server
:
port
:
8080
spring
:
cloud
:
gateway
:
routes
:
-
id
:
provider_route
uri
:
http://localhost:18070
predicates
:
-
Path=/provider/b/*
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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>
gateway-2.1.x-scenario
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
<version>
5.0.0
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
gateway-projectB-scenario
</artifactId>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
<version>
2.1.0.RELEASE
</version>
</dependency>
</dependencies>
<build>
<finalName>
gateway-projectB-scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<version>
1.5.9.RELEASE
</version>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectB
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.ComponentScan
;
@SpringBootApplication
@ComponentScan
(
value
=
{
"org.apache.skywalking.apm.testcase.sc.gateway.projectB.controller"
})
public
class
Application
{
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
Application
.
class
,
args
);
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
0 → 100644
浏览文件 @
7b99019c
/*
* 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.testcase.sc.gateway.projectB.controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
public
class
TestController
{
@RequestMapping
(
"/provider/b/testcase"
)
public
String
testcase
()
{
System
.
out
.
println
(
1
);
return
"1"
;
}
@RequestMapping
(
"/provider/b/healthCheck"
)
public
String
healthCheck
()
{
return
"Success"
;
}
}
test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
0 → 100644
浏览文件 @
7b99019c
#
# 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.
#
server.port
=
18070
\ No newline at end of file
test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml
0 → 100644
浏览文件 @
7b99019c
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.apache.skywalking
</groupId>
<artifactId>
gateway-2.1.x-scenario
</artifactId>
<packaging>
pom
</packaging>
<version>
5.0.0
</version>
<modules>
<module>
gateway-projectA-scenario
</module>
<module>
gateway-projectB-scenario
</module>
<module>
gateway-dist
</module>
</modules>
<name>
skywalking-gateway-2.1.x-scenario
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<test.framework.version>
2.0.2.RELEASE
</test.framework.version>
<docker.image.version>
${test.framework.version}
</docker.image.version>
</properties>
<build>
<finalName>
gateway-2.1.x-scenario
</finalName>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.6.0
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
<encoding>
${project.build.sourceEncoding}
</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
test/plugin/scenarios/gateway-2.1.x-scenario/support-version.list
0 → 100644
浏览文件 @
7b99019c
# 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.
2.1.2.RELEASE
2.1.1.RELEASE
2.1.0.RELEASE
2.2.0.RELEASE
2.2.1.RELEASE
2.2.2.RELEASE
2.2.3.RELEASE
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录