Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
SkyWalking
提交
edc154c4
S
SkyWalking
项目概览
apache
/
SkyWalking
上一次同步 大约 1 年
通知
302
Star
21345
Fork
6091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SkyWalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
edc154c4
编写于
5月 02, 2021
作者:
Z
ZhangZhaoyuan
提交者:
GitHub
5月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add spring cloud gateway 3.x plugin (#6881)
上级
63ea62f2
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
2100 addition
and
1 deletion
+2100
-1
.github/workflows/plugins-test.3.yaml
.github/workflows/plugins-test.3.yaml
+1
-0
CHANGES.md
CHANGES.md
+1
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/pom.xml
...-plugins/optional-spring-cloud/gateway-3.x-plugin/pom.xml
+80
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerConstructorInterceptor.java
...ateway/v3x/HttpClientFinalizerConstructorInterceptor.java
+43
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerResponseConnectionInterceptor.java
...v3x/HttpClientFinalizerResponseConnectionInterceptor.java
+77
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerSendInterceptor.java
...cloud/gateway/v3x/HttpClientFinalizerSendInterceptor.java
+105
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerUriInterceptor.java
.../cloud/gateway/v3x/HttpClientFinalizerUriInterceptor.java
+52
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/NettyRoutingFilterInterceptor.java
...ring/cloud/gateway/v3x/NettyRoutingFilterInterceptor.java
+76
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/AbstractGatewayV3EnhancePluginDefine.java
...eway/v3x/define/AbstractGatewayV3EnhancePluginDefine.java
+32
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/DispatcherHandlerInstrumentation.java
.../gateway/v3x/define/DispatcherHandlerInstrumentation.java
+32
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/EnhanceObjectCache.java
...n/spring/cloud/gateway/v3x/define/EnhanceObjectCache.java
+54
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/HttpClientFinalizerInstrumentation.java
...ateway/v3x/define/HttpClientFinalizerInstrumentation.java
+121
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/NettyRoutingFilterInstrumentation.java
...gateway/v3x/define/NettyRoutingFilterInstrumentation.java
+75
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/ServerWebExchangeInstrumentation.java
.../gateway/v3x/define/ServerWebExchangeInstrumentation.java
+32
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/resources/skywalking-plugin.def
...teway-3.x-plugin/src/main/resources/skywalking-plugin.def
+20
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerConstructorInterceptorTest.java
...ay/v3x/HttpClientFinalizerConstructorInterceptorTest.java
+70
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerInterceptorTest.java
...cloud/gateway/v3x/HttpClientFinalizerInterceptorTest.java
+171
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/MockCliengRequest.java
...pm/plugin/spring/cloud/gateway/v3x/MockCliengRequest.java
+125
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/MockClientResponse.java
...m/plugin/spring/cloud/gateway/v3x/MockClientResponse.java
+104
-0
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/NettyRoutingFilterInterceptorTest.java
.../cloud/gateway/v3x/NettyRoutingFilterInterceptorTest.java
+104
-0
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/setup/service-agent/java-agent/Plugin-list.md
docs/en/setup/service-agent/java-agent/Plugin-list.md
+1
-0
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-3.x-scenario/config/expectedData.yaml
...n/scenarios/gateway-3.x-scenario/config/expectedData.yaml
+93
-0
test/plugin/scenarios/gateway-3.x-scenario/configuration.yml
test/plugin/scenarios/gateway-3.x-scenario/configuration.yml
+22
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-dist/bin/startup.sh
...cenarios/gateway-3.x-scenario/gateway-dist/bin/startup.sh
+24
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-dist/pom.xml
...lugin/scenarios/gateway-3.x-scenario/gateway-dist/pom.xml
+54
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-dist/src/main/assembly/assembly.xml
...-3.x-scenario/gateway-dist/src/main/assembly/assembly.xml
+46
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/pom.xml
...os/gateway-3.x-scenario/gateway-projectA-scenario/pom.xml
+67
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
...king/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
+31
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
...walking/apm/testcase/sc/gateway/projectA/Application.java
+29
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test1Filter.java
+38
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
...walking/apm/testcase/sc/gateway/projectA/Test2Filter.java
+39
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
...ng/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
+35
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
...eway-projectA-scenario/src/main/resources/application.yml
+27
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectB-scenario/pom.xml
...os/gateway-3.x-scenario/gateway-projectB-scenario/pom.xml
+57
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectB-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
...walking/apm/testcase/sc/gateway/projectB/Application.java
+31
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectB-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
...stcase/sc/gateway/projectB/controller/TestController.java
+35
-0
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
...ojectB-scenario/src/main/resources/application.properties
+17
-0
test/plugin/scenarios/gateway-3.x-scenario/pom.xml
test/plugin/scenarios/gateway-3.x-scenario/pom.xml
+58
-0
test/plugin/scenarios/gateway-3.x-scenario/support-version.list
...lugin/scenarios/gateway-3.x-scenario/support-version.list
+19
-0
未找到文件。
.github/workflows/plugins-test.3.yaml
浏览文件 @
edc154c4
...
...
@@ -72,6 +72,7 @@ jobs:
-
thrift-scenario
-
dbcp-2.x-scenario
-
jsonrpc4j-1.x-scenario
-
gateway-3.x-scenario
steps
:
-
uses
:
actions/checkout@v2
with
:
...
...
CHANGES.md
浏览文件 @
edc154c4
...
...
@@ -21,6 +21,7 @@ Release Notes.
*
Add
`MessageListener`
enhancement in pulsar plugin.
*
fix a bug that spring-mvc set an error endpoint name if the controller class annotation implements an interface.
*
Add an optional agent plugin to support mybatis.
*
Add
`spring-cloud-gateway-3.x`
optional plugin.
#### OAP-Backend
*
BugFix: filter invalid Envoy access logs whose socket address is empty.
...
...
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/pom.xml
0 → 100644
浏览文件 @
edc154c4
<?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>
optional-spring-cloud
</artifactId>
<groupId>
org.apache.skywalking
</groupId>
<version>
8.6.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
apm-spring-cloud-gateway-3.x-plugin
</artifactId>
<packaging>
jar
</packaging>
<url>
http://maven.apache.org
</url>
<properties>
<spring-cloud-starter-gateway.version>
3.0.0
</spring-cloud-starter-gateway.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>
org.apache.skywalking
</groupId>
<artifactId>
apm-spring-webflux-5.x-plugin
</artifactId>
<version>
${project.version}
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-shade-plugin
</artifactId>
<version>
3.2.4
</version>
<executions>
<execution>
<phase>
package
</phase>
<goals>
<goal>
shade
</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>
org.apache.skywalking:apm-spring-webflux-5.x-plugin
</artifact>
<excludes>
<exclude>
skywalking-plugin.def
</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerConstructorInterceptor.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
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.v3x.define.EnhanceObjectCache
;
import
reactor.netty.http.client.HttpClientConfig
;
/**
* Intercept the constructor and inject {@link EnhanceObjectCache}.
* <p>
* The first constructor argument is {@link reactor.netty.http.client.HttpClientConfig} class instance which can get the
* request uri string.
*/
public
class
HttpClientFinalizerConstructorInterceptor
implements
InstanceConstructorInterceptor
{
@Override
public
void
onConstruct
(
EnhancedInstance
objInst
,
Object
[]
allArguments
)
{
final
HttpClientConfig
httpClientConfig
=
(
HttpClientConfig
)
allArguments
[
0
];
if
(
httpClientConfig
==
null
)
{
return
;
}
final
EnhanceObjectCache
enhanceObjectCache
=
new
EnhanceObjectCache
();
enhanceObjectCache
.
setUrl
(
httpClientConfig
.
uri
());
objInst
.
setSkyWalkingDynamicField
(
enhanceObjectCache
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerResponseConnectionInterceptor.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
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.v3x.define.EnhanceObjectCache
;
import
org.reactivestreams.Publisher
;
import
reactor.netty.Connection
;
import
reactor.netty.http.client.HttpClientResponse
;
import
java.lang.reflect.Method
;
import
java.util.function.BiFunction
;
/**
* This class intercept <code>responseConnection</code> method.
* <p>
* After downstream service response, finish the span in the {@link EnhanceObjectCache}.
*/
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
]
=
(
BiFunction
<
HttpClientResponse
,
Connection
,
Publisher
>)
(
response
,
connection
)
->
{
Publisher
publisher
=
finalReceiver
.
apply
(
response
,
connection
);
if
(
cache
==
null
)
{
return
publisher
;
}
// receive the response. Stop the span.
if
(
cache
.
getSpan
()
!=
null
)
{
if
(
response
.
status
().
code
()
>=
HttpResponseStatus
.
BAD_REQUEST
.
code
())
{
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-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerSendInterceptor.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
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.plugin.spring.cloud.gateway.v3x.define.EnhanceObjectCache
;
import
org.apache.skywalking.apm.util.StringUtil
;
import
org.reactivestreams.Publisher
;
import
reactor.netty.NettyOutbound
;
import
reactor.netty.http.client.HttpClientRequest
;
import
java.lang.reflect.Method
;
import
java.net.URL
;
import
java.util.function.BiFunction
;
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
/**
* This class intercept <code>send</code> method.
* <p>
* In before method, create a new BiFunction lambda expression for setting <code>ContextCarrier</code> to http header
* and replace the original lambda in argument
*/
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
();
if
(
enhanceObjectCache
==
null
)
{
return
;
}
AbstractSpan
span
=
ContextManager
.
activeSpan
();
span
.
prepareForAsync
();
if
(
StringUtil
.
isNotEmpty
(
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
);
abstractSpan
.
setLayer
(
SpanLayer
.
HTTP
);
ContextManager
.
stopSpan
(
abstractSpan
);
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>
finalSender
=
(
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>)
allArguments
[
0
];
allArguments
[
0
]
=
(
BiFunction
<
HttpClientRequest
,
NettyOutbound
,
Publisher
<
Void
>>)
(
request
,
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
);
}
ContextManager
.
stopSpan
(
span
);
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-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerUriInterceptor.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
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.v3x.define.EnhanceObjectCache
;
import
java.lang.reflect.Method
;
/**
* This class intercept <code>uri</code> method to get the url of downstream service
*/
public
class
HttpClientFinalizerUriInterceptor
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
{
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
)
{
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/NettyRoutingFilterInterceptor.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
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
java.lang.reflect.Method
;
import
static
org
.
apache
.
skywalking
.
apm
.
network
.
trace
.
component
.
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
;
/**
* This class intercept <code>filter</code> method.
* <p>
* <code>spring-webflux-5.x-plugin</code> will inject context snapshot into skywalking dynamic field, and this
* interceptor will continue the span in another thread.
* </p>
*/
public
class
NettyRoutingFilterInterceptor
implements
InstanceMethodsAroundInterceptor
{
@Override
public
void
beforeMethod
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
MethodInterceptResult
result
)
throws
Throwable
{
EnhancedInstance
enhancedInstance
=
getInstance
(
allArguments
[
0
]);
AbstractSpan
span
=
ContextManager
.
createLocalSpan
(
"SpringCloudGateway/RoutingFilter"
);
if
(
enhancedInstance
!=
null
&&
enhancedInstance
.
getSkyWalkingDynamicField
()
!=
null
)
{
ContextManager
.
continued
((
ContextSnapshot
)
enhancedInstance
.
getSkyWalkingDynamicField
());
}
span
.
setComponent
(
SPRING_CLOUD_GATEWAY
);
}
private
EnhancedInstance
getInstance
(
Object
o
)
{
EnhancedInstance
instance
=
null
;
if
(
o
instanceof
EnhancedInstance
)
{
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
{
return
ret
;
}
@Override
public
void
handleMethodException
(
EnhancedInstance
objInst
,
Method
method
,
Object
[]
allArguments
,
Class
<?>[]
argumentsTypes
,
Throwable
t
)
{
ContextManager
.
activeSpan
().
log
(
t
);
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/AbstractGatewayV3EnhancePluginDefine.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.define
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine
;
/**
* This abstract class defines the <code>witnessClasses()</code> method,
* and other plugin define classes need to inherit from this class
*/
public
abstract
class
AbstractGatewayV3EnhancePluginDefine
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-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/DispatcherHandlerInstrumentation.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.define
;
/**
* This class is used for enable {@link org.apache.skywalking.apm.plugin.spring.webflux.v5.define.DispatcherHandlerInstrumentation}
* class when {@link org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor} class is exist
*/
public
class
DispatcherHandlerInstrumentation
extends
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
webflux
.
v5
.
define
.
DispatcherHandlerInstrumentation
{
@Override
protected
String
[]
witnessClasses
()
{
return
new
String
[]{
"org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor"
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/EnhanceObjectCache.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.define
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
/**
* enhance object cache
*/
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
AbstractSpan
getSpan1
()
{
return
span1
;
}
public
void
setSpan1
(
final
AbstractSpan
span
)
{
span1
=
span
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/HttpClientFinalizerInstrumentation.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.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.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
;
/**
* This class instrument <code>reactor.netty.http.client.HttpClientFinalizer</code> class.
* <p>
* This is the class that actually sends the request. By enhancing in different methods,
* we can get information such as uri and send trace context to the downstream service through http header.
* </p>
*/
public
class
HttpClientFinalizerInstrumentation
extends
AbstractGatewayV3EnhancePluginDefine
{
private
static
final
String
INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER
=
"reactor.netty.http.client.HttpClientFinalizer"
;
private
static
final
String
CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.HttpClientFinalizerConstructorInterceptor"
;
private
static
final
String
CLIENT_FINALIZER_CONSTRUCTOR_ARGUMENT_TYPE
=
"reactor.netty.http.client.HttpClientConfig"
;
private
static
final
String
HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.HttpClientFinalizerUriInterceptor"
;
private
static
final
String
HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.HttpClientFinalizerSendInterceptor"
;
private
static
final
String
HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.HttpClientFinalizerResponseConnectionInterceptor"
;
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER
);
}
@Override
public
ConstructorInterceptPoint
[]
getConstructorsInterceptPoints
()
{
return
new
ConstructorInterceptPoint
[]{
new
ConstructorInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getConstructorMatcher
()
{
return
takesArgumentWithType
(
0
,
CLIENT_FINALIZER_CONSTRUCTOR_ARGUMENT_TYPE
);
}
@Override
public
String
getConstructorInterceptor
()
{
return
CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR
;
}
}
};
}
@Override
public
InstanceMethodsInterceptPoint
[]
getInstanceMethodsInterceptPoints
()
{
return
new
InstanceMethodsInterceptPoint
[]{
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"uri"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
false
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"send"
).
and
(
takesArgumentWithType
(
0
,
"java.util.function.BiFunction"
));
}
@Override
public
String
getMethodsInterceptor
()
{
return
HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
true
;
}
},
new
InstanceMethodsInterceptPoint
()
{
@Override
public
ElementMatcher
<
MethodDescription
>
getMethodsMatcher
()
{
return
named
(
"responseConnection"
);
}
@Override
public
String
getMethodsInterceptor
()
{
return
HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
true
;
}
}
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/NettyRoutingFilterInstrumentation.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.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.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
;
/**
* This class instrument {@link org.springframework.cloud.gateway.filter.NettyRoutingFilter} class.
* <p>
* Enhance <code>filter</code> method and get <code>ContextSnapshot</code> from {@link
* org.springframework.web.server.ServerWebExchange}. Create a local span to continue context snapshot created in {@link
* org.apache.skywalking.apm.plugin.spring.webflux.v5.DispatcherHandlerHandleMethodInterceptor} interceptor.
* </p>
*/
public
class
NettyRoutingFilterInstrumentation
extends
AbstractGatewayV3EnhancePluginDefine
{
private
static
final
String
INTERCEPT_CLASS_NETTY_ROUTING_FILTER
=
"org.springframework.cloud.gateway.filter.NettyRoutingFilter"
;
private
static
final
String
NETTY_ROUTING_FILTER_INTERCEPTOR
=
"org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.NettyRoutingFilterInterceptor"
;
@Override
protected
ClassMatch
enhanceClass
()
{
return
byName
(
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
NETTY_ROUTING_FILTER_INTERCEPTOR
;
}
@Override
public
boolean
isOverrideArgs
()
{
return
true
;
}
}
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/define/ServerWebExchangeInstrumentation.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x.define
;
/**
* This class is used for enable {@link org.apache.skywalking.apm.plugin.spring.webflux.v5.define.ServerWebExchangeInstrumentation}
* when {@link org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor} class is exist.
*/
public
class
ServerWebExchangeInstrumentation
extends
org
.
apache
.
skywalking
.
apm
.
plugin
.
spring
.
webflux
.
v5
.
define
.
ServerWebExchangeInstrumentation
{
@Override
protected
String
[]
witnessClasses
()
{
return
new
String
[]{
"org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor"
};
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/main/resources/skywalking-plugin.def
0 → 100644
浏览文件 @
edc154c4
# 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-3.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.HttpClientFinalizerInstrumentation
spring-cloud-gateway-3.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.NettyRoutingFilterInstrumentation
spring-cloud-gateway-3.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.ServerWebExchangeInstrumentation
spring-cloud-gateway-3.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.DispatcherHandlerInstrumentation
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerConstructorInterceptorTest.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.EnhanceObjectCache
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
reactor.netty.http.client.HttpClientConfig
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
powermock
.
api
.
mockito
.
PowerMockito
.
mock
;
import
static
org
.
powermock
.
api
.
mockito
.
PowerMockito
.
when
;
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
(
HttpClientConfig
.
class
)
public
class
HttpClientFinalizerConstructorInterceptorTest
{
private
static
final
String
URI
=
"http://localhost:8080/get"
;
private
final
EnhancedInstance
enhancedInstance
=
new
EnhancedInstance
()
{
private
EnhanceObjectCache
enhanceObjectCache
;
@Override
public
Object
getSkyWalkingDynamicField
()
{
return
enhanceObjectCache
;
}
@Override
public
void
setSkyWalkingDynamicField
(
Object
value
)
{
this
.
enhanceObjectCache
=
(
EnhanceObjectCache
)
value
;
}
};
private
HttpClientConfig
httpClientConfig
;
private
HttpClientFinalizerConstructorInterceptor
httpClientFinalizerConstructorInterceptor
;
@Before
public
void
setUp
()
{
httpClientConfig
=
mock
(
HttpClientConfig
.
class
);
when
(
httpClientConfig
.
uri
()).
thenReturn
(
URI
);
httpClientFinalizerConstructorInterceptor
=
new
HttpClientFinalizerConstructorInterceptor
();
}
@Test
public
void
onConstruct
()
{
httpClientFinalizerConstructorInterceptor
.
onConstruct
(
enhancedInstance
,
new
Object
[]{
httpClientConfig
});
final
EnhanceObjectCache
enhanceCache
=
(
EnhanceObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
assertNotNull
(
enhanceCache
);
assertEquals
(
enhanceCache
.
getUrl
(),
URI
);
}
}
\ No newline at end of file
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/HttpClientFinalizerInterceptorTest.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
org.apache.skywalking.apm.agent.core.context.ContextManager
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.apache.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.apache.skywalking.apm.agent.test.tools.SpanAssert
;
import
org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.apache.skywalking.apm.plugin.spring.cloud.gateway.v3x.define.EnhanceObjectCache
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
import
org.reactivestreams.Publisher
;
import
reactor.netty.Connection
;
import
reactor.netty.NettyOutbound
;
import
reactor.netty.http.client.HttpClientRequest
;
import
reactor.netty.http.client.HttpClientResponse
;
import
java.util.List
;
import
java.util.function.BiFunction
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
public
class
HttpClientFinalizerInterceptorTest
{
private
final
static
String
URI
=
"http://localhost:8080/get"
;
private
final
static
String
ENTRY_OPERATION_NAME
=
"/get"
;
private
final
HttpClientFinalizerSendInterceptor
sendInterceptor
=
new
HttpClientFinalizerSendInterceptor
();
private
final
HttpClientFinalizerResponseConnectionInterceptor
responseConnectionInterceptor
=
new
HttpClientFinalizerResponseConnectionInterceptor
();
private
final
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>
originalSendBiFunction
=
(
httpClientRequest
,
nettyOutbound
)
->
(
Publisher
<
Void
>)
s
->
{
};
private
final
BiFunction
<?
super
HttpClientResponse
,
?
super
Connection
,
?
extends
Publisher
<
Void
>>
originalResponseConnectionBiFunction
=
(
httpClientResponse
,
connection
)
->
(
Publisher
<
Void
>)
s
->
{
};
private
final
EnhancedInstance
enhancedInstance
=
new
EnhancedInstance
()
{
private
EnhanceObjectCache
enhanceObjectCache
;
@Override
public
Object
getSkyWalkingDynamicField
()
{
return
enhanceObjectCache
;
}
@Override
public
void
setSkyWalkingDynamicField
(
Object
value
)
{
this
.
enhanceObjectCache
=
(
EnhanceObjectCache
)
value
;
}
};
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
private
HttpClientResponse
mockResponse
;
private
HttpClientRequest
mockRequest
;
@SegmentStoragePoint
private
SegmentStorage
segmentStorage
;
private
AbstractSpan
entrySpan
;
@Before
public
void
setUp
()
throws
Exception
{
final
EnhanceObjectCache
enhanceObjectCache
=
new
EnhanceObjectCache
();
enhanceObjectCache
.
setUrl
(
URI
);
enhancedInstance
.
setSkyWalkingDynamicField
(
enhanceObjectCache
);
entrySpan
=
ContextManager
.
createEntrySpan
(
ENTRY_OPERATION_NAME
,
null
);
entrySpan
.
setLayer
(
SpanLayer
.
HTTP
);
entrySpan
.
setComponent
(
ComponentsDefine
.
SPRING_WEBFLUX
);
mockRequest
=
new
MockCliengRequest
();
mockResponse
=
new
MockClientResponse
();
}
@Test
public
void
testWithDynamicFieldNull
()
throws
Throwable
{
enhancedInstance
.
setSkyWalkingDynamicField
(
null
);
executeSendRequest
();
final
List
<
TraceSegment
>
traceSegments
=
segmentStorage
.
getTraceSegments
();
assertEquals
(
traceSegments
.
size
(),
0
);
if
(
ContextManager
.
isActive
())
{
ContextManager
.
stopSpan
();
}
}
@Test
public
void
testWithEmptyUri
()
throws
Throwable
{
final
EnhanceObjectCache
objectCache
=
(
EnhanceObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
objectCache
.
setUrl
(
""
);
executeSendRequest
();
final
List
<
TraceSegment
>
traceSegments
=
segmentStorage
.
getTraceSegments
();
assertEquals
(
traceSegments
.
size
(),
1
);
final
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
traceSegments
.
get
(
0
));
assertNotNull
(
spans
);
assertEquals
(
spans
.
size
(),
1
);
assertUpstreamSpan
(
spans
.
get
(
0
));
assertNotNull
(
objectCache
.
getSpan1
());
assertEquals
(
objectCache
.
getSpan1
().
getSpanId
(),
entrySpan
.
getSpanId
());
}
@Test
public
void
testWithUri
()
throws
Throwable
{
executeSendRequest
();
final
List
<
TraceSegment
>
traceSegments
=
segmentStorage
.
getTraceSegments
();
assertEquals
(
traceSegments
.
size
(),
1
);
final
EnhanceObjectCache
objectCache
=
(
EnhanceObjectCache
)
enhancedInstance
.
getSkyWalkingDynamicField
();
assertNotNull
(
objectCache
.
getSpan1
());
assertNotNull
(
objectCache
.
getSpan
());
assertEquals
(
objectCache
.
getSpan1
().
getSpanId
(),
entrySpan
.
getSpanId
());
assertTrue
(
objectCache
.
getSpan
().
isExit
());
assertEquals
(
objectCache
.
getSpan
().
getOperationName
(),
"SpringCloudGateway/sendRequest"
);
final
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
traceSegments
.
get
(
0
));
assertNotNull
(
spans
);
assertEquals
(
spans
.
size
(),
2
);
assertUpstreamSpan
(
spans
.
get
(
1
));
assertDownstreamSpan
(
spans
.
get
(
0
));
}
private
void
executeSendRequest
()
throws
Throwable
{
Object
[]
sendArguments
=
new
Object
[]{
originalSendBiFunction
};
sendInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
sendArguments
,
null
,
null
);
sendInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
new
Object
[
0
],
null
,
enhancedInstance
);
((
BiFunction
<?
super
HttpClientRequest
,
?
super
NettyOutbound
,
?
extends
Publisher
<
Void
>>)
sendArguments
[
0
])
.
apply
(
mockRequest
,
null
);
Object
[]
responseConnectionArguments
=
new
Object
[]{
originalResponseConnectionBiFunction
};
responseConnectionInterceptor
.
beforeMethod
(
enhancedInstance
,
null
,
responseConnectionArguments
,
null
,
null
);
responseConnectionInterceptor
.
afterMethod
(
enhancedInstance
,
null
,
new
Object
[
0
],
null
,
enhancedInstance
);
((
BiFunction
<?
super
HttpClientResponse
,
?
super
Connection
,
?
extends
Publisher
<
Void
>>)
responseConnectionArguments
[
0
])
.
apply
(
mockResponse
,
null
);
}
private
void
assertUpstreamSpan
(
AbstractSpan
span
)
{
SpanAssert
.
assertLayer
(
span
,
SpanLayer
.
HTTP
);
SpanAssert
.
assertComponent
(
span
,
ComponentsDefine
.
SPRING_WEBFLUX
);
}
private
void
assertDownstreamSpan
(
AbstractSpan
span
)
{
SpanAssert
.
assertLayer
(
span
,
SpanLayer
.
HTTP
);
SpanAssert
.
assertComponent
(
span
,
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
);
SpanAssert
.
assertTagSize
(
span
,
2
);
SpanAssert
.
assertTag
(
span
,
0
,
URI
);
SpanAssert
.
assertTag
(
span
,
1
,
String
.
valueOf
(
HttpResponseStatus
.
OK
.
code
()));
}
}
\ No newline at end of file
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/MockCliengRequest.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
import
io.netty.handler.codec.http.DefaultHttpHeaders
;
import
io.netty.handler.codec.http.HttpHeaders
;
import
io.netty.handler.codec.http.HttpMethod
;
import
io.netty.handler.codec.http.HttpVersion
;
import
io.netty.handler.codec.http.cookie.Cookie
;
import
reactor.netty.http.client.HttpClientRequest
;
import
reactor.util.context.Context
;
import
reactor.util.context.ContextView
;
import
java.time.Duration
;
import
java.util.Map
;
import
java.util.Set
;
public
class
MockCliengRequest
implements
HttpClientRequest
{
@Override
public
HttpClientRequest
addCookie
(
Cookie
cookie
)
{
return
null
;
}
@Override
public
HttpClientRequest
addHeader
(
CharSequence
charSequence
,
CharSequence
charSequence1
)
{
return
null
;
}
@Override
public
HttpClientRequest
header
(
CharSequence
charSequence
,
CharSequence
charSequence1
)
{
return
null
;
}
@Override
public
HttpClientRequest
headers
(
HttpHeaders
httpHeaders
)
{
return
null
;
}
@Override
public
boolean
isFollowRedirect
()
{
return
false
;
}
@Override
public
HttpClientRequest
responseTimeout
(
Duration
duration
)
{
return
null
;
}
@Override
public
Context
currentContext
()
{
return
null
;
}
@Override
public
ContextView
currentContextView
()
{
return
null
;
}
@Override
public
String
[]
redirectedFrom
()
{
return
new
String
[
0
];
}
@Override
public
HttpHeaders
requestHeaders
()
{
return
new
DefaultHttpHeaders
();
}
@Override
public
String
resourceUrl
()
{
return
null
;
}
@Override
public
Map
<
CharSequence
,
Set
<
Cookie
>>
cookies
()
{
return
null
;
}
@Override
public
boolean
isKeepAlive
()
{
return
false
;
}
@Override
public
boolean
isWebsocket
()
{
return
false
;
}
@Override
public
HttpMethod
method
()
{
return
null
;
}
@Override
public
String
fullPath
()
{
return
null
;
}
@Override
public
String
uri
()
{
return
null
;
}
@Override
public
HttpVersion
version
()
{
return
null
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/MockClientResponse.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
import
io.netty.handler.codec.http.HttpHeaders
;
import
io.netty.handler.codec.http.HttpMethod
;
import
io.netty.handler.codec.http.HttpResponseStatus
;
import
io.netty.handler.codec.http.HttpVersion
;
import
io.netty.handler.codec.http.cookie.Cookie
;
import
reactor.netty.http.client.HttpClientResponse
;
import
reactor.util.context.Context
;
import
reactor.util.context.ContextView
;
import
java.util.Map
;
import
java.util.Set
;
public
class
MockClientResponse
implements
HttpClientResponse
{
@Override
public
HttpHeaders
responseHeaders
()
{
return
null
;
}
@Override
public
HttpResponseStatus
status
()
{
return
HttpResponseStatus
.
OK
;
}
@Override
public
Context
currentContext
()
{
return
null
;
}
@Override
public
ContextView
currentContextView
()
{
return
null
;
}
@Override
public
String
[]
redirectedFrom
()
{
return
new
String
[
0
];
}
@Override
public
HttpHeaders
requestHeaders
()
{
return
null
;
}
@Override
public
String
resourceUrl
()
{
return
null
;
}
@Override
public
Map
<
CharSequence
,
Set
<
Cookie
>>
cookies
()
{
return
null
;
}
@Override
public
boolean
isKeepAlive
()
{
return
false
;
}
@Override
public
boolean
isWebsocket
()
{
return
false
;
}
@Override
public
HttpMethod
method
()
{
return
null
;
}
@Override
public
String
fullPath
()
{
return
null
;
}
@Override
public
String
uri
()
{
return
null
;
}
@Override
public
HttpVersion
version
()
{
return
null
;
}
}
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-3.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v3x/NettyRoutingFilterInterceptorTest.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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.v3x
;
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.context.trace.AbstractTracingSpan
;
import
org.apache.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.apache.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance
;
import
org.apache.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.apache.skywalking.apm.agent.test.tools.SpanAssert
;
import
org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.apache.skywalking.apm.network.trace.component.ComponentsDefine
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.powermock.modules.junit4.PowerMockRunnerDelegate
;
import
java.util.List
;
@RunWith
(
PowerMockRunner
.
class
)
@PowerMockRunnerDelegate
(
TracingSegmentRunner
.
class
)
public
class
NettyRoutingFilterInterceptorTest
{
private
final
EnhancedInstance
enhancedInstance
=
new
EnhancedInstance
()
{
private
ContextSnapshot
snapshot
;
@Override
public
Object
getSkyWalkingDynamicField
()
{
return
snapshot
;
}
@Override
public
void
setSkyWalkingDynamicField
(
Object
value
)
{
this
.
snapshot
=
(
ContextSnapshot
)
value
;
}
};
private
final
NettyRoutingFilterInterceptor
interceptor
=
new
NettyRoutingFilterInterceptor
();
@Rule
public
AgentServiceRule
serviceRule
=
new
AgentServiceRule
();
@SegmentStoragePoint
private
SegmentStorage
segmentStorage
;
@Before
public
void
setUp
()
throws
Exception
{
}
@Test
public
void
testWithNullDynamicField
()
throws
Throwable
{
interceptor
.
beforeMethod
(
null
,
null
,
new
Object
[]{
enhancedInstance
},
null
,
null
);
interceptor
.
afterMethod
(
null
,
null
,
null
,
null
,
null
);
ContextManager
.
stopSpan
();
final
List
<
TraceSegment
>
traceSegments
=
segmentStorage
.
getTraceSegments
();
Assert
.
assertEquals
(
traceSegments
.
size
(),
1
);
final
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
traceSegments
.
get
(
0
));
Assert
.
assertNotNull
(
spans
);
Assert
.
assertEquals
(
spans
.
size
(),
1
);
SpanAssert
.
assertComponent
(
spans
.
get
(
0
),
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
);
}
@Test
public
void
testWithContextSnapshot
()
throws
Throwable
{
final
AbstractSpan
entrySpan
=
ContextManager
.
createEntrySpan
(
"/get"
,
null
);
SpanLayer
.
asHttp
(
entrySpan
);
entrySpan
.
setComponent
(
ComponentsDefine
.
SPRING_WEBFLUX
);
enhancedInstance
.
setSkyWalkingDynamicField
(
ContextManager
.
capture
());
interceptor
.
beforeMethod
(
null
,
null
,
new
Object
[]{
enhancedInstance
},
null
,
null
);
interceptor
.
afterMethod
(
null
,
null
,
null
,
null
,
null
);
ContextManager
.
stopSpan
();
ContextManager
.
stopSpan
(
entrySpan
);
final
List
<
TraceSegment
>
traceSegments
=
segmentStorage
.
getTraceSegments
();
Assert
.
assertEquals
(
traceSegments
.
size
(),
1
);
final
List
<
AbstractTracingSpan
>
spans
=
SegmentHelper
.
getSpans
(
traceSegments
.
get
(
0
));
Assert
.
assertNotNull
(
spans
);
Assert
.
assertEquals
(
spans
.
size
(),
2
);
SpanAssert
.
assertComponent
(
spans
.
get
(
0
),
ComponentsDefine
.
SPRING_CLOUD_GATEWAY
);
SpanAssert
.
assertComponent
(
spans
.
get
(
1
),
ComponentsDefine
.
SPRING_WEBFLUX
);
SpanAssert
.
assertLayer
(
spans
.
get
(
1
),
SpanLayer
.
HTTP
);
}
}
\ No newline at end of file
apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
浏览文件 @
edc154c4
...
...
@@ -30,6 +30,7 @@
<modules>
<module>
gateway-2.0.x-plugin
</module>
<module>
gateway-2.1.x-plugin
</module>
<module>
gateway-3.x-plugin
</module>
</modules>
<packaging>
pom
</packaging>
...
...
docs/en/setup/service-agent/java-agent/Plugin-list.md
浏览文件 @
edc154c4
...
...
@@ -116,3 +116,4 @@
-
mssql-jdbc
-
apache-cxf-3.x
-
jsonrpc4j
-
spring-cloud-gateway-3.x
docs/en/setup/service-agent/java-agent/Supported-list.md
浏览文件 @
edc154c4
...
...
@@ -30,7 +30,7 @@ metrics based on the tracing data.
*
[
AsyncHttpClient
](
https://github.com/AsyncHttpClient/async-http-client
)
2.x
*
JRE HttpURLConnection (Optional²)
*
HTTP Gateway
*
[
Spring Cloud Gateway
](
https://spring.io/projects/spring-cloud-gateway
)
2.0.2.RELEASE ->
2.2.x.RELEASE
(Optional²)
*
[
Spring Cloud Gateway
](
https://spring.io/projects/spring-cloud-gateway
)
2.0.2.RELEASE ->
3.x
(Optional²)
*
JDBC
*
Mysql Driver 5.x, 6.x, 8.x
*
Oracle Driver (Optional¹)
...
...
test/plugin/scenarios/gateway-3.x-scenario/config/expectedData.yaml
0 → 100644
浏览文件 @
edc154c4
# 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
spanLayer
:
Http
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-3.x-scenario/configuration.yml
0 → 100644
浏览文件 @
edc154c4
# 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-3.x-plugin-*.jar
test/plugin/scenarios/gateway-3.x-scenario/gateway-dist/bin/startup.sh
0 → 100644
浏览文件 @
edc154c4
#!/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-3.x-scenario/gateway-dist/pom.xml
0 → 100644
浏览文件 @
edc154c4
<?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-3.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-3.x-scenario/gateway-dist/src/main/assembly/assembly.xml
0 → 100644
浏览文件 @
edc154c4
<?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-3.x-scenario/gateway-projectA-scenario/pom.xml
0 → 100644
浏览文件 @
edc154c4
<?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-3.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>
https://repo.spring.io/snapshot
</url>
</pluginRepository>
<pluginRepository>
<id>
spring-milestones
</id>
<url>
https://repo.spring.io/milestone
</url>
</pluginRepository>
</pluginRepositories>
</project>
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.apache.skywalking.apm.testcase.sc.gateway.projectA
;
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-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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-3.x-scenario/gateway-projectA-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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-3.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
0 → 100644
浏览文件 @
edc154c4
#
# 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-3.x-scenario/gateway-projectB-scenario/pom.xml
0 → 100644
浏览文件 @
edc154c4
<?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-3.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-3.x-scenario/gateway-projectB-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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
=
{
"test.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-3.x-scenario/gateway-projectB-scenario/src/main/java/test/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
0 → 100644
浏览文件 @
edc154c4
/*
* 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
test.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
()
{
return
"1"
;
}
@RequestMapping
(
"/provider/b/healthCheck"
)
public
String
healthCheck
()
{
return
"Success"
;
}
}
test/plugin/scenarios/gateway-3.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
0 → 100644
浏览文件 @
edc154c4
#
# 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-3.x-scenario/pom.xml
0 → 100644
浏览文件 @
edc154c4
<?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-3.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-3.x-scenario
</name>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<test.framework.version>
3.0.0
</test.framework.version>
<docker.image.version>
${test.framework.version}
</docker.image.version>
</properties>
<build>
<finalName>
gateway-3.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-3.x-scenario/support-version.list
0 → 100644
浏览文件 @
edc154c4
# 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.
3.0.0
3.0.1
3.0.2
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录