diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplHandlerInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteImplHandlerInterceptor.java similarity index 95% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplHandlerInterceptor.java rename to apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteImplHandlerInterceptor.java index 91b30a47e..e2ceb79f3 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouterImplHandlerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/RouteImplHandlerInterceptor.java @@ -26,7 +26,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInt import java.lang.reflect.Method; import java.util.Collections; -public class RouterImplHandlerInterceptor implements InstanceMethodsAroundInterceptor { +public class RouteImplHandlerInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, 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 index 3e8b56ff5..159d61472 100644 --- 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 @@ -34,10 +34,15 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; public class RouteStateInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor { + private static final Pattern HTTP_METHOD_PATTERN = Pattern.compile("methods:\\[([a-zA-Z,]+)\\]"); + @Override public void onConstruct(EnhancedInstance objInst, Object[] allArguments) { if (allArguments.length > 8) { @@ -71,6 +76,27 @@ public class RouteStateInterceptor implements InstanceMethodsAroundInterceptor, Object connection = ((EnhancedInstance) routingContext.request()).getSkyWalkingDynamicField(); VertxContext vertxContext = (VertxContext) ((EnhancedInstance) connection).getSkyWalkingDynamicField(); + + String routeMethods = null; + if (VertxContext.VERTX_VERSION >= 37.1) { + if (routingContext.currentRoute().methods() != null) { + routeMethods = "{" + + routingContext.currentRoute().methods() + .stream().map(Enum::toString) + .collect(Collectors.joining(",")) + + "}"; + } + } else { + //no methods() method; have to strip from toString() + Matcher matcher = HTTP_METHOD_PATTERN.matcher(routingContext.currentRoute().toString()); + if (matcher.find()) { + routeMethods = "{" + matcher.group(1) + "}"; + } + } + if (routeMethods != null && routingContext.currentRoute().getPath() != null) { + vertxContext.getSpan().setOperationName(routeMethods + routingContext.currentRoute().getPath()); + } + ContextManager.continued(vertxContext.getContextSnapshot()); span.setComponent(ComponentsDefine.VERTX); SpanLayer.asHttp(span); diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ServerConnectionHandleMessageInterceptor.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 index 37f50fc26..1afbb4e8c 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/ServerConnectionHandleMessageInterceptor.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 @@ -47,7 +47,7 @@ public class ServerConnectionHandleMessageInterceptor implements InstanceMethods request.headers().remove(next.getHeadKey()); } - AbstractSpan span = ContextManager.createEntrySpan(toPath(request.getUri()), contextCarrier); + AbstractSpan span = ContextManager.createEntrySpan("{" + request.getMethod() + "}" + toPath(request.getUri()), contextCarrier); span.setComponent(ComponentsDefine.VERTX); SpanLayer.asHttp(span); Tags.HTTP.METHOD.set(span, request.getMethod().toString()); 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/RouterImplHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouteImplHandlerInstrumentation.java similarity index 90% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandlerInstrumentation.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/RouteImplHandlerInstrumentation.java index 7ae3cf721..f4d6dc2da 100644 --- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplHandlerInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouteImplHandlerInstrumentation.java @@ -29,17 +29,17 @@ import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; import static net.bytebuddy.matcher.ElementMatchers.named; /** - * {@link RouterImplHandlerInstrumentation} enhance the handler method in + * {@link RouteImplHandlerInstrumentation} enhance the handler method in * io.vertx.ext.web.impl.RouterImpl class by - * RouterImplHandlerInterceptor class. + * RouteImplHandlerInterceptor class. * * Ver. 3.0.0 - 3.4.2 */ -public class RouterImplHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class RouteImplHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { 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"; + private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.RouteImplHandlerInterceptor"; @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/RouteImplInstrumentation.java similarity index 93% rename from apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx3/define/RouterImplInstrumentation.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/RouteImplInstrumentation.java index 0aa072e77..9a58aa4a5 100644 --- 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/RouteImplInstrumentation.java @@ -30,13 +30,13 @@ 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 + * {@link RouteImplInstrumentation} enhance the handleContext method in + * io.vertx.ext.web.impl.RouteImpl class by * RouteStateInterceptor class. * * Ver. 3.0.0 - 3.8.2 */ -public class RouterImplInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class RouteImplInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "io.vertx.ext.web.impl.RouteImpl"; private static final String ENHANCE_METHOD = "handleContext"; 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 94bd3a122..1b443d536 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 @@ -25,8 +25,8 @@ vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.HttpServerResponse 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.RouteImplInstrumentation +vertx-core-3.x=org.apache.skywalking.apm.plugin.vertx3.define.RouteImplHandlerInstrumentation 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 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 50fc7cc07..237511440 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,11 +19,19 @@ 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 + - 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: '{HEAD}/vertx-eventbus-3-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 spanId: 0 @@ -37,7 +45,7 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: HEAD} - - {key: url, value: /vertx-eventbus-3-scenario/case/healthCheck} + - {key: url, value: '/vertx-eventbus-3-scenario/case/healthCheck'} - {key: status_code, value: '200'} - segmentId: not null spans: @@ -60,12 +68,21 @@ segmentItems: traceId: not null} - segmentId: not null spans: - - {operationName: local-message-receiver, operationId: 0, parentSpanId: -1, spanId: 0, - spanLayer: RPCFramework, startTime: nq 0, endTime: nq 0, componentId: 59, - isError: false, spanType: Local, peer: '', skipAnalysis: false} + - operationName: local-message-receiver + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false - segmentId: not null spans: - - operationName: /vertx-eventbus-3-scenario/case/executeTest + - operationName: '/vertx-eventbus-3-scenario/case/executeTest' operationId: 0 parentSpanId: 1 spanId: 2 @@ -79,13 +96,21 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + - {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 + - 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: '{GET}/vertx-eventbus-3-scenario/case/eventbus-case' operationId: 0 parentSpanId: -1 spanId: 0 @@ -99,7 +124,7 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-eventbus-3-scenario/case/eventbus-case} + - {key: url, value: '/vertx-eventbus-3-scenario/case/eventbus-case'} - {key: status_code, value: '200'} - segmentId: not null spans: @@ -116,7 +141,7 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: '', + - {parentEndpoint: '{GET}/vertx-eventbus-3-scenario/case/eventbus-case', networkAddress: '', refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-eventbus-3.x-scenario, traceId: not null} @@ -141,16 +166,33 @@ segmentItems: traceId: not null} - segmentId: not null spans: - - {operationName: cluster-message-receiver, operationId: 0, parentSpanId: -1, - spanId: 0, spanLayer: RPCFramework, startTime: nq 0, endTime: nq 0, - componentId: 59, isError: false, spanType: Exit, peer: not null, skipAnalysis: false} + - operationName: cluster-message-receiver + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Exit + peer: 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 + - 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: '{GET}/vertx-eventbus-3-scenario/case/executeTest' operationId: 0 parentSpanId: -1 spanId: 0 @@ -164,10 +206,10 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-eventbus-3-scenario/case/executeTest} + - {key: url, value: '/vertx-eventbus-3-scenario/case/executeTest'} - {key: status_code, value: '200'} refs: - - {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: 'localhost:8080', + - {parentEndpoint: '{GET}/vertx-eventbus-3-scenario/case/eventbus-case', networkAddress: 'localhost:8080', 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-web-3.54minus-scenario/config/expectedData.yaml b/test/plugin/scenarios/vertx-web-3.54minus-scenario/config/expectedData.yaml index cf100f508..df7a69a48 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,15 +15,23 @@ # limitations under the License. segmentItems: - serviceName: vertx-web-3.54minus-scenario - segmentSize: 7 + segmentSize: 9 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 + - 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: '{HEAD}/vertx-web-3_54minus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 spanId: 0 @@ -37,11 +45,11 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_54minus-scenario/case/healthCheck} + - {key: url, value: '/vertx-web-3_54minus-scenario/case/healthCheck'} - {key: status_code, value: '200'} - segmentId: not null spans: - - operationName: /vertx-web-3_54minus-scenario/case/healthCheck + - operationName: '/vertx-web-3_54minus-scenario/dynamicEndpoint/100' operationId: 0 parentSpanId: 1 spanId: 2 @@ -54,14 +62,38 @@ segmentItems: peer: localhost:8080 skipAnalysis: false tags: - - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_54minus-scenario/case/healthCheck} + - {key: http.method, value: GET} + - {key: url, value: '/vertx-web-3_54minus-scenario/dynamicEndpoint/100'} - {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 + - operationName: '/vertx-web-3_54minus-scenario/case/healthCheck' + operationId: 0 + parentSpanId: 1 + spanId: 3 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Exit + peer: localhost:8080 + skipAnalysis: false + tags: + - {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: '{GET}/vertx-web-3_54minus-scenario/case/web-case' operationId: 0 parentSpanId: -1 spanId: 0 @@ -75,15 +107,23 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_54minus-scenario/case/web-case} + - {key: url, value: '/vertx-web-3_54minus-scenario/case/web-case'} - {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 + - 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: '{HEAD}/vertx-web-3_54minus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 spanId: 0 @@ -97,20 +137,63 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_54minus-scenario/case/healthCheck} + - {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', + - {parentEndpoint: '{GET}/vertx-web-3_54minus-scenario/case/web-case', networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 3, 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: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + - operationName: '{GET}/vertx-web-3_54minus-scenario/dynamicEndpoint/:id' + 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/dynamicEndpoint/100'} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: '{GET}/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 + - 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: '{GET}/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler' operationId: 0 parentSpanId: -1 spanId: 0 @@ -124,13 +207,32 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_54minus-scenario/case/web-case/withBodyHandler} + - {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: '#/vertx-web-3_54minus-scenario/dynamicEndpoint/100' + 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: '{GET}/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: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext) @@ -146,13 +248,13 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: /vertx-web-3_54minus-scenario/case/web-case/withBodyHandler, + - {parentEndpoint: '{GET}/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 + - operationName: '/vertx-web-3_54minus-scenario/case/web-case/withBodyHandler' operationId: 0 parentSpanId: 0 spanId: 1 @@ -166,7 +268,7 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_54minus-scenario/case/web-case/withBodyHandler} + - {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 @@ -181,8 +283,8 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: /vertx-web-3_54minus-scenario/case/web-case, networkAddress: '', - refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, + - {parentEndpoint: '{GET}/vertx-web-3_54minus-scenario/case/web-case', networkAddress: '', + refType: CrossThread, parentSpanId: 3, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-web-3.54minus-scenario, traceId: not null} - segmentId: 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 39cf6e4e4..204ceb020 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 @@ -28,6 +28,7 @@ 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.get("/vertx-web-3_54minus-scenario/dynamicEndpoint/:id").handler(this::dynamicEndpoint); 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); @@ -35,6 +36,12 @@ public class VertxWebController extends AbstractVerticle { } private void handleWebCase(RoutingContext routingContext) { + //dynamic endpoint test + vertx.createHttpClient().getNow(8080, "localhost", + "/vertx-web-3_54minus-scenario/dynamicEndpoint/100", it -> { + }); + + //non-body and body handler test vertx.createHttpClient().headNow(8080, "localhost", "/vertx-web-3_54minus-scenario/case/healthCheck", healthCheck -> { vertx.createHttpClient().getNow(8080, "localhost", @@ -43,6 +50,10 @@ public class VertxWebController extends AbstractVerticle { }); } + private void dynamicEndpoint(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); + } + private void withBodyHandler(RoutingContext routingContext) { routingContext.response().setStatusCode(200).end("Success"); } 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 d22e4f104..5de5e8f28 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,15 +15,23 @@ # limitations under the License. segmentItems: - serviceName: vertx-web-3.6plus-scenario - segmentSize: 7 + segmentSize: 9 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 + - 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: '{HEAD}/vertx-web-3_6plus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 spanId: 0 @@ -37,11 +45,11 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_6plus-scenario/case/healthCheck} + - {key: url, value: '/vertx-web-3_6plus-scenario/case/healthCheck'} - {key: status_code, value: '200'} - segmentId: not null spans: - - operationName: /vertx-web-3_6plus-scenario/case/healthCheck + - operationName: '/vertx-web-3_6plus-scenario/dynamicEndpoint/100' operationId: 0 parentSpanId: 1 spanId: 2 @@ -54,14 +62,38 @@ segmentItems: peer: localhost:8080 skipAnalysis: false tags: - - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_6plus-scenario/case/healthCheck} + - {key: http.method, value: GET} + - {key: url, value: '/vertx-web-3_6plus-scenario/dynamicEndpoint/100'} - {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 + - operationName: '/vertx-web-3_6plus-scenario/case/healthCheck' + operationId: 0 + parentSpanId: 1 + spanId: 3 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Exit + peer: localhost:8080 + skipAnalysis: false + tags: + - {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: '{GET}/vertx-web-3_6plus-scenario/case/web-case' operationId: 0 parentSpanId: -1 spanId: 0 @@ -75,15 +107,23 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_6plus-scenario/case/web-case} + - {key: url, value: '/vertx-web-3_6plus-scenario/case/web-case'} - {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 + - 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: '{HEAD}/vertx-web-3_6plus-scenario/case/healthCheck' operationId: 0 parentSpanId: -1 spanId: 0 @@ -97,20 +137,63 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: HEAD} - - {key: url, value: /vertx-web-3_6plus-scenario/case/healthCheck} + - {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', + - {parentEndpoint: '{GET}/vertx-web-3_6plus-scenario/case/web-case', networkAddress: 'localhost:8080', + refType: CrossProcess, parentSpanId: 3, 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: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 59 + isError: false + spanType: Local + peer: '' + skipAnalysis: false + - operationName: '{GET}/vertx-web-3_6plus-scenario/dynamicEndpoint/:id' + 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/dynamicEndpoint/100'} + - {key: status_code, value: '200'} + refs: + - {parentEndpoint: '{GET}/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 + - 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: '{GET}/vertx-web-3_6plus-scenario/case/web-case/withBodyHandler' operationId: 0 parentSpanId: -1 spanId: 0 @@ -124,13 +207,32 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_6plus-scenario/case/web-case/withBodyHandler} + - {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: '#/vertx-web-3_6plus-scenario/dynamicEndpoint/100' + 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: '{GET}/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: org.apache.skywalking.apm.testcase.vertxweb.controller.VertxWebController$$Lambda$.handle(RoutingContext) @@ -146,13 +248,13 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: /vertx-web-3_6plus-scenario/case/web-case/withBodyHandler, + - {parentEndpoint: '{GET}/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 + - operationName: '/vertx-web-3_6plus-scenario/case/web-case/withBodyHandler' operationId: 0 parentSpanId: 0 spanId: 1 @@ -166,7 +268,7 @@ segmentItems: skipAnalysis: false tags: - {key: http.method, value: GET} - - {key: url, value: /vertx-web-3_6plus-scenario/case/web-case/withBodyHandler} + - {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 @@ -181,8 +283,8 @@ segmentItems: peer: '' skipAnalysis: false refs: - - {parentEndpoint: /vertx-web-3_6plus-scenario/case/web-case, networkAddress: '', - refType: CrossThread, parentSpanId: 2, parentTraceSegmentId: not null, + - {parentEndpoint: '{GET}/vertx-web-3_6plus-scenario/case/web-case', networkAddress: '', + refType: CrossThread, parentSpanId: 3, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: vertx-web-3.6plus-scenario, traceId: not null} - segmentId: not null 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 4ea37fbb6..8180a072a 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 @@ -29,6 +29,7 @@ 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/dynamicEndpoint/:id").handler(this::dynamicEndpoint); 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); @@ -36,6 +37,12 @@ public class VertxWebController extends AbstractVerticle { } private void handleWebCase(RoutingContext routingContext) { + //dynamic endpoint test + WebClient.create(vertx).get(8080, "localhost", + "/vertx-web-3_6plus-scenario/dynamicEndpoint/100").send(it -> { + }); + + //non-body and body handler test WebClient.create(vertx).head(8080, "localhost", "/vertx-web-3_6plus-scenario/case/healthCheck") .send(healthCheck -> { if (healthCheck.succeeded()) { @@ -48,6 +55,10 @@ public class VertxWebController extends AbstractVerticle { }); } + private void dynamicEndpoint(RoutingContext routingContext) { + routingContext.response().setStatusCode(200).end("Success"); + } + private void withBodyHandler(RoutingContext routingContext) { routingContext.response().setStatusCode(200).end("Success"); }