From 2e9f0016332ec4d3d79393897c7985eda2376fd6 Mon Sep 17 00:00:00 2001 From: cngdkxw Date: Fri, 20 Mar 2020 20:28:30 +0800 Subject: [PATCH] Add spring cloud feign 2.x plugin (#4526) --- .github/workflows/plugins-test.yaml | 6 + .../spring-cloud-feign-1.x-plugin/pom.xml | 21 +- .../spring-plugins/spring-cloud/pom.xml | 1 + .../spring-cloud-feign-2.x-plugin/pom.xml | 36 +++ ...oadBalancerFeignClientInstrumentation.java | 68 ++++++ .../src/main/resources/skywalking-plugin.def | 17 ++ .../java-agent/Supported-list.md | 2 +- .../bin/startup.sh | 21 ++ .../config/expectedData.yaml | 104 ++++++++ .../configuration.yml | 23 ++ .../spring-cloud-feign-1.1.x-scenario/pom.xml | 130 ++++++++++ .../src/main/assembly/assembly.xml | 41 ++++ .../apm/testcase/feign/Application.java | 36 +++ .../feign/controller/BackController.java | 32 +++ .../feign/controller/CaseController.java | 45 ++++ .../feign/controller/RestRequest.java | 30 +++ .../src/main/resources/application.yaml | 25 ++ .../src/main/resources/log4j2.xml | 30 +++ .../support-version.list | 23 ++ .../bin/startup.sh | 21 ++ .../config/expectedData.yaml | 104 ++++++++ .../configuration.yml | 23 ++ .../spring-cloud-feign-1.2.x-scenario/pom.xml | 130 ++++++++++ .../src/main/assembly/assembly.xml | 41 ++++ .../apm/testcase/feign/Application.java | 36 +++ .../feign/controller/BackController.java | 32 +++ .../feign/controller/CaseController.java | 49 ++++ .../feign/controller/RestRequest.java | 30 +++ .../src/main/resources/application.yaml | 25 ++ .../src/main/resources/log4j2.xml | 30 +++ .../support-version.list | 38 +++ .../bin/startup.sh | 21 ++ .../config/expectedData.yaml | 225 ++++++++++++++++++ .../configuration.yml | 23 ++ .../spring-cloud-feign-2.x-scenario/pom.xml | 127 ++++++++++ .../src/main/assembly/assembly.xml | 41 ++++ .../apm/testcase/feign/Application.java | 36 +++ .../feign/controller/BackController.java | 65 +++++ .../feign/controller/CaseController.java | 55 +++++ .../feign/controller/RestRequest.java | 40 ++++ .../apm/testcase/feign/entity/User.java | 53 +++++ .../src/main/resources/application.yaml | 26 ++ .../src/main/resources/log4j2.xml | 30 +++ .../support-version.list | 29 +++ 44 files changed, 2000 insertions(+), 21 deletions(-) create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/pom.xml create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/string/cloud/netflix/feign/v2/define/LoadBalancerFeignClientInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/resources/skywalking-plugin.def create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/support-version.list create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/support-version.list create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/entity/User.java create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/spring-cloud-feign-2.x-scenario/support-version.list diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index 7c979331a..4ad9a433a 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -159,6 +159,12 @@ jobs: run: ./mvnw --batch-mode -f test/plugin/pom.xml clean package -DskipTests docker:build -DBUILD_NO=local >/dev/null - name: Run feign 9.0.0-9.5.1 (8) run: bash test/plugin/run.sh feign-scenario + - name: Run springcloud feign 1.1.x (8) + run: bash test/plugin/run.sh spring-cloud-feign-1.1.x-scenario + - name: Run springcloud feign 1.2.x-1.4.x (23) + run: bash test/plugin/run.sh spring-cloud-feign-1.2.x-scenario + - name: Run springcloud feign 2.x (14) + run: bash test/plugin/run.sh spring-cloud-feign-2.x-scenario - name: Run customize (1) run: bash test/plugin/run.sh customize-scenario - name: Run canal 1.0.24-1.1.2 (5) diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/netflix-plugins/spring-cloud-feign-1.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/netflix-plugins/spring-cloud-feign-1.x-plugin/pom.xml index 0000f58c8..7a4d30ed1 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/netflix-plugins/spring-cloud-feign-1.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/netflix-plugins/spring-cloud-feign-1.x-plugin/pom.xml @@ -29,27 +29,8 @@ apm-spring-cloud-feign-1.x-plugin jar - + spring-cloud-feign-1.x-plugin http://maven.apache.org - - 1.1.0.RELEASE - - - - - org.springframework.cloud - spring-cloud-starter-feign - ${spring-cloud-starter-feign.version} - provided - - - org.apache.skywalking - apm-feign-default-http-9.x-plugin - ${project.version} - provided - - - diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/pom.xml index babccd38d..50e149633 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/pom.xml @@ -29,6 +29,7 @@ spring-cloud netflix-plugins + spring-cloud-feign-2.x-plugin pom diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/pom.xml new file mode 100644 index 000000000..bbdfbae87 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/pom.xml @@ -0,0 +1,36 @@ + + + + + 4.0.0 + + + org.apache.skywalking + spring-cloud + 7.1.0-SNAPSHOT + + + apm-spring-cloud-feign-2.x-plugin + jar + + apm-spring-cloud-feign-2.x-plugin + http://maven.apache.org + + diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/string/cloud/netflix/feign/v2/define/LoadBalancerFeignClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/string/cloud/netflix/feign/v2/define/LoadBalancerFeignClientInstrumentation.java new file mode 100644 index 000000000..12f03d2f6 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/string/cloud/netflix/feign/v2/define/LoadBalancerFeignClientInstrumentation.java @@ -0,0 +1,68 @@ +/* + * 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.string.cloud.netflix.feign.v2.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class LoadBalancerFeignClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + public static final String ENHANCE_CLASS = "org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient"; + + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.feign.http.v9.DefaultHttpClientInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("execute"); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..6d359217a --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-cloud/spring-cloud-feign-2.x-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1,17 @@ +# 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-feign-2.x=org.apache.skywalking.apm.plugin.string.cloud.netflix.feign.v2.define.LoadBalancerFeignClientInstrumentation diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index 5647c327b..1468fe3dd 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -17,7 +17,7 @@ * [Netty SocketIO](https://github.com/mrniko/netty-socketio) 1.x * HTTP Client * [Feign](https://github.com/OpenFeign/feign) 9.x - * [Netflix Spring Cloud Feign](https://github.com/spring-cloud/spring-cloud-netflix/tree/master/spring-cloud-starter-feign) 1.1.x, 1.2.x, 1.3.x + * [Netflix Spring Cloud Feign](https://github.com/spring-cloud/spring-cloud-openfeign) 1.1.x -> 2.x * [Okhttp](https://github.com/square/okhttp) 3.x * [Apache httpcomponent HttpClient](http://hc.apache.org/) 2.0 -> 3.1, 4.2, 4.3 * [Spring RestTemplete](https://github.com/spring-projects/spring-framework) 4.x diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/bin/startup.sh new file mode 100644 index 000000000..e2c4cc46a --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/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} ${home}/../libs/spring-cloud-feign-1.1.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000..381a880a0 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/config/expectedData.yaml @@ -0,0 +1,104 @@ +# 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. +registryItems: + services: + - {spring-cloud-feign-1.1.x-scenario: nq 0} + instances: + - {spring-cloud-feign-1.1.x-scenario: 1} + operationNames: + - spring-cloud-feign-1.1.x-scenario: [/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, + /spring-cloud-feign-1.1.x-scenario/get] + heartbeat: [] +segmentItems: + - serviceName: spring-cloud-feign-1.1.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/get + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.1.x-scenario/get + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/get'} + - operationName: /spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario'} + - {key: http.method, value: GET} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/configuration.yml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/configuration.yml new file mode 100644 index 000000000..c4a5843d8 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/configuration.yml @@ -0,0 +1,23 @@ +# 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/spring-cloud-feign-1.1.x-scenario/case/spring-cloud-feign-1.1.x-scenario +healthCheck: http://localhost:8080/spring-cloud-feign-1.1.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: spring-cloud-feign-1.1.x-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/pom.xml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/pom.xml new file mode 100644 index 000000000..52eb51cf1 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/pom.xml @@ -0,0 +1,130 @@ + + + + + org.apache.skywalking.apm.testcase + spring-cloud-feign-1.1.x-scenario + 7.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 1.1.0.RELEASE + 1.3.0.RELEASE + + + skywalking-spring-cloud-feign-1.1.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + jul-to-slf4j + org.slf4j + + + + + org.springframework.cloud + spring-cloud-starter-feign + ${test.framework.version} + + + com.netflix.feign + feign-hystrix + + + + + + + spring-cloud-feign-1.1.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..e0a36e7ab --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-cloud-feign-1.1.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java new file mode 100644 index 000000000..57c9ada2f --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.feign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java new file mode 100644 index 000000000..c1664352d --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class BackController { + + @RequestMapping(value = "/get", method = RequestMethod.GET) + public String getUser() { + return "Hello"; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java new file mode 100644 index 000000000..e26b65a8a --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +public class CaseController { + + @Autowired + private RestRequest restRequest; + + @ResponseBody + @RequestMapping("/healthCheck") + public String healthcheck() { + return "Success"; + } + + @ResponseBody + @RequestMapping("/spring-cloud-feign-1.1.x-scenario") + public String feignCase() { + restRequest.getById(); + return "success"; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java new file mode 100644 index 000000000..92b3fcb75 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@FeignClient(value = "spring-cloud-feign-1.1.x-scenario", url = "localhost:8080/spring-cloud-feign-1.1.x-scenario") +public interface RestRequest { + + @RequestMapping(value = "/get", method = RequestMethod.GET) + String getById(); +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..87696a8aa --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,25 @@ +# +# 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 + context-path: /spring-cloud-feign-1.1.x-scenario +logging: + config: classpath:log4j2.xml +spring: + application: + name: spring-cloud-feign-1.1.x-scenario diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/support-version.list b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/support-version.list new file mode 100644 index 000000000..4396abe4d --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.1.x-scenario/support-version.list @@ -0,0 +1,23 @@ +# 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 +# "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. +1.1.0.RELEASE +1.1.1.RELEASE +1.1.2.RELEASE +1.1.3.RELEASE +1.1.4.RELEASE +1.1.5.RELEASE +1.1.6.RELEASE +1.1.7.RELEASE diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/bin/startup.sh new file mode 100644 index 000000000..091b39892 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/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} ${home}/../libs/spring-cloud-feign-1.2.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000..9f8e496f8 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/config/expectedData.yaml @@ -0,0 +1,104 @@ +# 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. +registryItems: + services: + - {spring-cloud-feign-1.2.x-scenario: nq 0} + instances: + - {spring-cloud-feign-1.2.x-scenario: 1} + operationNames: + - spring-cloud-feign-1.2.x-scenario: [/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, + /spring-cloud-feign-1.2.x-scenario/get] + heartbeat: [] +segmentItems: + - serviceName: spring-cloud-feign-1.2.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/get + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-1.2.x-scenario/get + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/get'} + - operationName: /spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/configuration.yml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/configuration.yml new file mode 100644 index 000000000..c8185c3eb --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/configuration.yml @@ -0,0 +1,23 @@ +# 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/spring-cloud-feign-1.2.x-scenario/case/spring-cloud-feign-1.2.x-scenario +healthCheck: http://localhost:8080/spring-cloud-feign-1.2.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: spring-cloud-feign-1.2.x-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/pom.xml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/pom.xml new file mode 100644 index 000000000..fcf88ae67 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/pom.xml @@ -0,0 +1,130 @@ + + + + + org.apache.skywalking.apm.testcase + spring-cloud-feign-1.2.x-scenario + 7.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 1.3.0.RELEASE + 1.5.0.RELEASE + + + skywalking-spring-cloud-feign-1.2.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + jul-to-slf4j + org.slf4j + + + + + org.springframework.cloud + spring-cloud-starter-feign + ${test.framework.version} + + + io.github.openfeign + feign-hystrix + + + + + + + spring-cloud-feign-1.2.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..836ea141f --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-cloud-feign-1.2.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java new file mode 100644 index 000000000..57c9ada2f --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.feign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java new file mode 100644 index 000000000..c1664352d --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class BackController { + + @RequestMapping(value = "/get", method = RequestMethod.GET) + public String getUser() { + return "Hello"; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java new file mode 100644 index 000000000..750441cfa --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +public class CaseController { + private static final Logger logger = LogManager.getLogger(CaseController.class); + + @Autowired + private RestRequest restRequest; + + @ResponseBody + @RequestMapping("/healthCheck") + public String healthcheck() { + return "Success"; + } + + @ResponseBody + @RequestMapping("/spring-cloud-feign-1.2.x-scenario") + public String feignCase() { + String user = restRequest.getById(); + logger.info(user); + return "success"; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java new file mode 100644 index 000000000..abe9f0ca0 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.springframework.cloud.netflix.feign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@FeignClient(value = "spring-cloud-feign-1.2.x-scenario", url = "localhost:8080/spring-cloud-feign-1.2.x-scenario") +public interface RestRequest { + + @RequestMapping(value = "/get", method = RequestMethod.GET) + String getById(); +} diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..976fbb71d --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,25 @@ +# +# 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 + context-path: /spring-cloud-feign-1.2.x-scenario +logging: + config: classpath:log4j2.xml +spring: + application: + name: spring-cloud-feign-1.2.x-scenario diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/support-version.list b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/support-version.list new file mode 100644 index 000000000..306535553 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-1.2.x-scenario/support-version.list @@ -0,0 +1,38 @@ +# 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 +# "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. +1.2.0.RELEASE +1.2.1.RELEASE +1.2.2.RELEASE +1.2.3.RELEASE +1.2.4.RELEASE +1.2.5.RELEASE +1.2.6.RELEASE +1.2.7.RELEASE +1.3.0.RELEASE +1.3.1.RELEASE +1.3.2.RELEASE +#1.3.3.RELEASE +1.3.4.RELEASE +1.3.5.RELEASE +1.3.6.RELEASE +1.4.0.RELEASE +1.4.1.RELEASE +1.4.2.RELEASE +1.4.3.RELEASE +1.4.4.RELEASE +1.4.5.RELEASE +1.4.6.RELEASE +1.4.7.RELEASE diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/bin/startup.sh new file mode 100644 index 000000000..32ab4dcc9 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/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} ${home}/../libs/spring-cloud-feign-2.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000..edce0ed9f --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/config/expectedData.yaml @@ -0,0 +1,225 @@ +# 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. +registryItems: + services: + - {spring-cloud-feign-2.x-scenario: nq 0} + instances: + - {spring-cloud-feign-2.x-scenario: 1} + operationNames: + - spring-cloud-feign-2.x-scenario: [/spring-cloud-feign-2.x-scenario/update/1, /spring-cloud-feign-2.x-scenario/create/, + /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + /spring-cloud-feign-2.x-scenario/delete/1, /spring-cloud-feign-2.x-scenario/get/1] + heartbeat: [] +segmentItems: + - serviceName: spring-cloud-feign-2.x-scenario + segmentSize: ge 5 + segments: + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/case/healthCheck'} + - {key: http.method, value: HEAD} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/create/ + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/create/'} + - {key: http.method, value: POST} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/create/ + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: POST} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/create/'} + - operationName: /spring-cloud-feign-2.x-scenario/get/{id} + operationId: 0 + parentSpanId: 0 + spanId: 2 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/get/1'} + - operationName: /spring-cloud-feign-2.x-scenario/update/{id} + operationId: 0 + parentSpanId: 0 + spanId: 3 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: PUT} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/update/1'} + - operationName: /spring-cloud-feign-2.x-scenario/delete/{id} + operationId: 0 + parentSpanId: 0 + spanId: 4 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Exit + peer: localhost:8080 + peerId: 0 + tags: + - {key: http.method, value: DELETE} + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/delete/1'} + - operationName: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario'} + - {key: http.method, value: GET} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/get/1 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/get/1'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 2, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/update/1 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/update/1'} + - {key: http.method, value: PUT} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 3, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-cloud-feign-2.x-scenario/delete/1 + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: not null + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-cloud-feign-2.x-scenario/delete/1'} + - {key: http.method, value: DELETE} + refs: + - {parentEndpointId: 0, parentEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 4, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: 'localhost:8080', entryEndpoint: /spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario, + entryServiceInstanceId: 1} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/configuration.yml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/configuration.yml new file mode 100644 index 000000000..6cb82e1b2 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/configuration.yml @@ -0,0 +1,23 @@ +# 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/spring-cloud-feign-2.x-scenario/case/spring-cloud-feign-2.x-scenario +healthCheck: http://localhost:8080/spring-cloud-feign-2.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: spring-cloud-feign-2.x-scenario +environment: +dependencies: \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/pom.xml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/pom.xml new file mode 100644 index 000000000..8c4c48b24 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/pom.xml @@ -0,0 +1,127 @@ + + + + + org.apache.skywalking.apm.testcase + spring-cloud-feign-2.x-scenario + 7.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 2.1.2.RELEASE + + + skywalking-spring-cloud-feign-2.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${test.framework.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + jul-to-slf4j + org.slf4j + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + ${test.framework.version} + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + ${test.framework.version} + + + + + spring-cloud-feign-2.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + 1.5.9.RELEASE + + + + repackage + + + + + + maven-compiler-plugin + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..b14db0f32 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-cloud-feign-2.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java new file mode 100644 index 000000000..e69a36a17 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/Application.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@SpringBootApplication +@EnableFeignClients +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java new file mode 100644 index 000000000..a7ecdfacf --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/BackController.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.apache.skywalking.apm.testcase.feign.entity.User; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.util.UriComponentsBuilder; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@RestController +public class BackController { + + private static final Map users = new ConcurrentHashMap<>(); + + @GetMapping("/get/{id}") + public ResponseEntity getUser(@PathVariable("id") int id) { + User currentUser = users.get(id); + return ResponseEntity.ok(currentUser); + } + + @PostMapping(value = "/create/") + public ResponseEntity createUser(@RequestBody User user, UriComponentsBuilder ucBuilder) { + users.put(user.getId(), user); + HttpHeaders headers = new HttpHeaders(); + headers.setLocation(ucBuilder.path("/user/{id}").buildAndExpand(user.getId()).toUri()); + return new ResponseEntity<>(headers, HttpStatus.CREATED); + } + + @PutMapping(value = "/update/{id}") + public ResponseEntity updateUser(@PathVariable("id") int id, @RequestBody User user) { + User currentUser = new User(id, user.getUserName()); + return ResponseEntity.ok(currentUser); + } + + @DeleteMapping(value = "/delete/{id}") + public ResponseEntity deleteUser(@PathVariable("id") int id) { + User currentUser = users.get(id); + if (currentUser == null) { + return ResponseEntity.noContent().build(); + } + users.remove(id); + return ResponseEntity.noContent().build(); + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java new file mode 100644 index 000000000..b6ecac35b --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/CaseController.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.feign.entity.User; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/case") +public class CaseController { + private static final Logger logger = LogManager.getLogger(CaseController.class); + + private RestRequest restRequest; + + public CaseController(RestRequest restRequest) { + this.restRequest = restRequest; + } + + @ResponseBody + @RequestMapping("/healthCheck") + public String healthcheck() { + return "Success"; + } + + @ResponseBody + @RequestMapping("/spring-cloud-feign-2.x-scenario") + public String feignCase() { + restRequest.createUser(new User(1, "test")); + User user = restRequest.getById(1); + logger.info("find Id{} user. User name is {} ", user.getId(), user.getUserName()); + restRequest.updateUser(1, new User(0, "testA")); + restRequest.deleteUser(1); + return "success"; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java new file mode 100644 index 000000000..b3d9a2f02 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/controller/RestRequest.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.controller; + +import org.apache.skywalking.apm.testcase.feign.entity.User; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.*; + +@FeignClient(value = "spring-cloud-feign-2.x-scenario", url = "localhost:8080", path = "/spring-cloud-feign-2.x-scenario") +public interface RestRequest { + + @GetMapping("/get/{id}") + User getById(@PathVariable("id") int id); + + @PostMapping(value = "/create/", produces = MediaType.APPLICATION_JSON_VALUE) + void createUser(@RequestBody User user); + + @PutMapping(value = "/update/{id}", produces = MediaType.APPLICATION_JSON_VALUE) + User updateUser(@PathVariable("id") int id, @RequestBody User user); + + @DeleteMapping("/delete/{id}") + void deleteUser(@PathVariable("id") int id); +} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/entity/User.java b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/entity/User.java new file mode 100644 index 000000000..37d40a402 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/feign/entity/User.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.feign.entity; + +public class User { + + private int id; + private String userName; + + public User(int id) { + this.id = id; + } + + public User(int id, String userName) { + this.id = id; + this.userName = userName; + } + + public User() { + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..788925ab0 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,26 @@ +# +# 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 + servlet: + context-path: /spring-cloud-feign-2.x-scenario +logging: + config: classpath:log4j2.xml +spring: + application: + name: spring-cloud-feign-2.x-scenario diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/support-version.list b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/support-version.list new file mode 100644 index 000000000..a9af266b0 --- /dev/null +++ b/test/plugin/scenarios/spring-cloud-feign-2.x-scenario/support-version.list @@ -0,0 +1,29 @@ +# 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 +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +2.0.0.RELEASE +2.0.1.RELEASE +2.0.2.RELEASE +2.0.3.RELEASE +2.0.4.RELEASE +2.1.0.RELEASE +2.1.1.RELEASE +2.1.2.RELEASE +2.1.3.RELEASE +2.1.4.RELEASE +2.1.5.RELEASE +2.2.0.RELEASE +2.2.1.RELEASE +2.2.2.RELEASE