From 986db3c6fe206dd01df3840edfd126e0e2d1b321 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 8 Apr 2020 13:17:31 -0400 Subject: [PATCH 01/25] vertx web plugin re-impl attempt --- .../vertx-web-3.x-scenario/bin/startup.sh | 21 +++ .../config/expectedData.yaml | 93 ++++++++++++ .../vertx-web-3.x-scenario/configuration.yml | 21 +++ .../scenarios/vertx-web-3.x-scenario/pom.xml | 138 ++++++++++++++++++ .../src/main/assembly/assembly.xml | 41 ++++++ .../apm/testcase/vertxweb/Application.java | 40 +++++ .../controller/VertxCoreController.java | 51 +++++++ .../src/main/resources/log4j2.xml | 30 ++++ .../support-version.list | 37 +++++ 9 files changed, 472 insertions(+) create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/bin/startup.sh b/test/plugin/scenarios/vertx-web-3.x-scenario/bin/startup.sh new file mode 100644 index 000000000000..856a33da16bb --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.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/vertx-web-3.x-scenario.jar & diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000000..c1e51ec35aea --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -0,0 +1,93 @@ +registryItems: + applications: + - {vertx-web-3.x-scenario: 2} + instances: + - {vertx-web-3.x-scenario: 1} + operationNames: + - vertx-web-3.x-scenario: [ + "/vertx-web-3-scenario/case/healthCheck", + "/vertx-web-3-scenario/case/web-case" + ] +segmentItems: +- applicationCode: vertx-web-3.x-scenario + segmentSize: 3 + segments: + - segmentId: nq 0 + spans: + - operationName: "/vertx-web-3-scenario/case/healthCheck" + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + tags: + - {key: "http.method", value: "GET"} + - {key: "url", value: "/vertx-web-3-scenario/case/healthCheck"} + startTime: nq 0 + endTime: nq 0 + componentId: 59 + componentName: "" + isError: false + spanType: Exit + peer: not null + peerId: 0 + - operationName: "/vertx-web-3-scenario/case/web-case" + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + tags: + - {key: "http.method", value: "GET"} + - {key: "url", value: "/vertx-web-3-scenario/case/web-case"} + startTime: nq 0 + endTime: nq 0 + componentId: 59 + componentName: "" + isError: false + spanType: Entry + peer: "" + peerId: 0 + - segmentId: nq 0 + spans: + - operationName: "#/vertx-web-3-scenario/case/healthCheck" + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + refs: + - {parentEndpointId: 0, parentEndpoint: "/vertx-web-3-scenario/case/web-case", + networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: "", + entryEndpoint: "/vertx-web-3-scenario/case/web-case", entryServiceInstanceId: 1} + startTime: nq 0 + endTime: nq 0 + componentId: 59 + componentName: "" + isError: false + spanType: Local + peer: "" + peerId: 0 + - segmentId: nq 0 + spans: + - operationName: "/vertx-web-3-scenario/case/healthCheck" + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + refs: + - {parentEndpointId: 0, parentEndpoint: "/vertx-web-3-scenario/case/web-case", + networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, + parentTraceSegmentId: not null, parentServiceInstanceId: 1, + networkAddress: "localhost:8080", + entryEndpoint: "/vertx-web-3-scenario/case/web-case", + entryServiceInstanceId: 1} + tags: + - {key: "http.method", value: "GET"} + - {key: "url", value: "/vertx-web-3-scenario/case/healthCheck"} + startTime: nq 0 + endTime: nq 0 + componentId: 59 + componentName: "" + isError: false + spanType: Entry + peer: "" + peerId: 0 diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml b/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml new file mode 100644 index 000000000000..236809d59ed9 --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml @@ -0,0 +1,21 @@ +# 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/vertx-web-3-scenario/case/web-case +healthCheck: http://localhost:8080/vertx-web-3-scenario/case/healthCheck +startScript: ./bin/startup.sh +framework: Vert.x diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml new file mode 100644 index 000000000000..93333b9b5f9b --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml @@ -0,0 +1,138 @@ + + + + 4.0.0 + + org.apache.skywalking + vertx-web-3.x-scenario + 5.0.0 + skywalking-vertx-web-3.x-scenario + + + UTF-8 + 1.8 + 2.6.2 + 1.5.2.RELEASE + 3.6.3 + 3 + + + + + io.vertx + vertx-web + ${vertx.version} + + + + + org.springframework.boot + spring-boot-starter + ${spring-boot-version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + org.apache.logging.log4j + log4j-slf4j-impl + ${log4j.version} + + + org.apache.logging.log4j + log4j-jcl + ${log4j.version} + + + org.springframework.boot + spring-boot-starter-tomcat + ${spring-boot-version} + + + org.springframework.boot + spring-boot-starter-web + ${spring-boot-version} + + + + + vertx-web-3.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/ + + + + + + + + + + spring-snapshots + http://repo.spring.io/snapshot + + + spring-milestones + http://repo.spring.io/milestone + + + diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000000..0494bce21351 --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/vertx-web-3.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java new file mode 100644 index 000000000000..dadafb0959ec --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.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.vertxweb; + +import io.vertx.core.Vertx; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.apache.skywalking.apm.testcase.vertxweb.controller.VertxCoreController; + +public class Application { + + private static final Logger logger = LogManager.getLogger(Application.class); + + public static void main(String[] args) { + logger.info("Application started"); + + System.setProperty("vertx.disableFileCPResolving", "true"); + Vertx.vertx().deployVerticle(new VertxCoreController(), it -> { + if (it.failed()) { + it.cause().printStackTrace(); + System.exit(-1); + } + }); + } +} diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java new file mode 100644 index 000000000000..64445a8b9a76 --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java @@ -0,0 +1,51 @@ +/* + * 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.vertxweb.controller; + +import io.vertx.core.AbstractVerticle; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import org.apache.log4j.LogManager; +import org.apache.log4j.Logger; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class VertxCoreController extends AbstractVerticle { + + private static final Logger logger = LogManager.getLogger(VertxCoreController.class); + + @Override + public void start() { + logger.info("VertxCoreController started"); + + Router router = Router.router(vertx); + router.get("/vertx-web-3-scenario/case/web-case").handler(this::handleCoreCase); + router.get("/vertx-web-3-scenario/case/healthCheck").handler(this::healthCheck); + vertx.createHttpServer().requestHandler(router::accept).listen(8080); + } + + private void handleCoreCase(RoutingContext routingContext) { + vertx.createHttpClient().getNow(8080, "localhost", + "/vertx-web-3-scenario/case/healthCheck", + it -> routingContext.response().setStatusCode(it.statusCode()).end()); + } + + private void healthCheck(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); + } +} diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000000..ca19f179c233 --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list b/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list new file mode 100644 index 000000000000..3582c97d124d --- /dev/null +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list @@ -0,0 +1,37 @@ +# 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. + +3.7.0 +3.6.3 +3.6.2 +3.6.1 +3.6.0 +3.5.4 +3.5.3 +3.5.2 +3.5.1 +3.5.0 +3.4.2 +3.4.1 +3.4.0 +3.3.3 +3.3.2 +3.3.1 +3.3.0 +3.2.1 +3.2.0 +3.1.0 +3.0.0 From cf3665681e1e9fe594529a939a06802dd874117e Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 9 Apr 2020 02:11:59 -0400 Subject: [PATCH 02/25] added license --- .../config/expectedData.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index c1e51ec35aea..09762b86de34 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -1,3 +1,18 @@ +# 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: applications: - {vertx-web-3.x-scenario: 2} From 87d22ab647a08bf2bb45c3951bbeb91376f0dfe2 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 22 Apr 2020 12:10:23 -0400 Subject: [PATCH 03/25] update test for new plugin structure --- .../config/expectedData.yaml | 137 +++++++----------- .../vertx-web-3.x-scenario/configuration.yml | 1 - .../scenarios/vertx-web-3.x-scenario/pom.xml | 91 +++++------- .../apm/testcase/vertxweb/Application.java | 6 - .../controller/VertxCoreController.java | 10 +- 5 files changed, 94 insertions(+), 151 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index 09762b86de34..7f89f199e2bf 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -24,85 +24,58 @@ registryItems: "/vertx-web-3-scenario/case/web-case" ] segmentItems: -- applicationCode: vertx-web-3.x-scenario - segmentSize: 3 - segments: - - segmentId: nq 0 - spans: - - operationName: "/vertx-web-3-scenario/case/healthCheck" - operationId: 0 - parentSpanId: 0 - spanId: 1 - spanLayer: Http - tags: - - {key: "http.method", value: "GET"} - - {key: "url", value: "/vertx-web-3-scenario/case/healthCheck"} - startTime: nq 0 - endTime: nq 0 - componentId: 59 - componentName: "" - isError: false - spanType: Exit - peer: not null - peerId: 0 - - operationName: "/vertx-web-3-scenario/case/web-case" - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - tags: - - {key: "http.method", value: "GET"} - - {key: "url", value: "/vertx-web-3-scenario/case/web-case"} - startTime: nq 0 - endTime: nq 0 - componentId: 59 - componentName: "" - isError: false - spanType: Entry - peer: "" - peerId: 0 - - segmentId: nq 0 - spans: - - operationName: "#/vertx-web-3-scenario/case/healthCheck" - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - refs: - - {parentEndpointId: 0, parentEndpoint: "/vertx-web-3-scenario/case/web-case", - networkAddressId: 0, entryEndpointId: 0, refType: CrossThread, parentSpanId: 1, - parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: "", - entryEndpoint: "/vertx-web-3-scenario/case/web-case", entryServiceInstanceId: 1} - startTime: nq 0 - endTime: nq 0 - componentId: 59 - componentName: "" - isError: false - spanType: Local - peer: "" - peerId: 0 - - segmentId: nq 0 - spans: - - operationName: "/vertx-web-3-scenario/case/healthCheck" - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - refs: - - {parentEndpointId: 0, parentEndpoint: "/vertx-web-3-scenario/case/web-case", - networkAddressId: 0, entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, - parentTraceSegmentId: not null, parentServiceInstanceId: 1, - networkAddress: "localhost:8080", - entryEndpoint: "/vertx-web-3-scenario/case/web-case", - entryServiceInstanceId: 1} - tags: - - {key: "http.method", value: "GET"} - - {key: "url", value: "/vertx-web-3-scenario/case/healthCheck"} - startTime: nq 0 - endTime: nq 0 - componentId: 59 - componentName: "" - isError: false - spanType: Entry - peer: "" - peerId: 0 + - serviceName: vertx-web-3.x-scenario + segmentSize: 2 + segments: + - segmentId: nq 0 + spans: + - operationName: /vertx-web-3-scenario/case/healthCheck + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Exit + peer: localhost:8080 + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-web-3-scenario/case/healthCheck} + - operationName: /vertx-web-3-scenario/case/web-case + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-web-3-scenario/case/web-case} + - segmentId: nq 0 + spans: + - operationName: '#/vertx-web-3-scenario/case/healthCheck' + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - {parentEndpoint: /vertx-web-3-scenario/case/web-case, networkAddress: '', + refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.x-scenario, + traceId: not null} + diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml b/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml index 236809d59ed9..4be3c902de14 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/configuration.yml @@ -18,4 +18,3 @@ type: jvm entryService: http://localhost:8080/vertx-web-3-scenario/case/web-case healthCheck: http://localhost:8080/vertx-web-3-scenario/case/healthCheck startScript: ./bin/startup.sh -framework: Vert.x diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml index 93333b9b5f9b..1a54b80417be 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml @@ -19,64 +19,61 @@ - 4.0.0 - org.apache.skywalking + org.apache.skywalking.apm.testcase vertx-web-3.x-scenario - 5.0.0 - skywalking-vertx-web-3.x-scenario + 1.0.0 + jar + + 4.0.0 UTF-8 1.8 - 2.6.2 - 1.5.2.RELEASE - 3.6.3 - 3 + 3.7.0 + 2.1.6.RELEASE + 1.18.10 - - - io.vertx - vertx-web - ${vertx.version} - + skywalking-vertx-web-3.x-scenario - + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot-version} + pom + import + + + + + org.springframework.boot - spring-boot-starter - ${spring-boot-version} - - - org.apache.logging.log4j - log4j-api - ${log4j.version} - - - org.apache.logging.log4j - log4j-core - ${log4j.version} + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} + org.springframework.boot + spring-boot-starter-log4j2 - org.apache.logging.log4j - log4j-jcl - ${log4j.version} + org.projectlombok + lombok + ${lombok.version} + provided - org.springframework.boot - spring-boot-starter-tomcat - ${spring-boot-version} - - - org.springframework.boot - spring-boot-starter-web - ${spring-boot-version} + io.vertx + vertx-web + ${test.framework.version} @@ -86,7 +83,6 @@ org.springframework.boot spring-boot-maven-plugin - 1.5.9.RELEASE @@ -124,15 +120,4 @@ - - - - spring-snapshots - http://repo.spring.io/snapshot - - - spring-milestones - http://repo.spring.io/milestone - - diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java index dadafb0959ec..f4eeffe9a453 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java @@ -18,17 +18,11 @@ package org.apache.skywalking.apm.testcase.vertxweb; import io.vertx.core.Vertx; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; import org.apache.skywalking.apm.testcase.vertxweb.controller.VertxCoreController; public class Application { - private static final Logger logger = LogManager.getLogger(Application.class); - public static void main(String[] args) { - logger.info("Application started"); - System.setProperty("vertx.disableFileCPResolving", "true"); Vertx.vertx().deployVerticle(new VertxCoreController(), it -> { if (it.failed()) { diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java index 64445a8b9a76..f48bdacfdf11 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java @@ -20,22 +20,14 @@ import io.vertx.core.AbstractVerticle; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; -import org.apache.log4j.LogManager; -import org.apache.log4j.Logger; -import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication public class VertxCoreController extends AbstractVerticle { - private static final Logger logger = LogManager.getLogger(VertxCoreController.class); - @Override public void start() { - logger.info("VertxCoreController started"); - Router router = Router.router(vertx); router.get("/vertx-web-3-scenario/case/web-case").handler(this::handleCoreCase); - router.get("/vertx-web-3-scenario/case/healthCheck").handler(this::healthCheck); + router.head("/vertx-web-3-scenario/case/healthCheck").handler(this::healthCheck); vertx.createHttpServer().requestHandler(router::accept).listen(8080); } From 300499b153a580780c2186d3f00ca2ab65a28582 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 22 Apr 2020 12:16:17 -0400 Subject: [PATCH 04/25] got rid of registryItems --- .../vertx-web-3.x-scenario/config/expectedData.yaml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index 7f89f199e2bf..a8be66ceabf3 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -13,16 +13,6 @@ # 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: - applications: - - {vertx-web-3.x-scenario: 2} - instances: - - {vertx-web-3.x-scenario: 1} - operationNames: - - vertx-web-3.x-scenario: [ - "/vertx-web-3-scenario/case/healthCheck", - "/vertx-web-3-scenario/case/web-case" - ] segmentItems: - serviceName: vertx-web-3.x-scenario segmentSize: 2 From 81acb7ffea0850e938b70ed50f4abe063d450131 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 01:28:37 -0400 Subject: [PATCH 05/25] remove unnecessary dependencies --- .../scenarios/vertx-web-3.x-scenario/pom.xml | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml index 1a54b80417be..58d64e9894b6 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml @@ -31,45 +31,11 @@ UTF-8 1.8 3.7.0 - 2.1.6.RELEASE - 1.18.10 skywalking-vertx-web-3.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 - io.vertx vertx-web From 2fd69d3095e3ae0e91b49f0c073c42f692659250 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 02:10:58 -0400 Subject: [PATCH 06/25] re-impl eventbus scenario --- .../bin/startup.sh | 21 +++ .../config/expectedData.yaml | 140 ++++++++++++++++++ .../configuration.yml | 20 +++ .../vertx-eventbus-3.x-scenario/pom.xml | 99 +++++++++++++ .../src/main/assembly/assembly.xml | 41 +++++ .../testcase/vertxeventbus/Application.java | 59 ++++++++ .../controller/ClusterReceiver.java | 21 +++ .../controller/LocalReceiver.java | 18 +++ .../controller/VertxEventbusController.java | 94 ++++++++++++ .../vertxeventbus/util/CustomMessage.java | 35 +++++ .../util/CustomMessageCodec.java | 49 ++++++ .../src/main/resources/log4j2.xml | 30 ++++ .../support-version.list | 37 +++++ 13 files changed, 664 insertions(+) create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/bin/startup.sh b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/bin/startup.sh new file mode 100644 index 000000000000..a737278b5c4d --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.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/vertx-eventbus-3.x-scenario.jar & diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml new file mode 100644 index 000000000000..6b2fcb6537d7 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml @@ -0,0 +1,140 @@ +# 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: vertx-eventbus-3.x-scenario + segmentSize: 7 + segments: + - segmentId: not null + spans: + - operationName: local-message-receiver + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - {parentEndpoint: local-message-receiver, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, + traceId: not null} + - segmentId: not null + spans: + - {operationName: local-message-receiver, operationId: 0, parentSpanId: -1, spanId: 0, + spanLayer: RPCFramework, startTime: nq 0, endTime: nq 0, componentId: 59, + isError: false, spanType: Local, peer: '', skipAnalysis: false} + - segmentId: not null + spans: + - operationName: /vertx-eventbus-3-scenario/case/executeTest + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Exit + peer: localhost:8080 + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + - operationName: /vertx-eventbus-3-scenario/case/eventbus-case + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-eventbus-3-scenario/case/eventbus-case} + - segmentId: not null + spans: + - operationName: '#/vertx-eventbus-3-scenario/case/executeTest' + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + refs: + - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: '', + refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: cluster-message-receiver + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + refs: + - {parentEndpoint: cluster-message-receiver, networkAddress: 'localhost:41615', + refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, + traceId: not null} + - segmentId: not nullnot null + spans: + - {operationName: cluster-message-receiver, operationId: 0, parentSpanId: -1, + spanId: 0, spanLayer: RPCFramework, startTime: nq 0, endTime: nq 0, + componentId: 59, isError: false, spanType: Exit, peer: 'localhost:41615', skipAnalysis: false} + - segmentId: not null + spans: + - operationName: /vertx-eventbus-3-scenario/case/executeTest + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + refs: + - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, + traceId: not null} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/configuration.yml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/configuration.yml new file mode 100644 index 000000000000..995bfa6f3522 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.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/vertx-eventbus-3-scenario/case/eventbus-case +healthCheck: http://localhost:8080/vertx-eventbus-3-scenario/case/healthCheck +startScript: ./bin/startup.sh diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml new file mode 100644 index 000000000000..2765e6ab1cb7 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml @@ -0,0 +1,99 @@ + + + + + org.apache.skywalking.apm.testcase + vertx-eventbus-3.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.7.0 + + + skywalking-vertx-eventbus-3.x-scenario + + + + io.vertx + vertx-core + ${test.framework.version} + + + io.vertx + vertx-web + ${test.framework.version} + + + io.vertx + vertx-hazelcast + ${test.framework.version} + + + + + vertx-eventbus-3.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + + + + 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/vertx-eventbus-3.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000000..d0220acf0942 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/vertx-eventbus-3.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java new file mode 100644 index 000000000000..1295bdbca733 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java @@ -0,0 +1,59 @@ +/* + * 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.vertxeventbus; + +import io.vertx.core.Vertx; +import io.vertx.core.VertxOptions; +import io.vertx.core.spi.cluster.ClusterManager; +import io.vertx.spi.cluster.hazelcast.HazelcastClusterManager; + +import org.apache.skywalking.apm.testcase.vertxeventbus.controller.ClusterReceiver; +import org.apache.skywalking.apm.testcase.vertxeventbus.controller.VertxEventbusController; + +public class Application { + + public static void main(String[] args) { + ClusterManager mgr = new HazelcastClusterManager(); + VertxOptions options = new VertxOptions().setClusterManager(mgr); + Vertx.clusteredVertx(options, cluster -> { + if (cluster.succeeded()) { + cluster.result().deployVerticle(new ClusterReceiver(), deploy -> { + if (deploy.succeeded()) { + ClusterManager mgr2 = new HazelcastClusterManager(); + VertxOptions options2 = new VertxOptions().setClusterManager(mgr2); + Vertx.clusteredVertx(options2, cluster2 -> { + if (cluster2.succeeded()) { + cluster2.result().deployVerticle(new VertxEventbusController()); + } else { + cluster2.cause().printStackTrace(); + System.exit(-1); + } + }); + } else { + deploy.cause().printStackTrace(); + System.exit(-1); + } + }); + } else { + cluster.cause().printStackTrace(); + System.exit(-1); + } + }); + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java new file mode 100644 index 000000000000..e33471d9f715 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java @@ -0,0 +1,21 @@ +package org.apache.skywalking.apm.testcase.vertxeventbus.controller; + +import io.vertx.core.AbstractVerticle; +import io.vertx.core.eventbus.EventBus; +import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessage; +import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessageCodec; + +public class ClusterReceiver extends AbstractVerticle { + + @Override + public void start() { + EventBus eventBus = getVertx().eventBus(); + eventBus.registerDefaultCodec(CustomMessage.class, new CustomMessageCodec()); + + eventBus.consumer("cluster-message-receiver", message -> { + CustomMessage replyMessage = new CustomMessage(200, + "a00000002", "Message sent from cluster receiver!"); + message.reply(replyMessage); + }); + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java new file mode 100644 index 000000000000..102bfc1193bd --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java @@ -0,0 +1,18 @@ +package org.apache.skywalking.apm.testcase.vertxeventbus.controller; + +import io.vertx.core.AbstractVerticle; +import io.vertx.core.eventbus.EventBus; +import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessage; + +public class LocalReceiver extends AbstractVerticle { + + @Override + public void start() { + EventBus eventBus = getVertx().eventBus(); + eventBus.consumer("local-message-receiver", message -> { + CustomMessage replyMessage = new CustomMessage(200, + "a00000002", "Message sent from local receiver!"); + message.reply(replyMessage); + }); + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java new file mode 100644 index 000000000000..be7b53d0e393 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java @@ -0,0 +1,94 @@ +/* + * 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.vertxeventbus.controller; + +import io.vertx.core.AbstractVerticle; +import io.vertx.core.Future; +import io.vertx.core.json.Json; +import io.vertx.ext.web.Router; +import io.vertx.ext.web.RoutingContext; +import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessage; +import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessageCodec; + +public class VertxEventbusController extends AbstractVerticle { + + @Override + public void start() { + Router router = Router.router(vertx); + router.get("/vertx-eventbus-3-scenario/case/eventbus-case").handler(this::handleCoreCase); + router.get("/vertx-eventbus-3-scenario/case/executeTest").handler(this::executeTest); + router.head("/vertx-eventbus-3-scenario/case/healthCheck").handler(this::healthCheck); + vertx.createHttpServer().requestHandler(router::accept).listen(8080); + + vertx.eventBus().registerDefaultCodec(CustomMessage.class, new CustomMessageCodec()); + vertx.deployVerticle(LocalReceiver.class.getName()); + } + + private void handleCoreCase(RoutingContext routingContext) { + vertx.createHttpClient().getNow(8080, "localhost", + "/vertx-eventbus-3-scenario/case/executeTest", + it -> routingContext.response().setStatusCode(it.statusCode()).end()); + } + + private void executeTest(RoutingContext routingContext) { + Future localMessageFuture = Future.future(); + CustomMessage localMessage = new CustomMessage(200, + "a0000001", "Local message!"); + vertx.eventBus().send("local-message-receiver", localMessage, reply -> { + if (reply.succeeded()) { + CustomMessage replyMessage = (CustomMessage) reply.result().body(); + System.out.println("Received local reply: " + replyMessage.getSummary()); + localMessageFuture.complete(); + } else { + localMessageFuture.fail(reply.cause()); + } + }); + + Future clusterMessageFuture = Future.future(); + CustomMessage clusterWideMessage = new CustomMessage(200, + "a00000001", "Message sent from publisher!"); + vertx.eventBus().send("cluster-message-receiver", clusterWideMessage, reply -> { + if (reply.succeeded()) { + CustomMessage replyMessage = (CustomMessage) reply.result().body(); + System.out.println("Received reply: " + replyMessage.getSummary()); + clusterMessageFuture.complete(); + } else { + clusterMessageFuture.fail(reply.cause()); + } + }); + + localMessageFuture.setHandler(localHandler -> { + if (localHandler.succeeded()) { + clusterMessageFuture.setHandler(clusterHandler -> { + if (clusterHandler.succeeded()) { + routingContext.response().setStatusCode(200).end(); + } else { + routingContext.response().setStatusCode(500).end(Json.encodePrettily(clusterHandler.cause())); + } + }); + } else { + routingContext.response().setStatusCode(500).end(Json.encodePrettily(localHandler.cause())); + } + }); + } + + private void healthCheck(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java new file mode 100644 index 000000000000..91db968426a3 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java @@ -0,0 +1,35 @@ +package org.apache.skywalking.apm.testcase.vertxeventbus.util; + +public class CustomMessage { + private final int statusCode; + private final String resultCode; + private final String summary; + + public CustomMessage(int statusCode, String resultCode, String summary) { + this.statusCode = statusCode; + this.resultCode = resultCode; + this.summary = summary; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("CustomMessage{"); + sb.append("statusCode=").append(statusCode); + sb.append(", resultCode='").append(resultCode).append('\''); + sb.append(", summary='").append(summary).append('\''); + sb.append('}'); + return sb.toString(); + } + + public int getStatusCode() { + return statusCode; + } + + public String getResultCode() { + return resultCode; + } + + public String getSummary() { + return summary; + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java new file mode 100644 index 000000000000..3273c294127b --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java @@ -0,0 +1,49 @@ +package org.apache.skywalking.apm.testcase.vertxeventbus.util; + +import io.vertx.core.buffer.Buffer; +import io.vertx.core.eventbus.MessageCodec; +import io.vertx.core.json.JsonObject; + +public class CustomMessageCodec implements MessageCodec { + + @Override + public void encodeToWire(Buffer buffer, CustomMessage customMessage) { + JsonObject jsonToEncode = new JsonObject(); + jsonToEncode.put("statusCode", customMessage.getStatusCode()); + jsonToEncode.put("resultCode", customMessage.getResultCode()); + jsonToEncode.put("summary", customMessage.getSummary()); + + String jsonToStr = jsonToEncode.encode(); + int length = jsonToStr.getBytes().length; + buffer.appendInt(length); + buffer.appendString(jsonToStr); + } + + @Override + public CustomMessage decodeFromWire(int position, Buffer buffer) { + int _pos = position; + int length = buffer.getInt(_pos); + String jsonStr = buffer.getString(_pos += 4, _pos += length); + JsonObject contentJson = new JsonObject(jsonStr); + + int statusCode = contentJson.getInteger("statusCode"); + String resultCode = contentJson.getString("resultCode"); + String summary = contentJson.getString("summary"); + return new CustomMessage(statusCode, resultCode, summary); + } + + @Override + public CustomMessage transform(CustomMessage customMessage) { + return customMessage; + } + + @Override + public String name() { + return this.getClass().getSimpleName(); + } + + @Override + public byte systemCodecID() { + return -1; + } +} diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000000..ca19f179c233 --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list new file mode 100644 index 000000000000..3582c97d124d --- /dev/null +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list @@ -0,0 +1,37 @@ +# 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. + +3.7.0 +3.6.3 +3.6.2 +3.6.1 +3.6.0 +3.5.4 +3.5.3 +3.5.2 +3.5.1 +3.5.0 +3.4.2 +3.4.1 +3.4.0 +3.3.3 +3.3.2 +3.3.1 +3.3.0 +3.2.1 +3.2.0 +3.1.0 +3.0.0 From 959542d095f18d4e2a5fefd25c4b2f7c35c59adc Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 02:21:35 -0400 Subject: [PATCH 07/25] more precise naming --- .../apache/skywalking/apm/testcase/vertxweb/Application.java | 4 ++-- .../{VertxCoreController.java => VertxWebController.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/{VertxCoreController.java => VertxWebController.java} (96%) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java index f4eeffe9a453..9dce7c37ee58 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java @@ -18,13 +18,13 @@ package org.apache.skywalking.apm.testcase.vertxweb; import io.vertx.core.Vertx; -import org.apache.skywalking.apm.testcase.vertxweb.controller.VertxCoreController; +import org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController; public class Application { public static void main(String[] args) { System.setProperty("vertx.disableFileCPResolving", "true"); - Vertx.vertx().deployVerticle(new VertxCoreController(), it -> { + Vertx.vertx().deployVerticle(new VertxWebController(), it -> { if (it.failed()) { it.cause().printStackTrace(); System.exit(-1); diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java similarity index 96% rename from test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java rename to test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java index f48bdacfdf11..40c70f3734ae 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxCoreController.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java @@ -21,7 +21,7 @@ import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; -public class VertxCoreController extends AbstractVerticle { +public class VertxWebController extends AbstractVerticle { @Override public void start() { From aa0fd16adeee64c93874e0abde18cde37bd95583 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 02:22:52 -0400 Subject: [PATCH 08/25] fix expected data --- .../vertx-eventbus-3.x-scenario/config/expectedData.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml index 6b2fcb6537d7..27acc2621c86 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml @@ -107,15 +107,15 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: cluster-message-receiver, networkAddress: 'localhost:41615', + - {parentEndpoint: cluster-message-receiver, networkAddress: not null, refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, traceId: not null} - - segmentId: not nullnot null + - segmentId: not null spans: - {operationName: cluster-message-receiver, operationId: 0, parentSpanId: -1, spanId: 0, spanLayer: RPCFramework, startTime: nq 0, endTime: nq 0, - componentId: 59, isError: false, spanType: Exit, peer: 'localhost:41615', skipAnalysis: false} + componentId: 59, isError: false, spanType: Exit, peer: not null, skipAnalysis: false} - segmentId: not null spans: - operationName: /vertx-eventbus-3-scenario/case/executeTest From db347e961176dc4c36871d38432d14b64352932c Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 02:54:35 -0400 Subject: [PATCH 09/25] removed unsupported versions and removed vertx caching (avoids permission error) --- .../skywalking/apm/testcase/vertxeventbus/Application.java | 1 + .../scenarios/vertx-eventbus-3.x-scenario/support-version.list | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java index 1295bdbca733..867b9077e2d9 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java @@ -29,6 +29,7 @@ public class Application { public static void main(String[] args) { + System.setProperty("vertx.disableFileCPResolving", "true"); ClusterManager mgr = new HazelcastClusterManager(); VertxOptions options = new VertxOptions().setClusterManager(mgr); Vertx.clusteredVertx(options, cluster -> { diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list index 3582c97d124d..8273d93a6101 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list @@ -33,5 +33,3 @@ 3.3.0 3.2.1 3.2.0 -3.1.0 -3.0.0 From 4a877c01739fc119426bc3b097728f3a094ba9ce Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 23 Apr 2020 03:41:20 -0400 Subject: [PATCH 10/25] rewrote to remove copied code --- .../testcase/vertxeventbus/Application.java | 1 - .../controller/ClusterReceiver.java | 26 +++++++--- .../controller/LocalReceiver.java | 26 +++++++--- .../controller/VertxEventbusController.java | 11 ++--- .../vertxeventbus/util/CustomMessage.java | 48 +++++++++---------- .../util/CustomMessageCodec.java | 43 ++++++++++------- 6 files changed, 90 insertions(+), 65 deletions(-) diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java index 867b9077e2d9..fbfb84c4c948 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/Application.java @@ -15,7 +15,6 @@ * limitations under the License. * */ - package org.apache.skywalking.apm.testcase.vertxeventbus; import io.vertx.core.Vertx; diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java index e33471d9f715..1a2a2a6fc238 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/ClusterReceiver.java @@ -1,3 +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. + * + */ package org.apache.skywalking.apm.testcase.vertxeventbus.controller; import io.vertx.core.AbstractVerticle; @@ -9,13 +26,10 @@ public class ClusterReceiver extends AbstractVerticle { @Override public void start() { - EventBus eventBus = getVertx().eventBus(); + EventBus eventBus = vertx.eventBus(); eventBus.registerDefaultCodec(CustomMessage.class, new CustomMessageCodec()); - eventBus.consumer("cluster-message-receiver", message -> { - CustomMessage replyMessage = new CustomMessage(200, - "a00000002", "Message sent from cluster receiver!"); - message.reply(replyMessage); - }); + eventBus.consumer("cluster-message-receiver", + message -> message.reply(new CustomMessage("cluster-message-receiver reply"))); } } diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java index 102bfc1193bd..561954d54c27 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/LocalReceiver.java @@ -1,18 +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.vertxeventbus.controller; import io.vertx.core.AbstractVerticle; -import io.vertx.core.eventbus.EventBus; import org.apache.skywalking.apm.testcase.vertxeventbus.util.CustomMessage; public class LocalReceiver extends AbstractVerticle { @Override public void start() { - EventBus eventBus = getVertx().eventBus(); - eventBus.consumer("local-message-receiver", message -> { - CustomMessage replyMessage = new CustomMessage(200, - "a00000002", "Message sent from local receiver!"); - message.reply(replyMessage); - }); + vertx.eventBus().consumer("local-message-receiver", + message -> message.reply(new CustomMessage("local-message-receiver reply"))); } } diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java index be7b53d0e393..7e9981779e98 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java @@ -15,7 +15,6 @@ * limitations under the License. * */ - package org.apache.skywalking.apm.testcase.vertxeventbus.controller; import io.vertx.core.AbstractVerticle; @@ -48,12 +47,11 @@ private void handleCoreCase(RoutingContext routingContext) { private void executeTest(RoutingContext routingContext) { Future localMessageFuture = Future.future(); - CustomMessage localMessage = new CustomMessage(200, - "a0000001", "Local message!"); + CustomMessage localMessage = new CustomMessage("local-message-receiver request"); vertx.eventBus().send("local-message-receiver", localMessage, reply -> { if (reply.succeeded()) { CustomMessage replyMessage = (CustomMessage) reply.result().body(); - System.out.println("Received local reply: " + replyMessage.getSummary()); + System.out.println("Received local reply: " + replyMessage.getMessage()); localMessageFuture.complete(); } else { localMessageFuture.fail(reply.cause()); @@ -61,12 +59,11 @@ private void executeTest(RoutingContext routingContext) { }); Future clusterMessageFuture = Future.future(); - CustomMessage clusterWideMessage = new CustomMessage(200, - "a00000001", "Message sent from publisher!"); + CustomMessage clusterWideMessage = new CustomMessage("cluster-message-receiver request"); vertx.eventBus().send("cluster-message-receiver", clusterWideMessage, reply -> { if (reply.succeeded()) { CustomMessage replyMessage = (CustomMessage) reply.result().body(); - System.out.println("Received reply: " + replyMessage.getSummary()); + System.out.println("Received cluster reply: " + replyMessage.getMessage()); clusterMessageFuture.complete(); } else { clusterMessageFuture.fail(reply.cause()); diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java index 91db968426a3..df22264c47b3 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessage.java @@ -1,35 +1,31 @@ +/* + * 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.vertxeventbus.util; public class CustomMessage { - private final int statusCode; - private final String resultCode; - private final String summary; - public CustomMessage(int statusCode, String resultCode, String summary) { - this.statusCode = statusCode; - this.resultCode = resultCode; - this.summary = summary; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder("CustomMessage{"); - sb.append("statusCode=").append(statusCode); - sb.append(", resultCode='").append(resultCode).append('\''); - sb.append(", summary='").append(summary).append('\''); - sb.append('}'); - return sb.toString(); - } - - public int getStatusCode() { - return statusCode; - } + private final String message; - public String getResultCode() { - return resultCode; + public CustomMessage(String message) { + this.message = message; } - public String getSummary() { - return summary; + public String getMessage() { + return message; } } diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java index 3273c294127b..84b3c176732a 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/util/CustomMessageCodec.java @@ -1,35 +1,42 @@ +/* + * 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.vertxeventbus.util; import io.vertx.core.buffer.Buffer; import io.vertx.core.eventbus.MessageCodec; +import io.vertx.core.json.Json; import io.vertx.core.json.JsonObject; public class CustomMessageCodec implements MessageCodec { @Override public void encodeToWire(Buffer buffer, CustomMessage customMessage) { - JsonObject jsonToEncode = new JsonObject(); - jsonToEncode.put("statusCode", customMessage.getStatusCode()); - jsonToEncode.put("resultCode", customMessage.getResultCode()); - jsonToEncode.put("summary", customMessage.getSummary()); - - String jsonToStr = jsonToEncode.encode(); - int length = jsonToStr.getBytes().length; + String jsonStr = Json.encode(customMessage); + int length = jsonStr.getBytes().length; buffer.appendInt(length); - buffer.appendString(jsonToStr); + buffer.appendString(jsonStr); } @Override public CustomMessage decodeFromWire(int position, Buffer buffer) { - int _pos = position; - int length = buffer.getInt(_pos); - String jsonStr = buffer.getString(_pos += 4, _pos += length); - JsonObject contentJson = new JsonObject(jsonStr); - - int statusCode = contentJson.getInteger("statusCode"); - String resultCode = contentJson.getString("resultCode"); - String summary = contentJson.getString("summary"); - return new CustomMessage(statusCode, resultCode, summary); + int length = buffer.getInt(position); + JsonObject jsonMessage = new JsonObject(buffer.getString(position += 4, position + length)); + return new CustomMessage(jsonMessage.getString("message")); } @Override @@ -39,7 +46,7 @@ public CustomMessage transform(CustomMessage customMessage) { @Override public String name() { - return this.getClass().getSimpleName(); + return getClass().getSimpleName(); } @Override From 21cebc255e25dfe9e82f59da58ccc6c71f8c5722 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 24 Apr 2020 12:11:24 +0400 Subject: [PATCH 11/25] Update plugins-test.3.yaml --- .github/workflows/plugins-test.3.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index f330223de035..dbd4d12bc877 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -41,6 +41,8 @@ jobs: - { name: 'spring-4.1.x-scenario', title: 'Spring 4.1.x-4.2.x (20)' } - { name: 'spring-4.3.x-scenario', title: 'Spring 4.3.x-5.2.x (54)' } - { name: 'spring-async-scenario', title: 'Spring Async 4.3.x-5.1.x (35)' } + - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.x-3.7.x (19)' } + - { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.x-3.7.x (21)' } steps: - uses: actions/checkout@v2 - name: checkout submodules From b4ad628209307c063cd77054fa5e03ab3ee9f422 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 24 Apr 2020 05:44:28 -0400 Subject: [PATCH 12/25] fixes issue of .vertx files remaining on v3.0.0 --- .../apm/testcase/vertxweb/Application.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java index 9dce7c37ee58..aa39f6906e64 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java @@ -20,11 +20,24 @@ import io.vertx.core.Vertx; import org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Comparator; + public class Application { - public static void main(String[] args) { + public static void main(String[] args) throws IOException { + //ensures .vertx files are uncreated/deleted System.setProperty("vertx.disableFileCPResolving", "true"); - Vertx.vertx().deployVerticle(new VertxWebController(), it -> { + Vertx vertx = Vertx.vertx(); + Files.walk(new File(".vertx").toPath()) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + + vertx.deployVerticle(new VertxWebController(), it -> { if (it.failed()) { it.cause().printStackTrace(); System.exit(-1); From b876173ef60dfc37de2c7315a08967c181648a26 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Fri, 24 Apr 2020 06:12:51 -0400 Subject: [PATCH 13/25] only present in v3.0.0 --- .../skywalking/apm/testcase/vertxweb/Application.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java index aa39f6906e64..71cdfa4e08e2 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/Application.java @@ -32,10 +32,12 @@ public static void main(String[] args) throws IOException { //ensures .vertx files are uncreated/deleted System.setProperty("vertx.disableFileCPResolving", "true"); Vertx vertx = Vertx.vertx(); - Files.walk(new File(".vertx").toPath()) - .sorted(Comparator.reverseOrder()) - .map(Path::toFile) - .forEach(File::delete); + if (new File(".vertx").exists()) { + Files.walk(new File(".vertx").toPath()) + .sorted(Comparator.reverseOrder()) + .map(Path::toFile) + .forEach(File::delete); + } vertx.deployVerticle(new VertxWebController(), it -> { if (it.failed()) { From d57a3c352c786afeefaec98628888b2698f94752 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 09:51:01 -0400 Subject: [PATCH 14/25] consistency --- .../scenarios/vertx-web-3.x-scenario/config/expectedData.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index a8be66ceabf3..1c0e3bd2ec75 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -17,7 +17,7 @@ segmentItems: - serviceName: vertx-web-3.x-scenario segmentSize: 2 segments: - - segmentId: nq 0 + - segmentId: not null spans: - operationName: /vertx-web-3-scenario/case/healthCheck operationId: 0 @@ -49,7 +49,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-web-3-scenario/case/web-case} - - segmentId: nq 0 + - segmentId: not null spans: - operationName: '#/vertx-web-3-scenario/case/healthCheck' operationId: 0 From b0b24b41b71c13665d335428e749bd7c4e8a1a96 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 09:54:28 -0400 Subject: [PATCH 15/25] add more supported versions --- .github/workflows/plugins-test.3.yaml | 2 +- .../vertx3/HttpClientRequestImplEndInterceptor.java | 8 +++++++- test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml | 2 +- .../vertx-eventbus-3.x-scenario/support-version.list | 8 ++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 96f045833601..b80e6b2f8aed 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -41,7 +41,7 @@ jobs: - { name: 'spring-4.1.x-scenario', title: 'Spring 4.1.x-4.2.x (20)' } - { name: 'spring-4.3.x-scenario', title: 'Spring 4.3.x-5.2.x (54)' } - { name: 'spring-async-scenario', title: 'Spring Async 4.3.x-5.1.x (35)' } - - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.x-3.7.x (19)' } + - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.x-3.7.x (27)' } - { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.x-3.7.x (21)' } steps: - uses: actions/checkout@v2 diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java index d7daf033f12f..31493b17ce9d 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java @@ -40,11 +40,17 @@ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { String host; int port; if (allArguments[3] instanceof Integer) { + //ver. 3.0.x - 3.3.x host = (String) allArguments[2]; port = (Integer) allArguments[3]; - } else { + } else if (allArguments[4] instanceof Integer) { + //ver. 3.4.x - 3.7.x host = (String) allArguments[3]; port = (Integer) allArguments[4]; + } else { + //ver. 3.8.x+ + host = (String) allArguments[4]; + port = (Integer) allArguments[5]; } objInst.setSkyWalkingDynamicField(host + ":" + port); } diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml index 2765e6ab1cb7..e0af4c17b3c1 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml @@ -30,7 +30,7 @@ UTF-8 1.8 - 3.7.0 + 3.9.0 skywalking-vertx-eventbus-3.x-scenario diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list index 8273d93a6101..071d082029b0 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list @@ -14,6 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.9.0 +3.8.5 +3.8.4 +3.8.3 +3.8.2 +3.8.1 +3.8.0 +3.7.1 3.7.0 3.6.3 3.6.2 From de1ef3c0ac4ba5330a628e3bf67d98026c06fce2 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 11:00:35 -0400 Subject: [PATCH 16/25] track status code --- .../vertx-plugins/vertx-core-3.x-plugin/pom.xml | 2 +- .../HttpClientRequestImplHandleResponseInterceptor.java | 4 +++- .../vertx-eventbus-3.x-scenario/config/expectedData.yaml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/pom.xml index 8a25813b680c..3090bf149d0f 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/pom.xml @@ -31,7 +31,7 @@ http://maven.apache.org - 3.6.3 + 3.9.0 diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleResponseInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleResponseInterceptor.java index cd112add6f2f..cea72b028df2 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleResponseInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleResponseInterceptor.java @@ -18,7 +18,9 @@ package org.apache.skywalking.apm.plugin.vertx3; +import io.vertx.core.http.HttpClientResponse; 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; @@ -31,10 +33,10 @@ public class HttpClientRequestImplHandleResponseInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); + Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpClientResponse) allArguments[0]).statusCode())); context.getSpan().asyncFinish(); AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName()); diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml index 27acc2621c86..b7f20af0c458 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml @@ -58,6 +58,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + - {key: status_code, value: '200'} - operationName: /vertx-eventbus-3-scenario/case/eventbus-case operationId: 0 parentSpanId: -1 From ac3d6e11d28c13916720a053a536999fd7b0acee Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 11:00:57 -0400 Subject: [PATCH 17/25] spelling fix --- .../apm/agent/core/context/trace/AbstractTracingSpan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java index a572ed227968..6e2e3ae2a4b3 100644 --- a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java +++ b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java @@ -311,7 +311,7 @@ public AbstractSpan asyncFinish() { throw new RuntimeException("Span is not in async mode, please use '#prepareForAsync' to active."); } if (isAsyncStopped) { - throw new RuntimeException("Can not do async finish for the span repeately."); + throw new RuntimeException("Can not do async finish for the span repeatedly."); } this.endTime = System.currentTimeMillis(); owner.asyncStop(this); From 213f5a69e15a7e86b8b0a947d9c620b3fb5b8861 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 11:20:23 -0400 Subject: [PATCH 18/25] track status code --- .../apm/plugin/vertx3/RouterImplAcceptInterceptor.java | 4 +++- .../vertx-eventbus-3.x-scenario/config/expectedData.yaml | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java index 0eb4470f98a2..d54af6727e1e 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java @@ -60,7 +60,9 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { - ContextManager.stopSpan(); + AbstractSpan span = ContextManager.activeSpan(); + Tags.STATUS_CODE.set(span, Integer.toString(((HttpServerRequest) allArguments[0]).response().getStatusCode())); + ContextManager.stopSpan(span); return ret; } diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml index b7f20af0c458..de2591f737cf 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml @@ -74,6 +74,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-eventbus-3-scenario/case/eventbus-case} + - {key: status_code, value: '200'} - segmentId: not null spans: - operationName: '#/vertx-eventbus-3-scenario/case/executeTest' @@ -134,6 +135,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + - {key: status_code, value: '200'} refs: - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, From 1a44db0dcc0c4a27fba24f3357bb9a1ff72cc6d6 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 11:42:26 -0400 Subject: [PATCH 19/25] more correct naming --- .../vertxeventbus/controller/VertxEventbusController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java index 7e9981779e98..70f71a70e379 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxeventbus/controller/VertxEventbusController.java @@ -30,7 +30,7 @@ public class VertxEventbusController extends AbstractVerticle { @Override public void start() { Router router = Router.router(vertx); - router.get("/vertx-eventbus-3-scenario/case/eventbus-case").handler(this::handleCoreCase); + router.get("/vertx-eventbus-3-scenario/case/eventbus-case").handler(this::handleEventbusCase); router.get("/vertx-eventbus-3-scenario/case/executeTest").handler(this::executeTest); router.head("/vertx-eventbus-3-scenario/case/healthCheck").handler(this::healthCheck); vertx.createHttpServer().requestHandler(router::accept).listen(8080); @@ -39,7 +39,7 @@ public void start() { vertx.deployVerticle(LocalReceiver.class.getName()); } - private void handleCoreCase(RoutingContext routingContext) { + private void handleEventbusCase(RoutingContext routingContext) { vertx.createHttpClient().getNow(8080, "localhost", "/vertx-eventbus-3-scenario/case/executeTest", it -> routingContext.response().setStatusCode(it.statusCode()).end()); From 41c1ce2877a0137d8c9b678cdf3c2936ed0883e5 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 11:43:46 -0400 Subject: [PATCH 20/25] reverts 213f5a69 (status code isn't sent at this point) --- .../apm/plugin/vertx3/RouterImplAcceptInterceptor.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java index d54af6727e1e..0eb4470f98a2 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java @@ -60,9 +60,7 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { - AbstractSpan span = ContextManager.activeSpan(); - Tags.STATUS_CODE.set(span, Integer.toString(((HttpServerRequest) allArguments[0]).response().getStatusCode())); - ContextManager.stopSpan(span); + ContextManager.stopSpan(); return ret; } From ee394310dc5d0aa0b976a0794f70271a360b7091 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 12:53:41 -0400 Subject: [PATCH 21/25] made HttpServerResponseImplEndInstrumentation more strict based on version added status code tracking fixes issue not finishing async spans --- .../HttpServerResponseImplEndInterceptor.java | 10 +++++----- ...pServerResponseImplEndInstrumentation.java | 13 ++++++++---- .../config/expectedData.yaml | 20 ++++++++++++++++++- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplEndInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplEndInterceptor.java index 3234e2bb4a86..81423fe8a8fc 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplEndInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplEndInterceptor.java @@ -18,7 +18,9 @@ package org.apache.skywalking.apm.plugin.vertx3; +import io.vertx.core.http.HttpServerResponse; import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.tag.Tags; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; @@ -28,13 +30,11 @@ public class HttpServerResponseImplEndInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { - if (allArguments.length == 0) { - VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); - context.getSpan().asyncFinish(); - } + VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); + Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpServerResponse) objInst).getStatusCode())); + context.getSpan().asyncFinish(); } @Override diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplEndInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplEndInstrumentation.java index e7ce3973a74e..958419419bd2 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplEndInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplEndInstrumentation.java @@ -27,6 +27,7 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; /** * {@link HttpServerResponseImplEndInstrumentation} enhance the end method in @@ -36,8 +37,7 @@ public class HttpServerResponseImplEndInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "io.vertx.core.http.impl.HttpServerResponseImpl"; - private static final String ENHANCE_METHOD = "end"; - private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplEndInterceptor"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplEndInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { @@ -50,12 +50,17 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD); + return named("end0") //ver. 3.0.0 - 3.5.4 + .or(named("end") //ver. 3.6.0 - 3.7.0 + .and(takesArgumentWithType(0, "io.vertx.core.buffer.Buffer"))) + .or(named("end") //ver. 3.7.1+ + .and(takesArgumentWithType(0, "io.vertx.core.buffer.Buffer")) + .and(takesArgumentWithType(1, "io.netty.channel.ChannelPromise"))); } @Override public String getMethodsInterceptor() { - return INTERCEPT_CLASS; + return INTERCEPTOR_CLASS; } @Override diff --git a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml index de2591f737cf..ee808053b91c 100644 --- a/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/config/expectedData.yaml @@ -15,8 +15,26 @@ # limitations under the License. segmentItems: - serviceName: vertx-eventbus-3.x-scenario - segmentSize: 7 + segmentSize: 8 segments: + - segmentId: not null + spans: + - operationName: /vertx-eventbus-3-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: HEAD} + - {key: url, value: /vertx-eventbus-3-scenario/case/healthCheck} + - {key: status_code, value: '200'} - segmentId: not null spans: - operationName: local-message-receiver From b267f860fa0ec07bb38b9ff51535786ab1f093b7 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 13:00:59 -0400 Subject: [PATCH 22/25] works 3.0.0,3.7.0 --- .../config/expectedData.yaml | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index 1c0e3bd2ec75..0808e99320a0 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -15,8 +15,49 @@ # limitations under the License. segmentItems: - serviceName: vertx-web-3.x-scenario - segmentSize: 2 + segmentSize: 4 segments: + - segmentId: not null + spans: + - operationName: /vertx-web-3-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: HEAD} + - {key: url, value: /vertx-web-3-scenario/case/healthCheck} + - {key: status_code, value: '200'} + - segmentId: not null + spans: + - operationName: /vertx-web-3-scenario/case/healthCheck + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Entry + peer: '' + skipAnalysis: false + tags: + - {key: http.method, value: GET} + - {key: url, value: /vertx-web-3-scenario/case/healthCheck} + - {key: status_code, value: '404'} + refs: + - {parentEndpoint: /vertx-web-3-scenario/case/web-case, networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.x-scenario, + traceId: not null} - segmentId: not null spans: - operationName: /vertx-web-3-scenario/case/healthCheck @@ -34,6 +75,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-web-3-scenario/case/healthCheck} + - {key: status_code, value: '404'} - operationName: /vertx-web-3-scenario/case/web-case operationId: 0 parentSpanId: -1 @@ -49,6 +91,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-web-3-scenario/case/web-case} + - {key: status_code, value: '404'} - segmentId: not null spans: - operationName: '#/vertx-web-3-scenario/case/healthCheck' @@ -68,4 +111,3 @@ segmentItems: refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-web-3.x-scenario, traceId: not null} - From 35c71a4c8fb140431d584c9e812e274a70fa1118 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 13:10:11 -0400 Subject: [PATCH 23/25] increase compatibility --- .github/workflows/plugins-test.3.yaml | 4 ++-- .../vertx-web-3.x-scenario/config/expectedData.yaml | 10 +++++----- .../vertxweb/controller/VertxWebController.java | 2 +- .../vertx-web-3.x-scenario/support-version.list | 8 ++++++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index b80e6b2f8aed..42069a540753 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -41,8 +41,8 @@ jobs: - { name: 'spring-4.1.x-scenario', title: 'Spring 4.1.x-4.2.x (20)' } - { name: 'spring-4.3.x-scenario', title: 'Spring 4.3.x-5.2.x (54)' } - { name: 'spring-async-scenario', title: 'Spring Async 4.3.x-5.1.x (35)' } - - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.x-3.7.x (27)' } - - { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.x-3.7.x (21)' } + - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.0-3.9.0 (27)' } + - { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.0-3.9.0 (29)' } steps: - uses: actions/checkout@v2 with: diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml index 0808e99320a0..8f8885415704 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/config/expectedData.yaml @@ -50,9 +50,9 @@ segmentItems: peer: '' skipAnalysis: false tags: - - {key: http.method, value: GET} + - {key: http.method, value: HEAD} - {key: url, value: /vertx-web-3-scenario/case/healthCheck} - - {key: status_code, value: '404'} + - {key: status_code, value: '200'} refs: - {parentEndpoint: /vertx-web-3-scenario/case/web-case, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, @@ -73,9 +73,9 @@ segmentItems: peer: localhost:8080 skipAnalysis: false tags: - - {key: http.method, value: GET} + - {key: http.method, value: HEAD} - {key: url, value: /vertx-web-3-scenario/case/healthCheck} - - {key: status_code, value: '404'} + - {key: status_code, value: '200'} - operationName: /vertx-web-3-scenario/case/web-case operationId: 0 parentSpanId: -1 @@ -91,7 +91,7 @@ segmentItems: tags: - {key: http.method, value: GET} - {key: url, value: /vertx-web-3-scenario/case/web-case} - - {key: status_code, value: '404'} + - {key: status_code, value: '200'} - segmentId: not null spans: - operationName: '#/vertx-web-3-scenario/case/healthCheck' diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java index 40c70f3734ae..7da26aa6363d 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java @@ -32,7 +32,7 @@ public void start() { } private void handleCoreCase(RoutingContext routingContext) { - vertx.createHttpClient().getNow(8080, "localhost", + vertx.createHttpClient().headNow(8080, "localhost", "/vertx-web-3-scenario/case/healthCheck", it -> routingContext.response().setStatusCode(it.statusCode()).end()); } diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list b/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list index 3582c97d124d..db205eb25959 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/support-version.list @@ -14,6 +14,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.9.0 +3.8.5 +3.8.4 +3.8.3 +3.8.2 +3.8.1 +3.8.0 +3.7.1 3.7.0 3.6.3 3.6.2 From d2c95773bb447da1036cb675e710450224a7cdb5 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 29 Apr 2020 13:16:37 -0400 Subject: [PATCH 24/25] 3.9.0 default --- test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml index 58d64e9894b6..8f6c3daa0036 100644 --- a/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml +++ b/test/plugin/scenarios/vertx-web-3.x-scenario/pom.xml @@ -30,7 +30,7 @@ UTF-8 1.8 - 3.7.0 + 3.9.0 skywalking-vertx-web-3.x-scenario From 288e571e8e14d8145eb5d4c2d7d37b8c63296763 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Thu, 30 Apr 2020 09:07:37 -0400 Subject: [PATCH 25/25] versioned witness classes (advice from wu-sheng) --- .../HttpClientRequestImplEndInterceptor.java | 53 ++++++++------ ...tpClientRequestImplEndInstrumentation.java | 72 ++++++++++++------- 2 files changed, 77 insertions(+), 48 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java index 31493b17ce9d..1cc863c14ecc 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java @@ -33,35 +33,42 @@ import java.lang.reflect.Method; -public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor { +public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroundInterceptor { - @Override - public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { - String host; - int port; - if (allArguments[3] instanceof Integer) { - //ver. 3.0.x - 3.3.x - host = (String) allArguments[2]; - port = (Integer) allArguments[3]; - } else if (allArguments[4] instanceof Integer) { - //ver. 3.4.x - 3.7.x - host = (String) allArguments[3]; - port = (Integer) allArguments[4]; - } else { - //ver. 3.8.x+ - host = (String) allArguments[4]; - port = (Integer) allArguments[5]; + public static class Version30XTo33XConstructorInterceptor implements InstanceConstructorInterceptor { + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + String host = (String) allArguments[2]; + int port = (Integer) allArguments[3]; + objInst.setSkyWalkingDynamicField(host + ":" + port); + } + } + + public static class Version34XTo37XConstructorInterceptor implements InstanceConstructorInterceptor { + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + String host = (String) allArguments[3]; + int port = (Integer) allArguments[4]; + objInst.setSkyWalkingDynamicField(host + ":" + port); + } + } + + public static class Version38PlusConstructorInterceptor implements InstanceConstructorInterceptor { + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + String host = (String) allArguments[4]; + int port = (Integer) allArguments[5]; + objInst.setSkyWalkingDynamicField(host + ":" + port); } - objInst.setSkyWalkingDynamicField(host + ":" + port); } @Override - @SuppressWarnings("unchecked") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, - MethodInterceptResult result) throws Throwable { + MethodInterceptResult result) { HttpClientRequest request = (HttpClientRequest) objInst; ContextCarrier contextCarrier = new ContextCarrier(); - AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier, (String) objInst.getSkyWalkingDynamicField()); + AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier, + (String) objInst.getSkyWalkingDynamicField()); span.setComponent(ComponentsDefine.VERTX); SpanLayer.asHttp(span); Tags.HTTP.METHOD.set(span, request.method().toString()); @@ -77,14 +84,14 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, - Object ret) throws Throwable { + Object ret) { ContextManager.stopSpan(); return ret; } @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, - Class[] argumentsTypes, Throwable t) { + Class[] argumentsTypes, Throwable t) { ContextManager.activeSpan().errorOccurred().log(t); } diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplEndInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplEndInstrumentation.java index 236c1fe75b24..bc8b2fa8a628 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplEndInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplEndInstrumentation.java @@ -26,8 +26,8 @@ import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; -import static net.bytebuddy.matcher.ElementMatchers.any; import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; /** * {@link HttpClientRequestImplEndInstrumentation} enhance the end method in @@ -42,40 +42,62 @@ public class HttpClientRequestImplEndInstrumentation extends ClassInstanceMethod @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { - return new ConstructorInterceptPoint[] { - new ConstructorInterceptPoint() { - @Override - public ElementMatcher getConstructorMatcher() { - return any(); - } + return new ConstructorInterceptPoint[]{ + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgument(3, int.class); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS + "$Version30XTo33XConstructorInterceptor"; + } + }, + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgument(4, int.class); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS + "$Version34XTo37XConstructorInterceptor"; + } + }, + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgument(5, int.class); + } - @Override - public String getConstructorInterceptor() { - return INTERCEPT_CLASS; + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS + "$Version38PlusConstructorInterceptor"; + } } - } }; } @Override public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { - return new InstanceMethodsInterceptPoint[] { - new InstanceMethodsInterceptPoint() { - @Override - public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD); - } + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } - @Override - public String getMethodsInterceptor() { - return INTERCEPT_CLASS; - } + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } - @Override - public boolean isOverrideArgs() { - return false; + @Override + public boolean isOverrideArgs() { + return false; + } } - } }; }