diff --git a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml index 4bb71b0e3..e3a7c51e1 100644 --- a/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/spring-async-scenario/config/expectedData.yaml @@ -13,37 +13,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + registryItems: applications: - {spring-async-scenario: 2} instances: - {spring-async-scenario: 1} operationNames: - - spring-async-scenario: [/spring-async-scenario/case/healthCheck, /spring-async-scenario/case/spring-async, - /zh/team/] + - spring-async-scenario: [/spring-async-scenario/case/asyncVisit, /spring-async-scenario/case/spring-async] heartbeat: [] segmentItems: - applicationCode: spring-async-scenario - segmentSize: ge 4 + segmentSize: gt 5 segments: - - segmentId: not null - spans: - - operationName: /spring-async-scenario/case/healthCheck - operationId: 0 - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: 1 - componentName: '' - isError: false - spanType: Entry - peer: '' - peerId: 0 - tags: - - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/healthCheck'} - - {key: http.method, value: HEAD} - segmentId: not null spans: - operationName: /spring-async-scenario/case/spring-async @@ -64,7 +46,53 @@ segmentItems: - {key: http.method, value: GET} - segmentId: not null spans: - - operationName: /zh/team/ + - operationName: /spring-async-scenario/case/asyncVisit + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: SpringAsync, networkAddressId: 0, entryEndpointId: 0, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /spring-async-scenario/case/spring-async, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-async-scenario/case/asyncVisit + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit'} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: SpringAsync, networkAddressId: 0, entryEndpointId: 0, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstanceId: 1, networkAddress: 'localhost:8080', entryEndpoint: /spring-async-scenario/case/spring-async, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /spring-async-scenario/case/asyncVisit operationId: 0 parentSpanId: 0 spanId: 1 @@ -75,10 +103,10 @@ segmentItems: componentName: '' isError: false spanType: Exit - peer: skywalking.apache.org:80 + peer: localhost:8080 peerId: 0 tags: - - {key: url, value: 'http://skywalking.apache.org/zh/team/?k1=v'} + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit?by=system'} - {key: http.method, value: GET} - operationName: SpringAsync operationId: 0 @@ -101,7 +129,7 @@ segmentItems: entryServiceInstanceId: 1} - segmentId: not null spans: - - operationName: /zh/team/ + - operationName: /spring-async-scenario/case/asyncVisit operationId: 0 parentSpanId: 0 spanId: 1 @@ -112,10 +140,10 @@ segmentItems: componentName: '' isError: false spanType: Exit - peer: skywalking.apache.org:80 + peer: localhost:8080 peerId: 0 tags: - - {key: url, value: 'http://skywalking.apache.org/zh/team/?k2=v'} + - {key: url, value: 'http://localhost:8080/spring-async-scenario/case/asyncVisit?by=customize'} - {key: http.method, value: GET} - operationName: SpringAsync operationId: 0 @@ -136,4 +164,3 @@ segmentItems: parentTraceSegmentId: not null, parentServiceInstanceId: 1, networkAddress: '', entryEndpoint: /spring-async-scenario/case/spring-async, entryServiceInstanceId: 1} - diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java index f82d34bcb..2af13c613 100644 --- a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncBean.java @@ -34,11 +34,11 @@ public class AsyncBean { @Async public void sendVisitBySystem() throws IOException { - httpBean.visit("http://skywalking.apache.org/zh/team/?k1=v"); + httpBean.visit("http://localhost:8080/spring-async-scenario/case/asyncVisit?by=system"); } @Async("customizeAsync") public void sendVisitByCustomize() throws IOException { - httpBean.visit("http://skywalking.apache.org/zh/team/?k2=v"); + httpBean.visit("http://localhost:8080/spring-async-scenario/case/asyncVisit?by=customize"); } } diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncServlet.java b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncServlet.java new file mode 100644 index 000000000..33cb3caa5 --- /dev/null +++ b/test/plugin/scenarios/spring-async-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/async/AsyncServlet.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.skywalking.apm.testcase.spring.async; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * @author zhangwei + */ +public class AsyncServlet extends HttpServlet { + + private static final long serialVersionUID = 4644954650555106445L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + PrintWriter writer = resp.getWriter(); + writer.write("Success"); + writer.flush(); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + this.doGet(req, resp); + } +} diff --git a/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml index 581a0290d..9972046e3 100644 --- a/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml +++ b/test/plugin/scenarios/spring-async-scenario/src/main/webapp/WEB-INF/web.xml @@ -39,4 +39,13 @@ healthCheck /case/healthCheck + + + asyncVisit + org.apache.skywalking.apm.testcase.spring.async.AsyncServlet + + + asyncVisit + /case/asyncVisit +