From 705f97f27ae7362bd87022b323a059f90b303fd1 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Mon, 1 Jun 2020 17:00:16 +0400 Subject: [PATCH] Increased Vert.x support (#4840) --- .github/workflows/plugins-test.3.yaml | 4 +- .../vertx-core-3.x-plugin/pom.xml | 14 +- ...lusteredEventBusSendRemoteInterceptor.java | 2 +- ...entBusImplDeliverToHandlerInterceptor.java | 2 +- .../HandlerRegistrationInterceptor.java | 2 +- ...RequestImplHandleExceptionInterceptor.java | 1 - ...tRequestImplHandleResponseInterceptor.java | 23 ++- ... => HttpClientRequestImplInterceptor.java} | 54 ++++--- ...textHandleDispatchResponseInterceptor.java | 66 ++++++++ .../HttpContextSendRequestInterceptor.java | 50 ++++++ ...rverRequestImplConstructorInterceptor.java | 30 ++++ ...rRequestWrapperConstructorInterceptor.java | 30 ++++ ...esponseImplHandleExceptionInterceptor.java | 1 - .../HttpServerResponseImplInterceptor.java | 62 ++++++++ .../plugin/vertx3/RouteStateInterceptor.java | 91 +++++++++++ ...java => RouterImplHandlerInterceptor.java} | 11 +- ...ContextImplBaseConstructorInterceptor.java | 32 ++++ ...gContextWrapperConstructorInterceptor.java | 30 ++++ ...erConnectionHandleMessageInterceptor.java} | 42 ++--- ...uestImplHandleResponseInstrumentation.java | 4 +- ...HttpClientRequestImplInstrumentation.java} | 13 +- ...HandleDispatchResponseInstrumentation.java | 75 +++++++++ ...HttpContextSendRequestInstrumentation.java | 73 +++++++++ ...RequestImplConstructorInstrumentation.java | 67 ++++++++ ...uestWrapperConstructorInstrumentation.java | 67 ++++++++ ...nseImplHandleExceptionInstrumentation.java | 2 +- ...ttpServerResponseImplInstrumentation.java} | 23 ++- ...on.java => RouteStateInstrumentation.java} | 33 ++-- ...extImplBaseConstructorInstrumentation.java | 67 ++++++++ ... => RouterImplHandlerInstrumentation.java} | 14 +- .../define/RouterImplInstrumentation.java | 88 +++++++++++ ...textWrapperConstructorInstrumentation.java | 69 +++++++++ ...onnectionHandleMessageInstrumentation.java | 77 ++++++++++ .../src/main/resources/skywalking-plugin.def | 17 +- .../config/expectedData.yaml | 20 ++- .../support-version.list | 1 + .../config/expectedData.yaml | 145 ++++++++++++++---- .../controller/VertxWebController.java | 16 +- .../config/expectedData.yaml | 145 ++++++++++++++---- .../vertx-web-3.6plus-scenario/pom.xml | 2 +- .../controller/VertxWebController.java | 20 ++- .../support-version.list | 1 + 42 files changed, 1428 insertions(+), 158 deletions(-) rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/{HttpClientRequestImplEndInterceptor.java => HttpClientRequestImplInterceptor.java} (66%) create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextHandleDispatchResponseInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextSendRequestInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestImplConstructorInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestWrapperConstructorInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteStateInterceptor.java rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/{HttpServerResponseImplEndInterceptor.java => RouterImplHandlerInterceptor.java} (78%) create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextImplBaseConstructorInterceptor.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextWrapperConstructorInterceptor.java rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/{RouterImplAcceptInterceptor.java => ServerConnectionHandleMessageInterceptor.java} (68%) rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/{HttpClientRequestImplEndInstrumentation.java => HttpClientRequestImplInstrumentation.java} (89%) create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextHandleDispatchResponseInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextSendRequestInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestImplConstructorInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestWrapperConstructorInstrumentation.java rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/{HttpServerResponseImplEndInstrumentation.java => HttpServerResponseImplInstrumentation.java} (78%) rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/{RouterImplAcceptInstrumentation.java => RouteStateInstrumentation.java} (71%) create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterContextImplBaseConstructorInstrumentation.java rename apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/{RouterImplHandleInstrumentation.java => RouterImplHandlerInstrumentation.java} (86%) create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RoutingContextWrapperConstructorInstrumentation.java create mode 100644 apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/ServerConnectionHandleMessageInstrumentation.java diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 63e30a319..10e06d8e8 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -41,9 +41,9 @@ 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.0-3.9.0 (27)' } + - { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.0-3.9.1 (28)' } - { name: 'vertx-web-3.54minus-scenario', title: 'Vert.x Web 3.0.0-3.5.4 (16)' } - - { name: 'vertx-web-3.6plus-scenario', title: 'Vert.x Web 3.6.0-3.9.0 (13)' } + - { name: 'vertx-web-3.6plus-scenario', title: 'Vert.x Web 3.6.0-3.9.1 (14)' } - { name: 'mariadb-scenario', title: 'Mariadb 2.x (8)' } steps: - uses: actions/checkout@v2 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 3090bf149..0625ab0a0 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.9.0 + 3.9.1 @@ -41,5 +41,17 @@ ${vertx.version} provided + + io.vertx + vertx-web + ${vertx.version} + provided + + + io.vertx + vertx-web-client + ${vertx.version} + provided + diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ClusteredEventBusSendRemoteInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ClusteredEventBusSendRemoteInterceptor.java index 2b15cf10a..47e0a2017 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ClusteredEventBusSendRemoteInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ClusteredEventBusSendRemoteInterceptor.java @@ -35,7 +35,7 @@ import java.lang.reflect.Method; public class ClusteredEventBusSendRemoteInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { ContextManager.getRuntimeContext().remove(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName()); diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/EventBusImplDeliverToHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/EventBusImplDeliverToHandlerInterceptor.java index 709f87572..8e32945c5 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/EventBusImplDeliverToHandlerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/EventBusImplDeliverToHandlerInterceptor.java @@ -32,7 +32,7 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; public class EventBusImplDeliverToHandlerInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { ContextManager.getRuntimeContext().remove(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName()); diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HandlerRegistrationInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HandlerRegistrationInterceptor.java index cfb718cc9..ff8db51b4 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HandlerRegistrationInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HandlerRegistrationInterceptor.java @@ -34,7 +34,7 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; public class HandlerRegistrationInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") + @SuppressWarnings("rawtypes") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { ContextManager.getRuntimeContext().remove(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName()); diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleExceptionInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleExceptionInterceptor.java index 43e526d97..ef58d44c8 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleExceptionInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplHandleExceptionInterceptor.java @@ -28,7 +28,6 @@ import java.lang.reflect.Method; public class HttpClientRequestImplHandleExceptionInterceptor 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(); 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 982a5f1f4..de6bfb7b4 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 @@ -27,6 +27,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.vertx3.HttpClientRequestImplInterceptor.HttpClientRequestContext; import java.lang.reflect.Method; @@ -36,14 +37,17 @@ public class HttpClientRequestImplHandleResponseInterceptor implements InstanceM public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { if (VertxContext.VERTX_VERSION < 38 || allArguments.length == 2) { - VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); - Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpClientResponse) allArguments[0]).statusCode())); - context.getSpan().asyncFinish(); + HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField(); + if (!requestContext.usingWebClient) { + VertxContext context = requestContext.vertxContext; + Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpClientResponse) allArguments[0]).statusCode())); + context.getSpan().asyncFinish(); - AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName()); - span.setComponent(ComponentsDefine.VERTX); - SpanLayer.asHttp(span); - ContextManager.continued(context.getContextSnapshot()); + AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName()); + span.setComponent(ComponentsDefine.VERTX); + SpanLayer.asHttp(span); + ContextManager.continued(context.getContextSnapshot()); + } } } @@ -51,7 +55,10 @@ public class HttpClientRequestImplHandleResponseInterceptor implements InstanceM public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { if (VertxContext.VERTX_VERSION < 38 || allArguments.length == 2) { - ContextManager.stopSpan(); + HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField(); + if (!requestContext.usingWebClient) { + ContextManager.stopSpan(); + } } return ret; } 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/HttpClientRequestImplInterceptor.java similarity index 66% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplEndInterceptor.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpClientRequestImplInterceptor.java index 1cc863c14..08cf2ab55 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/HttpClientRequestImplInterceptor.java @@ -33,14 +33,25 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import java.lang.reflect.Method; -public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroundInterceptor { +public class HttpClientRequestImplInterceptor implements InstanceMethodsAroundInterceptor { + + static class HttpClientRequestContext { + String remotePeer; + boolean usingWebClient; + VertxContext vertxContext; + boolean sent; + + HttpClientRequestContext(String remotePeer) { + this.remotePeer = remotePeer; + } + } 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); + objInst.setSkyWalkingDynamicField(new HttpClientRequestContext(host + ":" + port)); } } @@ -49,7 +60,7 @@ public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroun public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { String host = (String) allArguments[3]; int port = (Integer) allArguments[4]; - objInst.setSkyWalkingDynamicField(host + ":" + port); + objInst.setSkyWalkingDynamicField(new HttpClientRequestContext(host + ":" + port)); } } @@ -58,34 +69,41 @@ public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroun public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { String host = (String) allArguments[4]; int port = (Integer) allArguments[5]; - objInst.setSkyWalkingDynamicField(host + ":" + port); + objInst.setSkyWalkingDynamicField(new HttpClientRequestContext(host + ":" + port)); } } @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) { - HttpClientRequest request = (HttpClientRequest) objInst; - ContextCarrier contextCarrier = new ContextCarrier(); - 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()); - Tags.URL.set(span, request.uri()); + HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField(); + if (!requestContext.sent) { + HttpClientRequest request = (HttpClientRequest) objInst; + ContextCarrier contextCarrier = new ContextCarrier(); + AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier, + requestContext.remotePeer); + span.setComponent(ComponentsDefine.VERTX); + SpanLayer.asHttp(span); + Tags.HTTP.METHOD.set(span, request.method().toString()); + Tags.URL.set(span, request.uri()); - CarrierItem next = contextCarrier.items(); - while (next.hasNext()) { - next = next.next(); - request.headers().add(next.getHeadKey(), next.getHeadValue()); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + request.headers().add(next.getHeadKey(), next.getHeadValue()); + } + requestContext.vertxContext = new VertxContext(ContextManager.capture(), span.prepareForAsync()); } - objInst.setSkyWalkingDynamicField(new VertxContext(ContextManager.capture(), span.prepareForAsync())); } @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) { - ContextManager.stopSpan(); + HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField(); + if (!requestContext.sent) { + requestContext.sent = true; + ContextManager.stopSpan(); + } return ret; } diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextHandleDispatchResponseInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextHandleDispatchResponseInterceptor.java new file mode 100644 index 000000000..7b9f3a95e --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextHandleDispatchResponseInterceptor.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import io.vertx.core.http.HttpClientRequest; +import io.vertx.ext.web.client.impl.HttpContext; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.tag.Tags; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.apache.skywalking.apm.plugin.vertx3.HttpClientRequestImplInterceptor.HttpClientRequestContext; + +import java.lang.reflect.Method; + +public class HttpContextHandleDispatchResponseInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + @SuppressWarnings("rawtypes") + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + HttpContext httpContext = (HttpContext) objInst; + HttpClientRequest clientRequest = httpContext.clientRequest(); + VertxContext context = ((HttpClientRequestContext) ((EnhancedInstance) clientRequest) + .getSkyWalkingDynamicField()).vertxContext; + Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(httpContext.clientResponse().statusCode())); + context.getSpan().asyncFinish(); + + AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName()); + span.setComponent(ComponentsDefine.VERTX); + SpanLayer.asHttp(span); + ContextManager.continued(context.getContextSnapshot()); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextSendRequestInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextSendRequestInterceptor.java new file mode 100644 index 000000000..a90dd4357 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpContextSendRequestInterceptor.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.plugin.vertx3.HttpClientRequestImplInterceptor.HttpClientRequestContext; + +import java.lang.reflect.Method; + +public class HttpContextSendRequestInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + HttpClientRequestContext requestContext = (HttpClientRequestContext) ((EnhancedInstance) allArguments[0]) + .getSkyWalkingDynamicField(); + requestContext.usingWebClient = true; + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestImplConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestImplConstructorInterceptor.java new file mode 100644 index 000000000..35e80afaf --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestImplConstructorInterceptor.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; + +public class HttpServerRequestImplConstructorInterceptor implements InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(allArguments[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/HttpServerRequestWrapperConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestWrapperConstructorInterceptor.java new file mode 100644 index 000000000..e90514adf --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerRequestWrapperConstructorInterceptor.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; + +public class HttpServerRequestWrapperConstructorInterceptor implements InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(((EnhancedInstance) allArguments[0]).getSkyWalkingDynamicField()); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplHandleExceptionInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplHandleExceptionInterceptor.java index 2db587c92..fd4561533 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplHandleExceptionInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplHandleExceptionInterceptor.java @@ -28,7 +28,6 @@ import java.lang.reflect.Method; public class HttpServerResponseImplHandleExceptionInterceptor 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(); diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplInterceptor.java new file mode 100644 index 000000000..83bb68910 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplInterceptor.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import io.netty.buffer.ByteBuf; +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.InstanceConstructorInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +import java.lang.reflect.Method; + +public class HttpServerResponseImplInterceptor implements InstanceMethodsAroundInterceptor, + InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(((EnhancedInstance) allArguments[1]).getSkyWalkingDynamicField()); + } + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + if ((VertxContext.VERTX_VERSION < 36 && allArguments[0] instanceof ByteBuf) + || ((VertxContext.VERTX_VERSION >= 36 && VertxContext.VERTX_VERSION <= 37) || allArguments.length == 2)) { + VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); + Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpServerResponse) objInst).getStatusCode())); + context.getSpan().asyncFinish(); + } + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteStateInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteStateInterceptor.java new file mode 100644 index 000000000..3e8b56ff5 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteStateInterceptor.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import io.vertx.core.Handler; +import io.vertx.ext.web.RoutingContext; +import io.vertx.ext.web.impl.RoutingContextImplBase; +import org.apache.skywalking.apm.agent.core.context.ContextManager; +import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan; +import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +public class RouteStateInterceptor implements InstanceMethodsAroundInterceptor, + InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + if (allArguments.length > 8) { + objInst.setSkyWalkingDynamicField(allArguments[8]); + } else if (VertxContext.VERTX_VERSION >= 35 && VertxContext.VERTX_VERSION <= 38.2) { + try { + Field field = objInst.getClass().getDeclaredField("contextHandlers"); + field.setAccessible(true); + objInst.setSkyWalkingDynamicField(field.get(objInst)); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + } + + @Override + @SuppressWarnings("unchecked") + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + RoutingContextImplBase routingContext = (RoutingContextImplBase) allArguments[0]; + List> contextHandlers = (List>) objInst.getSkyWalkingDynamicField(); + AtomicInteger currentContextIndex = (AtomicInteger) ((EnhancedInstance) routingContext).getSkyWalkingDynamicField(); + int handlerContextIndex = currentContextIndex.get(); + if (VertxContext.VERTX_VERSION >= 35 && contextHandlers.size() > 1) { + currentContextIndex.getAndIncrement(); //3.5+ has possibility for multiple handlers + } + String contextName = contextHandlers.get(handlerContextIndex).getClass().getCanonicalName(); + int lambdaOffset = contextName.indexOf("$$Lambda$"); + if (lambdaOffset > 0) contextName = contextName.substring(0, lambdaOffset + 9); + AbstractSpan span = ContextManager.createLocalSpan(String.format("%s.handle(RoutingContext)", contextName)); + + Object connection = ((EnhancedInstance) routingContext.request()).getSkyWalkingDynamicField(); + VertxContext vertxContext = (VertxContext) ((EnhancedInstance) connection).getSkyWalkingDynamicField(); + ContextManager.continued(vertxContext.getContextSnapshot()); + span.setComponent(ComponentsDefine.VERTX); + SpanLayer.asHttp(span); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().errorOccurred().log(t); + } +} 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/RouterImplHandlerInterceptor.java similarity index 78% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/HttpServerResponseImplEndInterceptor.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplHandlerInterceptor.java index 297209335..91b30a47e 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/RouterImplHandlerInterceptor.java @@ -18,24 +18,21 @@ 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; import java.lang.reflect.Method; +import java.util.Collections; -public class HttpServerResponseImplEndInterceptor implements InstanceMethodsAroundInterceptor { +public class RouterImplHandlerInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { - if (VertxContext.VERTX_VERSION <= 37 || allArguments.length == 2) { - VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField(); - Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpServerResponse) objInst).getStatusCode())); - context.getSpan().asyncFinish(); + if (VertxContext.VERTX_VERSION < 35) { + objInst.setSkyWalkingDynamicField(Collections.singletonList(allArguments[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/RoutingContextImplBaseConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextImplBaseConstructorInterceptor.java new file mode 100644 index 000000000..9751d4b18 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextImplBaseConstructorInterceptor.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; + +import java.util.concurrent.atomic.AtomicInteger; + +public class RoutingContextImplBaseConstructorInterceptor implements InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(new AtomicInteger(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/RoutingContextWrapperConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextWrapperConstructorInterceptor.java new file mode 100644 index 000000000..e63ea34a1 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RoutingContextWrapperConstructorInterceptor.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; + +public class RoutingContextWrapperConstructorInterceptor implements InstanceConstructorInterceptor { + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { + objInst.setSkyWalkingDynamicField(((EnhancedInstance) allArguments[3]).getSkyWalkingDynamicField()); + } +} 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/ServerConnectionHandleMessageInterceptor.java similarity index 68% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplAcceptInterceptor.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ServerConnectionHandleMessageInterceptor.java index 0eb4470f9..37f50fc26 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/ServerConnectionHandleMessageInterceptor.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.plugin.vertx3; -import io.vertx.core.http.HttpServerRequest; +import io.netty.handler.codec.http.HttpRequest; import org.apache.skywalking.apm.agent.core.context.CarrierItem; import org.apache.skywalking.apm.agent.core.context.ContextCarrier; import org.apache.skywalking.apm.agent.core.context.ContextManager; @@ -32,35 +32,37 @@ import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import java.lang.reflect.Method; -public class RouterImplAcceptInterceptor implements InstanceMethodsAroundInterceptor { +public class ServerConnectionHandleMessageInterceptor implements InstanceMethodsAroundInterceptor { @Override - @SuppressWarnings("unchecked") public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { - HttpServerRequest request = (HttpServerRequest) allArguments[0]; - ContextCarrier contextCarrier = new ContextCarrier(); - CarrierItem next = contextCarrier.items(); - while (next.hasNext()) { - next = next.next(); - next.setHeadValue(request.headers().get(next.getHeadKey())); - request.headers().remove(next.getHeadKey()); + if (allArguments[0] instanceof HttpRequest) { + HttpRequest request = (HttpRequest) allArguments[0]; + ContextCarrier contextCarrier = new ContextCarrier(); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + next.setHeadValue(request.headers().get(next.getHeadKey())); + request.headers().remove(next.getHeadKey()); + } + + AbstractSpan span = ContextManager.createEntrySpan(toPath(request.getUri()), contextCarrier); + span.setComponent(ComponentsDefine.VERTX); + SpanLayer.asHttp(span); + Tags.HTTP.METHOD.set(span, request.getMethod().toString()); + Tags.URL.set(span, request.getUri()); + + objInst.setSkyWalkingDynamicField(new VertxContext(ContextManager.capture(), span.prepareForAsync())); } - - AbstractSpan span = ContextManager.createEntrySpan(toPath(request.uri()), contextCarrier); - span.setComponent(ComponentsDefine.VERTX); - SpanLayer.asHttp(span); - Tags.HTTP.METHOD.set(span, request.method().toString()); - Tags.URL.set(span, request.uri()); - - ((EnhancedInstance) request.response()).setSkyWalkingDynamicField(new VertxContext(ContextManager.capture(), span - .prepareForAsync())); } @Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, Object ret) throws Throwable { - ContextManager.stopSpan(); + if (allArguments[0] instanceof HttpRequest) { + ContextManager.stopSpan(); + } return ret; } 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/HttpClientRequestImplHandleResponseInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplHandleResponseInstrumentation.java index d4212988d..63d4d1b28 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplHandleResponseInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplHandleResponseInstrumentation.java @@ -31,7 +31,9 @@ import static net.bytebuddy.matcher.ElementMatchers.named; /** * {@link HttpClientRequestImplHandleResponseInstrumentation} enhance the handleResponse method in * io.vertx.core.http.impl.HttpClientRequestImpl class by - * HttpClientRequestImplHandleResponseInterceptor class + * HttpClientRequestImplHandleResponseInterceptor class. + * + * Ver. 3.0.0 - 3.5.4 */ public class HttpClientRequestImplHandleResponseInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { 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/HttpClientRequestImplInstrumentation.java similarity index 89% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplEndInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpClientRequestImplInstrumentation.java index bc8b2fa8a..9f0478000 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/HttpClientRequestImplInstrumentation.java @@ -28,17 +28,17 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; /** - * {@link HttpClientRequestImplEndInstrumentation} enhance the end method in + * {@link HttpClientRequestImplInstrumentation} enhance the end/sendHead methods in * io.vertx.core.http.impl.HttpClientRequestImpl class by - * HttpClientRequestImplEndInterceptor class + * HttpClientRequestImplInterceptor class */ -public class HttpClientRequestImplEndInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class HttpClientRequestImplInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "io.vertx.core.http.impl.HttpClientRequestImpl"; - private static final String ENHANCE_METHOD = "end"; - private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpClientRequestImplEndInterceptor"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpClientRequestImplInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { @@ -85,7 +85,8 @@ public class HttpClientRequestImplEndInstrumentation extends ClassInstanceMethod new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD); + return named("end") + .or(named("sendHead").and(takesArguments(1))); } @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/HttpContextHandleDispatchResponseInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextHandleDispatchResponseInstrumentation.java new file mode 100644 index 000000000..454ad401a --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextHandleDispatchResponseInstrumentation.java @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +/** + * {@link HttpContextHandleDispatchResponseInstrumentation} enhance the handleDispatchResponse method in + * io.vertx.ext.web.client.impl.HttpContext class by + * HttpContextHandleDispatchResponseInterceptor class. + * + * Ver. 3.6.0+ + */ +public class HttpContextHandleDispatchResponseInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.client.impl.HttpContext"; + private static final String ENHANCE_METHOD = "handleDispatchResponse"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpContextHandleDispatchResponseInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/HttpContextSendRequestInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextSendRequestInstrumentation.java new file mode 100644 index 000000000..a4cc50df3 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpContextSendRequestInstrumentation.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +/** + * {@link HttpContextSendRequestInstrumentation} enhance the sendRequest method in + * io.vertx.ext.web.client.impl.HttpContext class by + * HttpContextSendRequestInterceptor class. + */ +public class HttpContextSendRequestInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.client.impl.HttpContext"; + private static final String ENHANCE_METHOD = "sendRequest"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpContextSendRequestInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/HttpServerRequestImplConstructorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestImplConstructorInstrumentation.java new file mode 100644 index 000000000..054f5bb79 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestImplConstructorInstrumentation.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; + +/** + * {@link HttpServerRequestImplConstructorInstrumentation} enhance the constructor in + * io.vertx.core.http.impl.HttpServerRequestImpl class by + * HttpServerRequestImplConstructorInterceptor class. + */ +public class HttpServerRequestImplConstructorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.core.http.impl.HttpServerRequestImpl"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerRequestImplConstructorInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[0]; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/HttpServerRequestWrapperConstructorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestWrapperConstructorInstrumentation.java new file mode 100644 index 000000000..2a0d468eb --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerRequestWrapperConstructorInstrumentation.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; + +/** + * {@link HttpServerRequestWrapperConstructorInstrumentation} enhance the constructor in + * io.vertx.ext.web.impl.HttpServerRequestWrapper class by + * HttpServerRequestWrapperConstructorInterceptor class. + */ +public class HttpServerRequestWrapperConstructorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.HttpServerRequestWrapper"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerRequestWrapperConstructorInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[0]; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/HttpServerResponseImplHandleExceptionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplHandleExceptionInstrumentation.java index ba7f27bf3..0bac299f2 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplHandleExceptionInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplHandleExceptionInstrumentation.java @@ -31,7 +31,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named; /** * {@link HttpServerResponseImplHandleExceptionInstrumentation} enhance the handleException method in * io.vertx.core.http.impl.HttpServerResponseImpl class by - * HttpServerResponseImplHandleExceptionInterceptor class + * HttpServerResponseImplHandleExceptionInterceptor class. */ public class HttpServerResponseImplHandleExceptionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { 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/HttpServerResponseImplInstrumentation.java similarity index 78% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplEndInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/HttpServerResponseImplInstrumentation.java index 958419419..87d6425ee 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/HttpServerResponseImplInstrumentation.java @@ -26,22 +26,35 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInst 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 org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; /** - * {@link HttpServerResponseImplEndInstrumentation} enhance the end method in + * {@link HttpServerResponseImplInstrumentation} enhance the end0/end method in * io.vertx.core.http.impl.HttpServerResponseImpl class by - * HttpServerResponseImplEndInterceptor class + * HttpServerResponseImplInterceptor class */ -public class HttpServerResponseImplEndInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class HttpServerResponseImplInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "io.vertx.core.http.impl.HttpServerResponseImpl"; - private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplEndInterceptor"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { - return new ConstructorInterceptPoint[0]; + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPTOR_CLASS; + } + } + }; } @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/RouterImplAcceptInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouteStateInstrumentation.java similarity index 71% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplAcceptInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouteStateInstrumentation.java index 3fddc8b89..47d37e5bc 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplAcceptInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouteStateInstrumentation.java @@ -26,24 +26,39 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInst import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; +import java.util.List; + import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; /** - * {@link RouterImplAcceptInstrumentation} enhance the accept method in - * io.vertx.ext.web.impl.RouterImpl class by - * RouterImplAcceptInterceptor class. + * {@link RouteStateInstrumentation} enhance the handleContext method in + * io.vertx.ext.web.impl.RouteState class by + * RouteStateInterceptor class. * - * Targets: ver. 3.0.0 - 3.5.4 + * Ver. 3.8.3+ */ -public class RouterImplAcceptInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class RouteStateInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouterImpl"; - private static final String ENHANCE_METHOD = "accept"; - private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouterImplAcceptInterceptor"; + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouteState"; + private static final String ENHANCE_METHOD = "handleContext"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouteStateInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { - return new ConstructorInterceptPoint[0]; + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgument(8, List.class); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; } @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/RouterContextImplBaseConstructorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterContextImplBaseConstructorInstrumentation.java new file mode 100644 index 000000000..13912d2db --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterContextImplBaseConstructorInstrumentation.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; + +/** + * {@link RouterContextImplBaseConstructorInstrumentation} enhance the constructor in + * io.vertx.ext.web.impl.RoutingContextImplBase class by + * RoutingContextImplBaseConstructorInterceptor class. + */ +public class RouterContextImplBaseConstructorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RoutingContextImplBase"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RoutingContextImplBaseConstructorInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[0]; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/RouterImplHandleInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandlerInstrumentation.java similarity index 86% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandleInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandlerInstrumentation.java index 431bcf216..7ae3cf721 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandleInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandlerInstrumentation.java @@ -29,17 +29,17 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link RouterImplHandleInstrumentation} enhance the handle method in + * {@link RouterImplHandlerInstrumentation} enhance the handler method in * io.vertx.ext.web.impl.RouterImpl class by - * RouterImplAcceptInterceptor class. + * RouterImplHandlerInterceptor class. * - * Targets: ver. 3.6.0+ + * Ver. 3.0.0 - 3.4.2 */ -public class RouterImplHandleInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class RouterImplHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouterImpl"; - private static final String ENHANCE_METHOD = "handle"; - private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouterImplAcceptInterceptor"; + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouteImpl"; + private static final String ENHANCE_METHOD = "handler"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouterImplHandlerInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { 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/RouterImplInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplInstrumentation.java new file mode 100644 index 000000000..0aa072e77 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplInstrumentation.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; +import static net.bytebuddy.matcher.ElementMatchers.named; + +/** + * {@link RouterImplInstrumentation} enhance the handleContext method in + * io.vertx.ext.web.impl.RouterImpl class by + * RouteStateInterceptor class. + * + * Ver. 3.0.0 - 3.8.2 + */ +public class RouterImplInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouteImpl"; + private static final String ENHANCE_METHOD = "handleContext"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouteStateInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/RoutingContextWrapperConstructorInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RoutingContextWrapperConstructorInstrumentation.java new file mode 100644 index 000000000..b010d300b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RoutingContextWrapperConstructorInstrumentation.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.any; + +/** + * {@link RoutingContextWrapperConstructorInstrumentation} enhance the constructor in + * io.vertx.ext.web.impl.RoutingContextWrapper class by + * RoutingContextWrapperInterceptor class. + * + * Ver. 3.1.0+ + */ +public class RoutingContextWrapperConstructorInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RoutingContextWrapper"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RoutingContextWrapperConstructorInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[0]; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } +} 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/ServerConnectionHandleMessageInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/ServerConnectionHandleMessageInstrumentation.java new file mode 100644 index 000000000..24c1b8166 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/ServerConnectionHandleMessageInstrumentation.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.vertx3.define; + +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +/** + * {@link ServerConnectionHandleMessageInstrumentation} enhance the handleMessage method in + * io.vertx.core.http.impl.ServerConnection and io.vertx.core.http.impl.Http1xServerConnection + * classes by ServerConnectionHandleMessageInterceptor class. + */ +public class ServerConnectionHandleMessageInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String SERVER_CONNECTION_ENHANCE_CLASS = "io.vertx.core.http.impl.ServerConnection"; + private static final String HTTP_SERVER_CONNECTION_ENHANCE_CLASS = "io.vertx.core.http.impl.Http1xServerConnection"; + private static final String ENHANCE_METHOD = "handleMessage"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.ServerConnectionHandleMessageInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return MultiClassNameMatch.byMultiClassMatch( + HTTP_SERVER_CONNECTION_ENHANCE_CLASS, //ver. 3.5.1+ + SERVER_CONNECTION_ENHANCE_CLASS //ver. 3.0.0 - 3.5.0 + ); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/resources/skywalking-plugin.def index 380bee356..94bd3a122 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/resources/skywalking-plugin.def @@ -17,11 +17,18 @@ vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.ClusteredEventBusSendRemoteInstrumentation vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.EventBusImplDeliverToHandlerInstrumentation vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HandlerRegistrationInstrumentation -vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpClientRequestImplEndInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpClientRequestImplInstrumentation vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpClientRequestImplHandleExceptionInstrumentation vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpClientRequestImplHandleResponseInstrumentation -vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerResponseImplEndInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerResponseImplInstrumentation vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerResponseImplHandleExceptionInstrumentation -vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouterImplAcceptInstrumentation -vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouterImplHandleInstrumentation - +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouterContextImplBaseConstructorInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.ServerConnectionHandleMessageInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouteStateInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouterImplInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouterImplHandlerInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RoutingContextWrapperConstructorInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerRequestImplConstructorInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerRequestWrapperConstructorInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpContextSendRequestInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpContextHandleDispatchResponseInstrumentation 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 ee808053b..50fc7cc07 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 @@ -19,6 +19,10 @@ segmentItems: segments: - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxeventbus.controller.VertxEventbusController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-eventbus-3-scenario/case/healthCheck operationId: 0 parentSpanId: -1 @@ -63,8 +67,8 @@ segmentItems: spans: - operationName: /vertx-eventbus-3-scenario/case/executeTest operationId: 0 - parentSpanId: 0 - spanId: 1 + parentSpanId: 1 + spanId: 2 spanLayer: Http startTime: nq 0 endTime: nq 0 @@ -77,6 +81,10 @@ segmentItems: - {key: http.method, value: GET} - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} - {key: status_code, value: '200'} + - {operationName: org.apache.skywalking.apm.testcase.vertxeventbus.controller.VertxEventbusController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-eventbus-3-scenario/case/eventbus-case operationId: 0 parentSpanId: -1 @@ -109,7 +117,7 @@ segmentItems: skipAnalysis: false refs: - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: '', - refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, + refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, traceId: not null} - segmentId: not null @@ -138,6 +146,10 @@ segmentItems: componentId: 59, isError: false, spanType: Exit, peer: not null, skipAnalysis: false} - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxeventbus.controller.VertxEventbusController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-eventbus-3-scenario/case/executeTest operationId: 0 parentSpanId: -1 @@ -156,6 +168,6 @@ segmentItems: - {key: status_code, value: '200'} refs: - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: 'localhost:8080', - refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + refType: CrossProcess, parentSpanId: 2, 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/support-version.list b/test/plugin/scenarios/vertx-eventbus-3.x-scenario/support-version.list index 071d08202..351da6281 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,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.9.1 3.9.0 3.8.5 3.8.4 diff --git a/test/plugin/scenarios/vertx-web-3.54minus-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.54minus-scenario/config/expectedData.yaml index eaa009e01..cf100f508 100644 --- a/test/plugin/scenarios/vertx-web-3.54minus-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.54minus-scenario/config/expectedData.yaml @@ -15,10 +15,14 @@ # limitations under the License. segmentItems: - serviceName: vertx-web-3.54minus-scenario - segmentSize: 4 + segmentSize: 7 segments: - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-web-3_54minus-scenario/case/healthCheck operationId: 0 parentSpanId: -1 @@ -39,31 +43,8 @@ segmentItems: spans: - operationName: /vertx-web-3_54minus-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_54minus-scenario/case/healthCheck} - - {key: status_code, value: '200'} - refs: - - {parentEndpoint: /vertx-web-3_54minus-scenario/case/web-case, networkAddress: 'localhost:8080', - refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, - traceId: not null} - - segmentId: not null - spans: - - operationName: /vertx-web-3_54minus-scenario/case/healthCheck - operationId: 0 - parentSpanId: 0 - spanId: 1 + parentSpanId: 1 + spanId: 2 spanLayer: Http startTime: nq 0 endTime: nq 0 @@ -76,6 +57,10 @@ segmentItems: - {key: http.method, value: HEAD} - {key: url, value: /vertx-web-3_54minus-scenario/case/healthCheck} - {key: status_code, value: '200'} + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-web-3_54minus-scenario/case/web-case operationId: 0 parentSpanId: -1 @@ -94,6 +79,95 @@ segmentItems: - {key: status_code, value: '200'} - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} + - operationName: /vertx-web-3_54minus-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_54minus-scenario/case/healthCheck} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: /vertx-web-3_54minus-scenario/case/web-case, networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, + traceId: not null} + - segmentId: not null + spans: + - {operationName: io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} + - operationName: /vertx-web-3_54minus-scenario/case/web-case/withBodyHandler + 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_54minus-scenario/case/web-case/withBodyHandler} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: '#/vertx-web-3_54minus-scenario/case/healthCheck', networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext) + 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_54minus-scenario/case/web-case/withBodyHandler, + networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: /vertx-web-3_54minus-scenario/case/web-case/withBodyHandler + 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_54minus-scenario/case/web-case/withBodyHandler} + - {key: status_code, value: '200'} - operationName: '#/vertx-web-3_54minus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 @@ -108,6 +182,25 @@ segmentItems: skipAnalysis: false refs: - {parentEndpoint: /vertx-web-3_54minus-scenario/case/web-case, networkAddress: '', + refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: '#/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler' + 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_54minus-scenario/case/healthCheck', networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, traceId: not null} diff --git a/test/plugin/scenarios/vertx-web-3.54minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java b/test/plugin/scenarios/vertx-web-3.54minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java index 3fb9be768..39cf6e4e4 100644 --- a/test/plugin/scenarios/vertx-web-3.54minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java +++ b/test/plugin/scenarios/vertx-web-3.54minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java @@ -20,6 +20,7 @@ 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 io.vertx.ext.web.handler.BodyHandler; public class VertxWebController extends AbstractVerticle { @@ -27,14 +28,23 @@ public class VertxWebController extends AbstractVerticle { public void start() { Router router = Router.router(vertx); router.get("/vertx-web-3_54minus-scenario/case/web-case").handler(this::handleWebCase); + router.route("/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler").handler(BodyHandler.create()); + router.get("/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler").handler(this::withBodyHandler); router.head("/vertx-web-3_54minus-scenario/case/healthCheck").handler(this::healthCheck); vertx.createHttpServer().requestHandler(router::accept).listen(8080); } private void handleWebCase(RoutingContext routingContext) { - vertx.createHttpClient().headNow(8080, "localhost", - "/vertx-web-3_54minus-scenario/case/healthCheck", - it -> routingContext.response().setStatusCode(it.statusCode()).end()); + vertx.createHttpClient().headNow(8080, "localhost", "/vertx-web-3_54minus-scenario/case/healthCheck", + healthCheck -> { + vertx.createHttpClient().getNow(8080, "localhost", + "/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler", + it -> routingContext.response().setStatusCode(it.statusCode()).end()); + }); + } + + private void withBodyHandler(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); } private void healthCheck(RoutingContext routingContext) { diff --git a/test/plugin/scenarios/vertx-web-3.6plus-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.6plus-scenario/config/expectedData.yaml index 2defdefae..d22e4f104 100644 --- a/test/plugin/scenarios/vertx-web-3.6plus-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/vertx-web-3.6plus-scenario/config/expectedData.yaml @@ -15,10 +15,14 @@ # limitations under the License. segmentItems: - serviceName: vertx-web-3.6plus-scenario - segmentSize: 4 + segmentSize: 7 segments: - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-web-3_6plus-scenario/case/healthCheck operationId: 0 parentSpanId: -1 @@ -39,31 +43,8 @@ segmentItems: spans: - operationName: /vertx-web-3_6plus-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_6plus-scenario/case/healthCheck} - - {key: status_code, value: '200'} - refs: - - {parentEndpoint: /vertx-web-3_6plus-scenario/case/web-case, networkAddress: 'localhost:8080', - refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, - parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, - traceId: not null} - - segmentId: not null - spans: - - operationName: /vertx-web-3_6plus-scenario/case/healthCheck - operationId: 0 - parentSpanId: 0 - spanId: 1 + parentSpanId: 1 + spanId: 2 spanLayer: Http startTime: nq 0 endTime: nq 0 @@ -76,6 +57,10 @@ segmentItems: - {key: http.method, value: HEAD} - {key: url, value: /vertx-web-3_6plus-scenario/case/healthCheck} - {key: status_code, value: '200'} + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} - operationName: /vertx-web-3_6plus-scenario/case/web-case operationId: 0 parentSpanId: -1 @@ -94,6 +79,95 @@ segmentItems: - {key: status_code, value: '200'} - segmentId: not null spans: + - {operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} + - operationName: /vertx-web-3_6plus-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_6plus-scenario/case/healthCheck} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: /vertx-web-3_6plus-scenario/case/web-case, networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, + traceId: not null} + - segmentId: not null + spans: + - {operationName: io.vertx.ext.web.handler.impl.BodyHandlerImpl.handle(RoutingContext), + operationId: 0, parentSpanId: 0, spanId: 1, spanLayer: Http, startTime: nq 0, + endTime: nq 0, componentId: 59, isError: false, spanType: Local, peer: '', + skipAnalysis: false} + - operationName: /vertx-web-3_6plus-scenario/case/web-case/withBodyHandler + 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_6plus-scenario/case/web-case/withBodyHandler} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: '#/vertx-web-3_6plus-scenario/case/healthCheck', networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext) + 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_6plus-scenario/case/web-case/withBodyHandler, + networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: /vertx-web-3_6plus-scenario/case/web-case/withBodyHandler + 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_6plus-scenario/case/web-case/withBodyHandler} + - {key: status_code, value: '200'} - operationName: '#/vertx-web-3_6plus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 @@ -108,6 +182,25 @@ segmentItems: skipAnalysis: false refs: - {parentEndpoint: /vertx-web-3_6plus-scenario/case/web-case, networkAddress: '', + refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, + parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, + traceId: not null} + - segmentId: not null + spans: + - operationName: '#/vertx-web-3_6plus-scenario/case/web-case/withBodyHandler' + 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_6plus-scenario/case/healthCheck', networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, traceId: not null} diff --git a/test/plugin/scenarios/vertx-web-3.6plus-scenario/pom.xml b/test/plugin/scenarios/vertx-web-3.6plus-scenario/pom.xml index c8b5a4ba3..d8dbe1df5 100644 --- a/test/plugin/scenarios/vertx-web-3.6plus-scenario/pom.xml +++ b/test/plugin/scenarios/vertx-web-3.6plus-scenario/pom.xml @@ -30,7 +30,7 @@ UTF-8 1.8 - 3.9.0 + 3.9.1 skywalking-vertx-web-3.6plus-scenario diff --git a/test/plugin/scenarios/vertx-web-3.6plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java b/test/plugin/scenarios/vertx-web-3.6plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java index 34d81d83e..4ea37fbb6 100644 --- a/test/plugin/scenarios/vertx-web-3.6plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java +++ b/test/plugin/scenarios/vertx-web-3.6plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/vertxweb/controller/VertxWebController.java @@ -21,6 +21,7 @@ import io.vertx.core.AbstractVerticle; import io.vertx.ext.web.Router; import io.vertx.ext.web.RoutingContext; import io.vertx.ext.web.client.WebClient; +import io.vertx.ext.web.handler.BodyHandler; public class VertxWebController extends AbstractVerticle { @@ -28,14 +29,27 @@ public class VertxWebController extends AbstractVerticle { public void start() { Router router = Router.router(vertx); router.get("/vertx-web-3_6plus-scenario/case/web-case").handler(this::handleWebCase); + router.get("/vertx-web-3_6plus-scenario/case/web-case/withBodyHandler") + .handler(BodyHandler.create()).handler(this::withBodyHandler); router.head("/vertx-web-3_6plus-scenario/case/healthCheck").handler(this::healthCheck); vertx.createHttpServer().requestHandler(router).listen(8080); } private void handleWebCase(RoutingContext routingContext) { - WebClient.create(vertx).head(8080, "localhost", - "/vertx-web-3_6plus-scenario/case/healthCheck") - .send(it -> routingContext.response().setStatusCode(it.result().statusCode()).end()); + WebClient.create(vertx).head(8080, "localhost", "/vertx-web-3_6plus-scenario/case/healthCheck") + .send(healthCheck -> { + if (healthCheck.succeeded()) { + WebClient.create(vertx).get(8080, "localhost", "/vertx-web-3_6plus-scenario/case/web-case/withBodyHandler") + .send(it -> routingContext.response().setStatusCode(it.result().statusCode()).end()); + } else { + healthCheck.cause().printStackTrace(); + routingContext.response().setStatusCode(500).end(); + } + }); + } + + private void withBodyHandler(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); } private void healthCheck(RoutingContext routingContext) { diff --git a/test/plugin/scenarios/vertx-web-3.6plus-scenario/support-version.list b/test/plugin/scenarios/vertx-web-3.6plus-scenario/support-version.list index d6fba3ea8..83daf2f4e 100644 --- a/test/plugin/scenarios/vertx-web-3.6plus-scenario/support-version.list +++ b/test/plugin/scenarios/vertx-web-3.6plus-scenario/support-version.list @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +3.9.1 3.9.0 3.8.5 3.8.4