From 6eeacf0959cf3837a63acb1b674291182d90bbc7 Mon Sep 17 00:00:00 2001 From: geekymv Date: Thu, 30 Jun 2022 09:31:59 +0800 Subject: [PATCH] Add an agent plugin to support hutool-http (#264) --- .github/workflows/plugins-test.1.yaml | 1 + CHANGES.md | 3 +- .../trace/component/ComponentsDefine.java | 2 + .../hutool-http-5.x-plugin/pom.xml | 47 +++++++ .../http/v5/HutoolHttpExecuteInterceptor.java | 102 ++++++++++++++ .../v5/define/HutoolHttpInstrumentation.java | 69 ++++++++++ .../src/main/resources/skywalking-plugin.def | 17 +++ .../apm-sdk-plugin/hutool-plugins/pom.xml | 41 ++++++ apm-sniffer/apm-sdk-plugin/pom.xml | 1 + .../service-agent/java-agent/Plugin-list.md | 1 + .../java-agent/Supported-list.md | 1 + .../hutool-http-5.x-scenario/bin/startup.sh | 21 +++ .../config/expectedData.yaml | 70 ++++++++++ .../configuration.yml | 20 +++ .../hutool-http-5.x-scenario/pom.xml | 124 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 ++++++ .../apm/testcase/hutoolhttp5/Application.java | 34 +++++ .../controller/CaseController.java | 55 ++++++++ .../src/main/resources/application.yaml | 23 ++++ .../src/main/resources/log4j2.xml | 30 +++++ .../support-version.list | 26 ++++ 21 files changed, 728 insertions(+), 1 deletion(-) create mode 100644 apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/pom.xml create mode 100644 apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/HutoolHttpExecuteInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/define/HutoolHttpInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/resources/skywalking-plugin.def create mode 100644 apm-sniffer/apm-sdk-plugin/hutool-plugins/pom.xml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/Application.java create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/controller/CaseController.java create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/hutool-http-5.x-scenario/support-version.list diff --git a/.github/workflows/plugins-test.1.yaml b/.github/workflows/plugins-test.1.yaml index ad17e7fef..8d66dc99c 100644 --- a/.github/workflows/plugins-test.1.yaml +++ b/.github/workflows/plugins-test.1.yaml @@ -60,6 +60,7 @@ jobs: - httpclient-3.x-scenario - httpclient-4.3.x-scenario - httpclient-5.x-scenario + - hutool-http-5.x-scenario - hystrix-scenario - sentinel-scenario - influxdb-scenario diff --git a/CHANGES.md b/CHANGES.md index 628c5c7ef..bcd50eeb0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,7 +7,8 @@ Release Notes. * Fix `Shenyu plugin`'s NPE in reading read trace ID when IgnoredTracerContext is used in the context. * Update witness class in elasticsearch-6.x-plugin, avoid throw NPE. * Fix `onHalfClose` using span operation name `/Request/onComplete` instead of the worng name `/Request/onHalfClose`. -* Add plugin to support for RESTeasy 4.x. +* Add plugin to support RESTeasy 4.x. +* Add plugin to support hutool-http 5.x. #### Documentation diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java index e9af24846..c3671ff69 100755 --- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java +++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java @@ -222,4 +222,6 @@ public class ComponentsDefine { public static final OfficialComponent GUAVA_EVENT_BUS = new OfficialComponent(123, "GuavaEventBus"); public static final OfficialComponent APACHE_SHENYU = new OfficialComponent(127, "Apache-ShenYu"); + + public static final OfficialComponent HUTOOL = new OfficialComponent(128, "Hutool"); } diff --git a/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/pom.xml new file mode 100644 index 000000000..65d907dab --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/pom.xml @@ -0,0 +1,47 @@ + + + + + hutool-plugins + org.apache.skywalking + 8.12.0-SNAPSHOT + + 4.0.0 + + apm-hutool-http-5.x-plugin + jar + + http://maven.apache.org + + 5.8.3 + + + + + cn.hutool + hutool-http + ${hutool.http.version} + provided + + + + + diff --git a/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/HutoolHttpExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/HutoolHttpExecuteInterceptor.java new file mode 100644 index 000000000..1d3389f31 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/HutoolHttpExecuteInterceptor.java @@ -0,0 +1,102 @@ +/* + * 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.hutool.http.v5; + +import cn.hutool.core.util.URLUtil; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import java.lang.reflect.Method; +import java.net.URL; +import org.apache.skywalking.apm.agent.core.context.CarrierItem; +import org.apache.skywalking.apm.agent.core.context.ContextCarrier; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.tag.Tags; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +public class HutoolHttpExecuteInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + final HttpRequest request = (HttpRequest) objInst; + final ContextCarrier contextCarrier = new ContextCarrier(); + final URL url = URLUtil.url(request.getUrl()); + + String remotePeer = getPeer(url); + String formatURIPath = url.getPath(); + AbstractSpan span = ContextManager.createExitSpan(formatURIPath, contextCarrier, remotePeer); + + span.setComponent(ComponentsDefine.HUTOOL); + Tags.HTTP.METHOD.set(span, request.getMethod().name()); + Tags.URL.set(span, url.toString()); + SpanLayer.asHttp(span); + + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + request.header(next.getHeadKey(), next.getHeadValue()); + } + } + + @Override + public Object afterMethod(final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) throws Throwable { + if (ret != null) { + HttpResponse response = (HttpResponse) ret; + int statusCode = response.getStatus(); + + AbstractSpan span = ContextManager.activeSpan(); + Tags.HTTP_RESPONSE_STATUS_CODE.set(span, statusCode); + if (statusCode >= 400) { + span.errorOccurred(); + } + } + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Throwable t) { + ContextManager.activeSpan().log(t); + } + + private String getPeer(URL url) { + String host = url.getHost(); + if (url.getPort() > 0) { + return host + ":" + url.getPort(); + } + return host; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/define/HutoolHttpInstrumentation.java b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/define/HutoolHttpInstrumentation.java new file mode 100644 index 000000000..4cc8a7623 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/hutool/http/v5/define/HutoolHttpInstrumentation.java @@ -0,0 +1,69 @@ +/* + * 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.hutool.http.v5.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 net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class HutoolHttpInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "cn.hutool.http.HttpRequest"; + + private static final String EXECUTE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.hutool.http.v5.HutoolHttpExecuteInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return null; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("execute").and(takesArguments(1)); + } + + @Override + public String getMethodsInterceptor() { + return EXECUTE_INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..dbf9f6ef2 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/hutool-plugins/hutool-http-5.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. + +hutool-http-5.x=org.apache.skywalking.apm.plugin.hutool.http.v5.define.HutoolHttpInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/hutool-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/hutool-plugins/pom.xml new file mode 100644 index 000000000..35d113936 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/hutool-plugins/pom.xml @@ -0,0 +1,41 @@ + + + + + apm-sdk-plugin + org.apache.skywalking + 8.12.0-SNAPSHOT + + 4.0.0 + + hutool-plugins + pom + + hutool-http-5.x-plugin + + + + UTF-8 + /.. + + + + diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml index 337eba602..ac5bd9735 100644 --- a/apm-sniffer/apm-sdk-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/pom.xml @@ -120,6 +120,7 @@ undertow-worker-thread-pool-plugin tomcat-thread-pool-plugin guava-eventbus-plugin + hutool-plugins pom diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index 7647f0a4d..7d7a40014 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -139,3 +139,4 @@ - guava-eventbus - shenyu-2.4.x - jdk-threadpool-plugin +- hutool-http-5.x 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 f566b9ad7..c18d22be1 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -29,6 +29,7 @@ metrics based on the tracing data. * [Apache httpcomponent AsyncClient](https://hc.apache.org/httpcomponents-asyncclient-4.1.x/) 4.x * [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client) 2.1+ * JRE HttpURLConnection (Optional²) + * [Hutool-http](https://www.hutool.cn/) client 5.x * HTTP Gateway * [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway) 2.0.2.RELEASE -> 3.x (Optional²) * [Apache ShenYu](https://shenyu.apache.org) (Rich protocol support: `HTTP`,`Spring Cloud`,`gRPC`,`Dubbo`,`SOFARPC`,`Motan`,`Tars`) 2.4.x (Optional²) diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/bin/startup.sh b/test/plugin/scenarios/hutool-http-5.x-scenario/bin/startup.sh new file mode 100644 index 000000000..eb615f20a --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.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/hutool-http-5.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/hutool-http-5.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000..223b0b022 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/config/expectedData.yaml @@ -0,0 +1,70 @@ +# 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: hutool-http-5.x-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: GET:/hutool-http-5.x-scenario/case/hutool + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/hutool-http-5.x-scenario/case/hutool'} + - {key: http.method, value: GET} + refs: + - {parentEndpoint: GET:/hutool-http-5.x-scenario/case/hutool-http-5.x-scenario, networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: hutool-http-5.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /hutool-http-5.x-scenario/case/hutool + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 128 + isError: false + spanType: Exit + peer: localhost:8080 + tags: + - {key: http.method, value: GET} + - {key: url, value: 'http://localhost:8080/hutool-http-5.x-scenario/case/hutool'} + - {key: http.status_code, value: '200'} + skipAnalysis: 'false' + - operationName: GET:/hutool-http-5.x-scenario/case/hutool-http-5.x-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/hutool-http-5.x-scenario/case/hutool-http-5.x-scenario'} + - {key: http.method, value: GET} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/configuration.yml b/test/plugin/scenarios/hutool-http-5.x-scenario/configuration.yml new file mode 100644 index 000000000..94378c544 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/configuration.yml @@ -0,0 +1,20 @@ +# 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/hutool-http-5.x-scenario/case/hutool-http-5.x-scenario +healthCheck: http://localhost:8080/hutool-http-5.x-scenario/case/healthCheck +startScript: ./bin/startup.sh diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/pom.xml b/test/plugin/scenarios/hutool-http-5.x-scenario/pom.xml new file mode 100644 index 000000000..40567b6dd --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/pom.xml @@ -0,0 +1,124 @@ + + + + + org.apache.skywalking.apm.testcase + hutool-http-5.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 5.8.3 + 2.1.6.RELEASE + 1.18.20 + + + skywalking-hutool-http-5.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 + + + org.projectlombok + lombok + ${lombok.version} + provided + + + cn.hutool + hutool-http + ${test.framework.version} + + + + + hutool-http-5.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + 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/hutool-http-5.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..ff42c5945 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/hutool-http-5.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/Application.java b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/Application.java new file mode 100644 index 000000000..6e5bc956a --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/Application.java @@ -0,0 +1,34 @@ +/* + * 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.hutoolhttp5; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +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/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/controller/CaseController.java b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/controller/CaseController.java new file mode 100644 index 000000000..66d69a698 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/hutoolhttp5/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.hutoolhttp5.controller; + +import cn.hutool.http.HttpUtil; +import lombok.extern.log4j.Log4j2; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +@Log4j2 +public class CaseController { + + private static final String SUCCESS = "Success"; + + @RequestMapping("/hutool-http-5.x-scenario") + @ResponseBody + public String testcase() { + // your codes + String result = HttpUtil.get("http://localhost:8080/hutool-http-5.x-scenario/case/hutool"); + return SUCCESS + ":" + result; + } + + @RequestMapping("/hutool") + @ResponseBody + public String hutool() { + return "hutool"; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + +} diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..bfbdee92c --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/application.yaml @@ -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. +# +# +server: + port: 8080 + servlet: + context-path: /hutool-http-5.x-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/hutool-http-5.x-scenario/support-version.list b/test/plugin/scenarios/hutool-http-5.x-scenario/support-version.list new file mode 100644 index 000000000..5e0927832 --- /dev/null +++ b/test/plugin/scenarios/hutool-http-5.x-scenario/support-version.list @@ -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. + +# lists your version here (Contains only the last version number of each minor version.) +5.0.7 +5.1.5 +5.2.5 +5.3.10 +5.4.7 +5.5.9 +5.6.7 +5.7.22 +5.8.3