From c54f28714bcb0b29dffa694b8c3fef08b5055bda Mon Sep 17 00:00:00 2001 From: lidiwei Date: Fri, 25 Jul 2025 23:42:53 +0800 Subject: [PATCH 01/28] Add support gRPC 1.60.x and 1.70.x server interceptor trace --- .../apm-sdk-plugin/grpc-1.x-plugin/pom.xml | 3 ++- .../AbstractServerImplBuilderInstrumentation.java | 15 +++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml index b1fc5775ae..deaa7b6642 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml @@ -35,10 +35,11 @@ + io.grpc grpc-all - ${grpc-all.version} + 1.73.0 provided diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java index f32987f4bc..01da3ad244 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java @@ -24,17 +24,13 @@ 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; import static net.bytebuddy.matcher.ElementMatchers.takesNoArguments; -import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; public class AbstractServerImplBuilderInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { - public static final String ENHANCE_CLASS = "io.grpc.internal.AbstractServerImplBuilder"; - public static final String ENHANCE_METHOD = "build"; - public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.server.AbstractServerImplBuilderInterceptor"; - @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; @@ -46,12 +42,12 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD).and(takesNoArguments()); + return named("build").and(takesNoArguments()); } @Override public String getMethodsInterceptor() { - return INTERCEPT_CLASS; + return "org.apache.skywalking.apm.plugin.grpc.v1.server.AbstractServerImplBuilderInterceptor"; } @Override @@ -64,6 +60,9 @@ public boolean isOverrideArgs() { @Override protected ClassMatch enhanceClass() { - return byName(ENHANCE_CLASS); + return MultiClassNameMatch.byMultiClassMatch( + "io.grpc.internal.AbstractServerImplBuilder", + "io.grpc.internal.ServerImplBuilder", + "io.grpc.internal.ForwardingServerBuilder"); } } From fe5cd51b0c2935c0508deea5960ceb4659f92cd7 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Fri, 25 Jul 2025 23:48:21 +0800 Subject: [PATCH 02/28] Add support gRPC 1.60.x and 1.70.x server interceptor trace --- apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml index deaa7b6642..a397ddf2cb 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml @@ -31,7 +31,7 @@ UTF-8 - 1.6.0 + 1.73.0 @@ -39,7 +39,7 @@ io.grpc grpc-all - 1.73.0 + ${grpc-all.version} provided From 0c88fa96a508eccb467cf0b4b1ef3f72c2cfdce3 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 09:59:22 +0800 Subject: [PATCH 03/28] Add case --- .../bin/startup.sh | 21 + .../config/expectedData.yaml | 458 ++++++++++++++++++ .../configuration.yml | 22 + .../grpc-1.60.x-1.70.x-scenario/pom.xml | 162 +++++++ .../src/main/assembly/assembly.xml | 41 ++ .../apm/testcase/grpc/Application.java | 34 ++ .../src/main/proto/GreetService.proto | 43 ++ .../src/main/resources/application.yaml | 23 + .../src/main/resources/log4j2.xml | 30 ++ .../support-version.list | 23 + 10 files changed, 857 insertions(+) create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..02def0f6f6 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/grpc-1.60.x-1.70.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..957b3d1eb0 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml @@ -0,0 +1,458 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: grpc-1.60.x-1.70.x-scenario + segmentSize: gt 10 + segments: + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onComplete + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.Exception} + - {key: message, value: ''} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Request/onComplete + parentSpanId: 2 + spanId: 3 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Response/onClose + parentSpanId: 2 + spanId: 4 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello + parentSpanId: 0 + panId: 2 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onComplete + parentSpanId: 5 + spanId: 6 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Response/onClose + parentSpanId: 5 + spanId: 7 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onCancel + parentSpanId: 5 + spanId: 8 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello + parentSpanId: 0 + spanId: 5 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Exit + peer: 127.0.0.1:18080 + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GET:/grpc-scenario/case/grpc-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: true + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/grpc-scenario/case/grpc-scenario'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: org.springframework.web.util.NestedServletException} + - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: + UNKNOWN'} + - {key: stack, value: not null} + - logEvent: + - {key: forward-url, value: /grpc-scenario/error} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml new file mode 100644 index 0000000000..1740cb5a64 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/grpc-scenario/case/grpc-scenario +healthCheck: http://localhost:8080/grpc-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml new file mode 100644 index 0000000000..41047378c2 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml @@ -0,0 +1,162 @@ + + + + + org.apache.skywalking.apm.testcase + grpc-1.60.x-1.70.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 1.6.2 + + 1.63.1 + + 2.1.6.RELEASE + + + grpc-1.60.x-1.70.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + io.grpc + grpc-all + ${test.framework.version} + + + + + grpc-1.60.x-1.70.x-scenario + + + kr.motd.maven + os-maven-plugin + ${os-maven-plugin.version} + + + initialize + + detect + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + com.google.protobuf:protoc:3.23.4:exe:${os.detected.classifier} + + grpc-java + io.grpc:protoc-gen-grpc-java:1.64.0:exe:${os.detected.classifier} + + + + + + compile + compile-custom + + + + + + + diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..c0ffe42723 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/grpc-1.60.x-1.70.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java new file mode 100644 index 0000000000..052e0f7e3b --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto new file mode 100644 index 0000000000..fd5ba4a8f1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto @@ -0,0 +1,43 @@ +/* + * 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. + * + */ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; + +service Greeter { + rpc SayHello (stream HelloRequest) returns (stream HelloReply) { + } +} + +service GreeterBlocking { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} +service GreeterBlockingError { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..6a22b386b5 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +server: + port: 8080 + servlet: + context-path: /grpc-scenario +logging: + config: classpath:log4j2.xml \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list new file mode 100644 index 0000000000..eb08371680 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 +# So these versions were not included in support-version.list. if you know what caused it, please help us. + +# Contains only the last version number of each minor version + +1.73.0 +1.63.1 From 7288e2e0ac40d353f9cc257f3f00ed2bce8d9e33 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 10:01:12 +0800 Subject: [PATCH 04/28] keep grpc old version --- apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml index a397ddf2cb..b1fc5775ae 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/pom.xml @@ -31,11 +31,10 @@ UTF-8 - 1.73.0 + 1.6.0 - io.grpc grpc-all From 89206ee7f21c20032dda9a2eb79bdd950c13d812 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 12:56:56 +0800 Subject: [PATCH 05/28] Update Docs --- CHANGES.md | 1 + docs/en/setup/service-agent/java-agent/Plugin-list.md | 2 +- docs/en/setup/service-agent/java-agent/Supported-list.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 57df5dde95..fada7555a0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Release Notes. * Fix RabbitMQ Consumer could not receive handleCancelOk callback. * Support for tracking in lettuce versions 6.5.x and above. * Upgrade byte-buddy version to 1.17.6. +* Support gRPC 1.60.x and 1.70.x server interceptor trace All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1) diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index 58a3a50ffc..630485b257 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -33,7 +33,7 @@ - graphql-9.x - graphql-12.x-15.x - graphql-16plus -- grpc-1.x +- grpc-1.x/1.60.x/1.70.x - gson-2.8.x - guava-cache - h2-1.x diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index 23c5680cd3..1063b1c27f 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -62,7 +62,7 @@ metrics based on the tracing data. * [Dubbox](https://github.com/dangdangdotcom/dubbox) 2.8.4 * [Apache Dubbo](https://github.com/apache/dubbo) 2.7.x -> 3.x * [Motan](https://github.com/weibocom/motan) 0.2.x -> 1.1.0 - * [gRPC](https://github.com/grpc/grpc-java) 1.x + * [gRPC](https://github.com/grpc/grpc-java) 1.x, 1.60.x, 1.70.x * [Apache ServiceComb Java Chassis](https://github.com/apache/servicecomb-java-chassis) 1.x, 2.x * [SOFARPC](https://github.com/alipay/sofa-rpc) 5.4.0 * [Armeria](https://github.com/line/armeria) 0.63.0 -> 1.22.0 From 956c9a5c16f8f8303ae46ce7181b557a64968633 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 13:22:34 +0800 Subject: [PATCH 06/28] Fix --- docs/en/setup/service-agent/java-agent/Plugin-list.md | 2 +- docs/en/setup/service-agent/java-agent/Supported-list.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index 630485b257..58a3a50ffc 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -33,7 +33,7 @@ - graphql-9.x - graphql-12.x-15.x - graphql-16plus -- grpc-1.x/1.60.x/1.70.x +- grpc-1.x - gson-2.8.x - guava-cache - h2-1.x diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index 1063b1c27f..23c5680cd3 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -62,7 +62,7 @@ metrics based on the tracing data. * [Dubbox](https://github.com/dangdangdotcom/dubbox) 2.8.4 * [Apache Dubbo](https://github.com/apache/dubbo) 2.7.x -> 3.x * [Motan](https://github.com/weibocom/motan) 0.2.x -> 1.1.0 - * [gRPC](https://github.com/grpc/grpc-java) 1.x, 1.60.x, 1.70.x + * [gRPC](https://github.com/grpc/grpc-java) 1.x * [Apache ServiceComb Java Chassis](https://github.com/apache/servicecomb-java-chassis) 1.x, 2.x * [SOFARPC](https://github.com/alipay/sofa-rpc) 5.4.0 * [Armeria](https://github.com/line/armeria) 0.63.0 -> 1.22.0 From 4551e27d500077a4f3fe066eaae7e084be32d8bb Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 13:25:20 +0800 Subject: [PATCH 07/28] Fix --- .../define/AbstractServerImplBuilderInstrumentation.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java index 01da3ad244..c796d721b3 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java @@ -31,6 +31,9 @@ public class AbstractServerImplBuilderInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + public static final String ENHANCE_METHOD = "build"; + public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.grpc.v1.server.AbstractServerImplBuilderInterceptor"; + @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { return new ConstructorInterceptPoint[0]; @@ -42,12 +45,12 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named("build").and(takesNoArguments()); + return named(ENHANCE_METHOD).and(takesNoArguments()); } @Override public String getMethodsInterceptor() { - return "org.apache.skywalking.apm.plugin.grpc.v1.server.AbstractServerImplBuilderInterceptor"; + return INTERCEPT_CLASS; } @Override From cd4bf58136ddc43bc9359ba53225af476e41614b Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 14:13:56 +0800 Subject: [PATCH 08/28] Add case --- .../grpc/consumr/ConsumerInterceptor.java | 109 ++++++++++++++ .../grpc/controller/CaseController.java | 137 ++++++++++++++++++ .../grpc/provider/ProviderConfiguration.java | 44 ++++++ .../interceptor/ProviderInterceptor.java | 96 ++++++++++++ .../GreeterBlockingErrorServiceImpl.java | 31 ++++ .../service/GreeterBlockingServiceImpl.java | 32 ++++ .../provider/service/GreeterServiceImpl.java | 52 +++++++ 7 files changed, 501 insertions(+) create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java new file mode 100644 index 0000000000..e8a35d0359 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java @@ -0,0 +1,109 @@ +/* + * 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.grpc.consumr; + +import io.grpc.CallOptions; +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.ClientInterceptor; +import io.grpc.ForwardingClientCall; +import io.grpc.ForwardingClientCallListener; +import io.grpc.Metadata; +import io.grpc.MethodDescriptor; +import io.grpc.Status; +import javax.annotation.Nullable; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ConsumerInterceptor implements ClientInterceptor { + + private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); + + @Override + public ClientCall interceptCall(MethodDescriptor descriptor, + CallOptions options, Channel channel) { + LOGGER.info("start interceptor!"); + LOGGER.info("method type: {}", descriptor.getType()); + return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { + @Override + public void start(Listener responseListener, Metadata headers) { + LOGGER.info("Peer: {}", channel.authority()); + LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); + Interceptor tracingResponseListener = new Interceptor(responseListener); + tracingResponseListener.contextSnapshot = "contextSnapshot"; + delegate().start(tracingResponseListener, headers); + } + + @Override + public void cancel(@Nullable String message, @Nullable Throwable cause) { + LOGGER.info("cancel"); + super.cancel(message, cause); + } + + @Override + public void halfClose() { + LOGGER.info("halfClose"); + super.halfClose(); + } + + @Override + public void sendMessage(REQ_T message) { + LOGGER.info("sendMessage ...."); + super.sendMessage(message); + } + }; + } + + private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { + private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); + + private Object contextSnapshot; + + protected Interceptor(ClientCall.Listener delegate) { + super(delegate); + } + + @Override + public void onHeaders(Metadata headers) { + LOGGER.info("on Headers"); + for (String key : headers.keys()) { + LOGGER.info("Receive key: {}", key); + } + delegate().onHeaders(headers); + } + + @Override + public void onMessage(RESP_T message) { + LOGGER.info("contextSnapshot: {}", contextSnapshot); + delegate().onMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + LOGGER.info("on close"); + delegate().onClose(status, trailers); + } + + @Override + public void onReady() { + LOGGER.info("on Ready"); + super.onReady(); + } + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java new file mode 100644 index 0000000000..ecda64ba7a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -0,0 +1,137 @@ +/* + * 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.grpc.controller; + +import io.grpc.ClientInterceptors; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.stub.ClientCallStreamObserver; +import io.grpc.stub.ClientResponseObserver; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import javax.annotation.PostConstruct; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + private final String grpcProviderHost = "127.0.0.1"; + private final int grpcProviderPort = 18080; + private ManagedChannel channel; + private GreeterGrpc.GreeterStub greeterStub; + private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; + private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; + + @PostConstruct + public void up() { + channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); + greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + } + + @RequestMapping("/grpc-scenario") + @ResponseBody + public String testcase() { + greetService(); + greetBlockingService(); + greetBlockingErrorService(); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + + private static List names() { + return Arrays.asList("Sophia", "Jackson"); + } + + private void greetService() { + ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { + private ClientCallStreamObserver requestStream; + + @Override + public void beforeStart(ClientCallStreamObserver observer) { + this.requestStream = observer; + this.requestStream.setOnReadyHandler(new Runnable() { + Iterator iterator = names().iterator(); + + @Override + public void run() { + while (requestStream.isReady()) { + if (iterator.hasNext()) { + String name = iterator.next(); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + requestStream.onNext(request); + } else { + requestStream.onCompleted(); + } + } + } + }); + } + + @Override + public void onNext(HelloReply reply) { + LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); + requestStream.request(1); + } + + public void onError(Throwable throwable) { + LOGGER.error("Failed to send data", throwable); + } + + public void onCompleted() { + LOGGER.info("All Done"); + } + }; + + greeterStub.sayHello(helloReplyStreamObserver); + } + + private void greetBlockingService() { + HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); + greeterBlockingStub.sayHello(request); + } + + private void greetBlockingErrorService() { + HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); + greeterBlockingErrorStub.sayHello(request); + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java new file mode 100644 index 0000000000..8541c403b1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java @@ -0,0 +1,44 @@ +/* + * 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.grpc.provider; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import io.grpc.ServerInterceptors; +import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Configurable +@Component +public class ProviderConfiguration { + + @Bean(initMethod = "start", destroyMethod = "shutdown") + public Server server() { + return ServerBuilder.forPort(18080) + .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) + .build(); + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java new file mode 100644 index 0000000000..26647b41a8 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java @@ -0,0 +1,96 @@ +/* + * 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.grpc.provider.interceptor; + +import io.grpc.ForwardingServerCall; +import io.grpc.ForwardingServerCallListener; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ProviderInterceptor implements ServerInterceptor { + private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); + + @Override + public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, + ServerCallHandler handler) { + Map headerMap = new HashMap(); + for (String key : metadata.keys()) { + LOGGER.info("Receive key: {}", key); + if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { + String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); + + headerMap.put(key, value); + } + } + LOGGER.info("authority : {}", call.getAuthority()); + return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { + @Override + public void sendHeaders(Metadata responseHeaders) { + LOGGER.info("sendHeaders...."); + Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); + responseHeaders.put(headerKey, "test-server"); + delegate().sendHeaders(responseHeaders); + } + + @Override + public void sendMessage(RESQ_T message) { + delegate().sendMessage(message); + } + + }, metadata)) { + @Override + public void onReady() { + LOGGER.info("onReady...."); + delegate().onReady(); + } + + @Override + public void onCancel() { + LOGGER.info("onCancel...."); + delegate().onCancel(); + } + + @Override + public void onComplete() { + LOGGER.info("onComplete...."); + delegate().onComplete(); + } + + @Override + public void onHalfClose() { + LOGGER.info("onHalfClose...."); + delegate().onHalfClose(); + } + + @Override + public void onMessage(REQ_T message) { + LOGGER.info("onMessage...."); + delegate().onMessage(message); + } + }; + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java new file mode 100644 index 0000000000..3cd6394a48 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onError(new Exception()); + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java new file mode 100644 index 0000000000..2f156bc62f --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.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.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + responseObserver.onCompleted(); + } +} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java new file mode 100644 index 0000000000..5235d09318 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { + + private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); + + @Override + public StreamObserver sayHello(final StreamObserver responseObserver) { + StreamObserver requestStreamObserver = new StreamObserver() { + + public void onNext(HelloRequest request) { + LOGGER.info("Receive an message from client. Message: {}", request.getName()); + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + } + + public void onError(Throwable throwable) { + responseObserver.onError(throwable); + } + + public void onCompleted() { + LOGGER.info("End the stream."); + responseObserver.onCompleted(); + } + }; + return requestStreamObserver; + } +} From 5a0b9600de6cdd455122367a443529a2608c234b Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 14:20:31 +0800 Subject: [PATCH 09/28] Update plugins-test.0.yaml --- .github/workflows/plugins-test.0.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index 19127048b5..2df705e42d 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -80,6 +80,7 @@ jobs: - gateway-2.1.x-scenario - gateway-2.0.x-scenario - grpc-scenario + - grpc-1.60.x-1.70.x-scenario - gson-scenario - guava-cache-scenario - elasticjob-3.x-scenario From fa3ff02db12136a1af91a4999fef08208b054ec5 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 15:02:13 +0800 Subject: [PATCH 10/28] Update expectedData.yaml --- .../config/expectedData.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml index 957b3d1eb0..125dd80581 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml @@ -32,7 +32,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -66,7 +66,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -83,7 +83,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -100,7 +100,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -175,7 +175,7 @@ segmentItems: refs: - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -203,7 +203,7 @@ segmentItems: refs: - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -233,7 +233,7 @@ segmentItems: refs: - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -250,7 +250,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -267,7 +267,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -284,7 +284,7 @@ segmentItems: refs: - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -320,7 +320,7 @@ segmentItems: refs: - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-scenario, traceId: not null} + null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: From 0f3dc3c457d9874263856c500fb6414c2d6f518f Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 15:11:13 +0800 Subject: [PATCH 11/28] Update test case --- .../config/expectedData.yaml | 24 +++++++++---------- .../configuration.yml | 4 ++-- .../grpc/controller/CaseController.java | 2 +- .../src/main/resources/application.yaml | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml index 125dd80581..5fe9b89d21 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml @@ -30,7 +30,7 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -47,7 +47,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null} skipAnalysis: 'false' @@ -64,7 +64,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -81,7 +81,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -98,7 +98,7 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -143,7 +143,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null} skipAnalysis: 'false' @@ -248,7 +248,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -265,7 +265,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -282,7 +282,7 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-scenario/case/grpc-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} skipAnalysis: 'false' @@ -432,7 +432,7 @@ segmentItems: - {key: message, value: UNKNOWN} - {key: stack, value: not null} skipAnalysis: 'false' - - operationName: GET:/grpc-scenario/case/grpc-scenario + - operationName: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario parentSpanId: -1 spanId: 0 spanLayer: Http @@ -443,7 +443,7 @@ segmentItems: spanType: Entry peer: '' tags: - - {key: url, value: 'http://localhost:8080/grpc-scenario/case/grpc-scenario'} + - {key: url, value: 'http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario'} - {key: http.method, value: GET} - {key: http.status_code, value: '500'} logs: @@ -454,5 +454,5 @@ segmentItems: UNKNOWN'} - {key: stack, value: not null} - logEvent: - - {key: forward-url, value: /grpc-scenario/error} + - {key: forward-url, value: /grpc-1.60.x-1.70.x-scenario/error} skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml index 1740cb5a64..4482503ff3 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml @@ -15,8 +15,8 @@ # limitations under the License. type: jvm -entryService: http://localhost:8080/grpc-scenario/case/grpc-scenario -healthCheck: http://localhost:8080/grpc-scenario/case/healthCheck +entryService: http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario +healthCheck: http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/healthCheck startScript: ./bin/startup.sh environment: dependencies: diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index ecda64ba7a..edd326b480 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -62,7 +62,7 @@ public void up() { greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); } - @RequestMapping("/grpc-scenario") + @RequestMapping("/grpc-1.60.x-1.70.x-scenario") @ResponseBody public String testcase() { greetService(); diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml index 6a22b386b5..941df5786b 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml @@ -18,6 +18,6 @@ server: port: 8080 servlet: - context-path: /grpc-scenario + context-path: /grpc-1.60.x-1.70.x-scenario logging: - config: classpath:log4j2.xml \ No newline at end of file + config: classpath:log4j2.xml From 0653a4359279fcdc315a77a4f5105b32a01f37ad Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sat, 26 Jul 2025 15:13:05 +0800 Subject: [PATCH 12/28] Update test case --- test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml index 41047378c2..5e84560ceb 100644 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml +++ b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml @@ -38,7 +38,7 @@ 2.1.6.RELEASE - grpc-1.60.x-1.70.x-scenario + skywalking-grpc-1.60.x-1.70.x-scenario From 9677d0316ffdbcc22f474b3c8d7f86c13704ec1d Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sun, 27 Jul 2025 10:06:16 +0800 Subject: [PATCH 13/28] Update grpc test case 1.50.0 -> 1.73.0 --- .github/workflows/plugins-test.0.yaml | 2 +- .../bin/startup.sh | 21 + .../config/expectedData.yaml | 458 ++++++++++++++++++ .../configuration.yml | 22 + .../grpc-1.50.x-1.70.x-scenario/pom.xml | 162 +++++++ .../src/main/assembly/assembly.xml | 41 ++ .../apm/testcase/grpc/Application.java | 34 ++ .../grpc/consumr/ConsumerInterceptor.java | 109 +++++ .../grpc/controller/CaseController.java | 137 ++++++ .../grpc/provider/ProviderConfiguration.java | 44 ++ .../interceptor/ProviderInterceptor.java | 96 ++++ .../GreeterBlockingErrorServiceImpl.java | 31 ++ .../service/GreeterBlockingServiceImpl.java | 32 ++ .../provider/service/GreeterServiceImpl.java | 52 ++ .../src/main/proto/GreetService.proto | 43 ++ .../src/main/resources/application.yaml | 23 + .../src/main/resources/log4j2.xml | 30 ++ .../support-version.list | 44 ++ 18 files changed, 1380 insertions(+), 1 deletion(-) create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index 2df705e42d..b8b77df8d2 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -80,7 +80,7 @@ jobs: - gateway-2.1.x-scenario - gateway-2.0.x-scenario - grpc-scenario - - grpc-1.60.x-1.70.x-scenario + - grpc-1.50.x-1.70.x-scenario - gson-scenario - guava-cache-scenario - elasticjob-3.x-scenario diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..07b863807c --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/grpc-1.50.x-1.70.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..abe44de32c --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml @@ -0,0 +1,458 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: grpc-1.50.x-1.70.x-scenario + segmentSize: gt 10 + segments: + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onComplete + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.Exception} + - {key: message, value: ''} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Request/onComplete + parentSpanId: 2 + spanId: 3 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Response/onClose + parentSpanId: 2 + spanId: 4 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello + parentSpanId: 0 + panId: 2 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onComplete + parentSpanId: 5 + spanId: 6 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Response/onClose + parentSpanId: 5 + spanId: 7 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onCancel + parentSpanId: 5 + spanId: 8 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello + parentSpanId: 0 + spanId: 5 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Exit + peer: 127.0.0.1:18080 + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: true + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: org.springframework.web.util.NestedServletException} + - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: + UNKNOWN'} + - {key: stack, value: not null} + - logEvent: + - {key: forward-url, value: /grpc-1.50.x-1.70.x-scenario/error} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml new file mode 100644 index 0000000000..da7a8357cb --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario +healthCheck: http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml new file mode 100644 index 0000000000..4a8ca711b0 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml @@ -0,0 +1,162 @@ + + + + + org.apache.skywalking.apm.testcase + grpc-1.50.x-1.70.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 1.6.2 + + 1.50.0 + + 2.1.6.RELEASE + + + skywalking-grpc-1.50.x-1.70.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + io.grpc + grpc-all + ${test.framework.version} + + + + + grpc-1.50.x-1.70.x-scenario + + + kr.motd.maven + os-maven-plugin + ${os-maven-plugin.version} + + + initialize + + detect + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + com.google.protobuf:protoc:3.23.4:exe:${os.detected.classifier} + + grpc-java + io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:${os.detected.classifier} + + + + + + compile + compile-custom + + + + + + + diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..c148c146ad --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/grpc-1.50.x-1.70.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java new file mode 100644 index 0000000000..052e0f7e3b --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java new file mode 100644 index 0000000000..e8a35d0359 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java @@ -0,0 +1,109 @@ +/* + * 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.grpc.consumr; + +import io.grpc.CallOptions; +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.ClientInterceptor; +import io.grpc.ForwardingClientCall; +import io.grpc.ForwardingClientCallListener; +import io.grpc.Metadata; +import io.grpc.MethodDescriptor; +import io.grpc.Status; +import javax.annotation.Nullable; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ConsumerInterceptor implements ClientInterceptor { + + private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); + + @Override + public ClientCall interceptCall(MethodDescriptor descriptor, + CallOptions options, Channel channel) { + LOGGER.info("start interceptor!"); + LOGGER.info("method type: {}", descriptor.getType()); + return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { + @Override + public void start(Listener responseListener, Metadata headers) { + LOGGER.info("Peer: {}", channel.authority()); + LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); + Interceptor tracingResponseListener = new Interceptor(responseListener); + tracingResponseListener.contextSnapshot = "contextSnapshot"; + delegate().start(tracingResponseListener, headers); + } + + @Override + public void cancel(@Nullable String message, @Nullable Throwable cause) { + LOGGER.info("cancel"); + super.cancel(message, cause); + } + + @Override + public void halfClose() { + LOGGER.info("halfClose"); + super.halfClose(); + } + + @Override + public void sendMessage(REQ_T message) { + LOGGER.info("sendMessage ...."); + super.sendMessage(message); + } + }; + } + + private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { + private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); + + private Object contextSnapshot; + + protected Interceptor(ClientCall.Listener delegate) { + super(delegate); + } + + @Override + public void onHeaders(Metadata headers) { + LOGGER.info("on Headers"); + for (String key : headers.keys()) { + LOGGER.info("Receive key: {}", key); + } + delegate().onHeaders(headers); + } + + @Override + public void onMessage(RESP_T message) { + LOGGER.info("contextSnapshot: {}", contextSnapshot); + delegate().onMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + LOGGER.info("on close"); + delegate().onClose(status, trailers); + } + + @Override + public void onReady() { + LOGGER.info("on Ready"); + super.onReady(); + } + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java new file mode 100644 index 0000000000..24f5279a9f --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -0,0 +1,137 @@ +/* + * 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.grpc.controller; + +import io.grpc.ClientInterceptors; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.stub.ClientCallStreamObserver; +import io.grpc.stub.ClientResponseObserver; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import javax.annotation.PostConstruct; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + private final String grpcProviderHost = "127.0.0.1"; + private final int grpcProviderPort = 18080; + private ManagedChannel channel; + private GreeterGrpc.GreeterStub greeterStub; + private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; + private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; + + @PostConstruct + public void up() { + channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); + greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + } + + @RequestMapping("/grpc-1.50.x-1.70.x-scenario") + @ResponseBody + public String testcase() { + greetService(); + greetBlockingService(); + greetBlockingErrorService(); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + + private static List names() { + return Arrays.asList("Sophia", "Jackson"); + } + + private void greetService() { + ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { + private ClientCallStreamObserver requestStream; + + @Override + public void beforeStart(ClientCallStreamObserver observer) { + this.requestStream = observer; + this.requestStream.setOnReadyHandler(new Runnable() { + Iterator iterator = names().iterator(); + + @Override + public void run() { + while (requestStream.isReady()) { + if (iterator.hasNext()) { + String name = iterator.next(); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + requestStream.onNext(request); + } else { + requestStream.onCompleted(); + } + } + } + }); + } + + @Override + public void onNext(HelloReply reply) { + LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); + requestStream.request(1); + } + + public void onError(Throwable throwable) { + LOGGER.error("Failed to send data", throwable); + } + + public void onCompleted() { + LOGGER.info("All Done"); + } + }; + + greeterStub.sayHello(helloReplyStreamObserver); + } + + private void greetBlockingService() { + HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); + greeterBlockingStub.sayHello(request); + } + + private void greetBlockingErrorService() { + HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); + greeterBlockingErrorStub.sayHello(request); + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java new file mode 100644 index 0000000000..8541c403b1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java @@ -0,0 +1,44 @@ +/* + * 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.grpc.provider; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import io.grpc.ServerInterceptors; +import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Configurable +@Component +public class ProviderConfiguration { + + @Bean(initMethod = "start", destroyMethod = "shutdown") + public Server server() { + return ServerBuilder.forPort(18080) + .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) + .build(); + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java new file mode 100644 index 0000000000..26647b41a8 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java @@ -0,0 +1,96 @@ +/* + * 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.grpc.provider.interceptor; + +import io.grpc.ForwardingServerCall; +import io.grpc.ForwardingServerCallListener; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ProviderInterceptor implements ServerInterceptor { + private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); + + @Override + public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, + ServerCallHandler handler) { + Map headerMap = new HashMap(); + for (String key : metadata.keys()) { + LOGGER.info("Receive key: {}", key); + if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { + String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); + + headerMap.put(key, value); + } + } + LOGGER.info("authority : {}", call.getAuthority()); + return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { + @Override + public void sendHeaders(Metadata responseHeaders) { + LOGGER.info("sendHeaders...."); + Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); + responseHeaders.put(headerKey, "test-server"); + delegate().sendHeaders(responseHeaders); + } + + @Override + public void sendMessage(RESQ_T message) { + delegate().sendMessage(message); + } + + }, metadata)) { + @Override + public void onReady() { + LOGGER.info("onReady...."); + delegate().onReady(); + } + + @Override + public void onCancel() { + LOGGER.info("onCancel...."); + delegate().onCancel(); + } + + @Override + public void onComplete() { + LOGGER.info("onComplete...."); + delegate().onComplete(); + } + + @Override + public void onHalfClose() { + LOGGER.info("onHalfClose...."); + delegate().onHalfClose(); + } + + @Override + public void onMessage(REQ_T message) { + LOGGER.info("onMessage...."); + delegate().onMessage(message); + } + }; + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java new file mode 100644 index 0000000000..3cd6394a48 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onError(new Exception()); + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java new file mode 100644 index 0000000000..2f156bc62f --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.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.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + responseObserver.onCompleted(); + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java new file mode 100644 index 0000000000..5235d09318 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { + + private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); + + @Override + public StreamObserver sayHello(final StreamObserver responseObserver) { + StreamObserver requestStreamObserver = new StreamObserver() { + + public void onNext(HelloRequest request) { + LOGGER.info("Receive an message from client. Message: {}", request.getName()); + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + } + + public void onError(Throwable throwable) { + responseObserver.onError(throwable); + } + + public void onCompleted() { + LOGGER.info("End the stream."); + responseObserver.onCompleted(); + } + }; + return requestStreamObserver; + } +} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto new file mode 100644 index 0000000000..fd5ba4a8f1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto @@ -0,0 +1,43 @@ +/* + * 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. + * + */ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; + +service Greeter { + rpc SayHello (stream HelloRequest) returns (stream HelloReply) { + } +} + +service GreeterBlocking { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} +service GreeterBlockingError { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..1ed0f442a1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +server: + port: 8080 + servlet: + context-path: /grpc-1.50.x-1.70.x-scenario +logging: + config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list new file mode 100644 index 0000000000..ebc1703006 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list @@ -0,0 +1,44 @@ +# 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. + +# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 +# So these versions were not included in support-version.list. if you know what caused it, please help us. + +# Contains only the last version number of each minor version + +1.73.0 +1.72.0 +1.71.0 +1.70.0 +1.69.0 +1.68.0 +1.67.1 +1.66.0 +1.65.0 +1.64.0 +1.63.0 +1.62.2 +1.61.0 +1.60.0 +1.59.0 +1.58.0 +1.57.0 +1.56.0 +1.55.1 +1.54.0 +1.53.0 +1.52.0 +1.51.0 From 29a1f0a5df4b82027b2b510cb1099cfaa90dce2e Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sun, 27 Jul 2025 10:45:13 +0800 Subject: [PATCH 14/28] Remove grpc-1.60.x-1.70.x-scenario --- .../bin/startup.sh | 21 - .../config/expectedData.yaml | 458 ------------------ .../configuration.yml | 22 - .../grpc-1.60.x-1.70.x-scenario/pom.xml | 162 ------- .../src/main/assembly/assembly.xml | 41 -- .../apm/testcase/grpc/Application.java | 34 -- .../grpc/consumr/ConsumerInterceptor.java | 109 ----- .../grpc/controller/CaseController.java | 137 ------ .../grpc/provider/ProviderConfiguration.java | 44 -- .../interceptor/ProviderInterceptor.java | 96 ---- .../GreeterBlockingErrorServiceImpl.java | 31 -- .../service/GreeterBlockingServiceImpl.java | 32 -- .../provider/service/GreeterServiceImpl.java | 52 -- .../src/main/proto/GreetService.proto | 43 -- .../src/main/resources/application.yaml | 23 - .../src/main/resources/log4j2.xml | 30 -- .../support-version.list | 23 - 17 files changed, 1358 deletions(-) delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml delete mode 100644 test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh deleted file mode 100644 index 02def0f6f6..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/bin/startup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -home="$(cd "$(dirname $0)"; pwd)" - -java -jar ${agent_opts} ${home}/../libs/grpc-1.60.x-1.70.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml deleted file mode 100644 index 5fe9b89d21..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/config/expectedData.yaml +++ /dev/null @@ -1,458 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -segmentItems: - - serviceName: grpc-1.60.x-1.70.x-scenario - segmentSize: gt 10 - segments: - - segmentId: not null - spans: - - operationName: GreeterBlocking.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onComplete - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onMessage - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlocking.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: OK} - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onMessage - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: OK} - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlockingError.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlockingError.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: UNKNOWN} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: java.lang.Exception} - - {key: message, value: ''} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.60.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Exit - peer: '127.0.0.1:18080' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/client/Request/onComplete - parentSpanId: 2 - spanId: 3 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/client/Response/onClose - parentSpanId: 2 - spanId: 4 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello - parentSpanId: 0 - panId: 2 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Exit - peer: '127.0.0.1:18080' - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Request/onComplete - parentSpanId: 5 - spanId: 6 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Response/onClose - parentSpanId: 5 - spanId: 7 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: UNKNOWN} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Request/onCancel - parentSpanId: 5 - spanId: 8 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello - parentSpanId: 0 - spanId: 5 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Exit - peer: 127.0.0.1:18080 - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GET:/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: 1 - isError: true - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario'} - - {key: http.method, value: GET} - - {key: http.status_code, value: '500'} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: org.springframework.web.util.NestedServletException} - - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: - UNKNOWN'} - - {key: stack, value: not null} - - logEvent: - - {key: forward-url, value: /grpc-1.60.x-1.70.x-scenario/error} - skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml deleted file mode 100644 index 4482503ff3..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/configuration.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -type: jvm -entryService: http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/grpc-1.60.x-1.70.x-scenario -healthCheck: http://localhost:8080/grpc-1.60.x-1.70.x-scenario/case/healthCheck -startScript: ./bin/startup.sh -environment: -dependencies: diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml deleted file mode 100644 index 5e84560ceb..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - org.apache.skywalking.apm.testcase - grpc-1.60.x-1.70.x-scenario - 1.0.0 - jar - - 4.0.0 - - - UTF-8 - 1.8 - 3.8.1 - 1.6.2 - - 1.63.1 - - 2.1.6.RELEASE - - - skywalking-grpc-1.60.x-1.70.x-scenario - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - - - io.grpc - grpc-all - ${test.framework.version} - - - - - grpc-1.60.x-1.70.x-scenario - - - kr.motd.maven - os-maven-plugin - ${os-maven-plugin.version} - - - initialize - - detect - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${compiler.version} - ${compiler.version} - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-assembly-plugin - - - assemble - package - - single - - - - src/main/assembly/assembly.xml - - ./target/ - - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - - - com.google.protobuf:protoc:3.23.4:exe:${os.detected.classifier} - - grpc-java - io.grpc:protoc-gen-grpc-java:1.64.0:exe:${os.detected.classifier} - - - - - - compile - compile-custom - - - - - - - diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml deleted file mode 100644 index c0ffe42723..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/assembly/assembly.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - zip - - - - - ./bin - 0775 - - - - - - ${project.build.directory}/grpc-1.60.x-1.70.x-scenario.jar - ./libs - 0775 - - - diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java deleted file mode 100644 index 052e0f7e3b..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.grpc; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - try { - SpringApplication.run(Application.class, args); - } catch (Exception e) { - // Never do this - } - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java deleted file mode 100644 index e8a35d0359..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.grpc.consumr; - -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; -import io.grpc.ForwardingClientCall; -import io.grpc.ForwardingClientCallListener; -import io.grpc.Metadata; -import io.grpc.MethodDescriptor; -import io.grpc.Status; -import javax.annotation.Nullable; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ConsumerInterceptor implements ClientInterceptor { - - private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); - - @Override - public ClientCall interceptCall(MethodDescriptor descriptor, - CallOptions options, Channel channel) { - LOGGER.info("start interceptor!"); - LOGGER.info("method type: {}", descriptor.getType()); - return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { - @Override - public void start(Listener responseListener, Metadata headers) { - LOGGER.info("Peer: {}", channel.authority()); - LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); - Interceptor tracingResponseListener = new Interceptor(responseListener); - tracingResponseListener.contextSnapshot = "contextSnapshot"; - delegate().start(tracingResponseListener, headers); - } - - @Override - public void cancel(@Nullable String message, @Nullable Throwable cause) { - LOGGER.info("cancel"); - super.cancel(message, cause); - } - - @Override - public void halfClose() { - LOGGER.info("halfClose"); - super.halfClose(); - } - - @Override - public void sendMessage(REQ_T message) { - LOGGER.info("sendMessage ...."); - super.sendMessage(message); - } - }; - } - - private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { - private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); - - private Object contextSnapshot; - - protected Interceptor(ClientCall.Listener delegate) { - super(delegate); - } - - @Override - public void onHeaders(Metadata headers) { - LOGGER.info("on Headers"); - for (String key : headers.keys()) { - LOGGER.info("Receive key: {}", key); - } - delegate().onHeaders(headers); - } - - @Override - public void onMessage(RESP_T message) { - LOGGER.info("contextSnapshot: {}", contextSnapshot); - delegate().onMessage(message); - } - - @Override - public void onClose(Status status, Metadata trailers) { - LOGGER.info("on close"); - delegate().onClose(status, trailers); - } - - @Override - public void onReady() { - LOGGER.info("on Ready"); - super.onReady(); - } - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java deleted file mode 100644 index edd326b480..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.grpc.controller; - -import io.grpc.ClientInterceptors; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import io.grpc.stub.ClientCallStreamObserver; -import io.grpc.stub.ClientResponseObserver; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import javax.annotation.PostConstruct; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/case") -public class CaseController { - - private static final Logger LOGGER = LogManager.getLogger(CaseController.class); - - private static final String SUCCESS = "Success"; - - private final String grpcProviderHost = "127.0.0.1"; - private final int grpcProviderPort = 18080; - private ManagedChannel channel; - private GreeterGrpc.GreeterStub greeterStub; - private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; - private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; - - @PostConstruct - public void up() { - channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); - greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - } - - @RequestMapping("/grpc-1.60.x-1.70.x-scenario") - @ResponseBody - public String testcase() { - greetService(); - greetBlockingService(); - greetBlockingErrorService(); - return SUCCESS; - } - - @RequestMapping("/healthCheck") - @ResponseBody - public String healthCheck() { - // your codes - return SUCCESS; - } - - private static List names() { - return Arrays.asList("Sophia", "Jackson"); - } - - private void greetService() { - ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { - private ClientCallStreamObserver requestStream; - - @Override - public void beforeStart(ClientCallStreamObserver observer) { - this.requestStream = observer; - this.requestStream.setOnReadyHandler(new Runnable() { - Iterator iterator = names().iterator(); - - @Override - public void run() { - while (requestStream.isReady()) { - if (iterator.hasNext()) { - String name = iterator.next(); - HelloRequest request = HelloRequest.newBuilder().setName(name).build(); - requestStream.onNext(request); - } else { - requestStream.onCompleted(); - } - } - } - }); - } - - @Override - public void onNext(HelloReply reply) { - LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); - requestStream.request(1); - } - - public void onError(Throwable throwable) { - LOGGER.error("Failed to send data", throwable); - } - - public void onCompleted() { - LOGGER.info("All Done"); - } - }; - - greeterStub.sayHello(helloReplyStreamObserver); - } - - private void greetBlockingService() { - HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); - greeterBlockingStub.sayHello(request); - } - - private void greetBlockingErrorService() { - HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); - greeterBlockingErrorStub.sayHello(request); - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java deleted file mode 100644 index 8541c403b1..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.grpc.provider; - -import io.grpc.Server; -import io.grpc.ServerBuilder; -import io.grpc.ServerInterceptors; -import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -@Configurable -@Component -public class ProviderConfiguration { - - @Bean(initMethod = "start", destroyMethod = "shutdown") - public Server server() { - return ServerBuilder.forPort(18080) - .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) - .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) - .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) - .build(); - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java deleted file mode 100644 index 26647b41a8..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.grpc.provider.interceptor; - -import io.grpc.ForwardingServerCall; -import io.grpc.ForwardingServerCallListener; -import io.grpc.Metadata; -import io.grpc.ServerCall; -import io.grpc.ServerCallHandler; -import io.grpc.ServerInterceptor; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ProviderInterceptor implements ServerInterceptor { - private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); - - @Override - public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, - ServerCallHandler handler) { - Map headerMap = new HashMap(); - for (String key : metadata.keys()) { - LOGGER.info("Receive key: {}", key); - if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { - String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); - - headerMap.put(key, value); - } - } - LOGGER.info("authority : {}", call.getAuthority()); - return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { - @Override - public void sendHeaders(Metadata responseHeaders) { - LOGGER.info("sendHeaders...."); - Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); - responseHeaders.put(headerKey, "test-server"); - delegate().sendHeaders(responseHeaders); - } - - @Override - public void sendMessage(RESQ_T message) { - delegate().sendMessage(message); - } - - }, metadata)) { - @Override - public void onReady() { - LOGGER.info("onReady...."); - delegate().onReady(); - } - - @Override - public void onCancel() { - LOGGER.info("onCancel...."); - delegate().onCancel(); - } - - @Override - public void onComplete() { - LOGGER.info("onComplete...."); - delegate().onComplete(); - } - - @Override - public void onHalfClose() { - LOGGER.info("onHalfClose...."); - delegate().onHalfClose(); - } - - @Override - public void onMessage(REQ_T message) { - LOGGER.info("onMessage...."); - delegate().onMessage(message); - } - }; - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java deleted file mode 100644 index 3cd6394a48..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { - @Override - public void sayHello(HelloRequest request, StreamObserver responseObserver) { - responseObserver.onError(new Exception()); - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java deleted file mode 100644 index 2f156bc62f..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { - @Override - public void sayHello(HelloRequest request, StreamObserver responseObserver) { - responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); - responseObserver.onCompleted(); - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java deleted file mode 100644 index 5235d09318..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { - - private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); - - @Override - public StreamObserver sayHello(final StreamObserver responseObserver) { - StreamObserver requestStreamObserver = new StreamObserver() { - - public void onNext(HelloRequest request) { - LOGGER.info("Receive an message from client. Message: {}", request.getName()); - responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); - } - - public void onError(Throwable throwable) { - responseObserver.onError(throwable); - } - - public void onCompleted() { - LOGGER.info("End the stream."); - responseObserver.onCompleted(); - } - }; - return requestStreamObserver; - } -} diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto deleted file mode 100644 index fd5ba4a8f1..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/proto/GreetService.proto +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - * - */ -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; - -service Greeter { - rpc SayHello (stream HelloRequest) returns (stream HelloReply) { - } -} - -service GreeterBlocking { - rpc SayHello (HelloRequest) returns (HelloReply) { - } -} -service GreeterBlockingError { - rpc SayHello (HelloRequest) returns (HelloReply) { - } -} - -message HelloRequest { - string name = 1; -} - -message HelloReply { - string message = 1; -} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml deleted file mode 100644 index 941df5786b..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/application.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -server: - port: 8080 - servlet: - context-path: /grpc-1.60.x-1.70.x-scenario -logging: - config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml deleted file mode 100644 index 9849ed5a8a..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list deleted file mode 100644 index eb08371680..0000000000 --- a/test/plugin/scenarios/grpc-1.60.x-1.70.x-scenario/support-version.list +++ /dev/null @@ -1,23 +0,0 @@ -# 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. - -# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 -# So these versions were not included in support-version.list. if you know what caused it, please help us. - -# Contains only the last version number of each minor version - -1.73.0 -1.63.1 From 303ffd42554d215b3428dbac53d4df8a796e443a Mon Sep 17 00:00:00 2001 From: lidiwei Date: Sun, 27 Jul 2025 10:53:17 +0800 Subject: [PATCH 15/28] Note enhancement points --- .../define/AbstractServerImplBuilderInstrumentation.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java index c796d721b3..d9c7fc7391 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java @@ -64,8 +64,9 @@ public boolean isOverrideArgs() { @Override protected ClassMatch enhanceClass() { return MultiClassNameMatch.byMultiClassMatch( - "io.grpc.internal.AbstractServerImplBuilder", - "io.grpc.internal.ServerImplBuilder", - "io.grpc.internal.ForwardingServerBuilder"); + "io.grpc.internal.AbstractServerImplBuilder", //grpc version <= 1.58.1 + "io.grpc.internal.ServerImplBuilder", //grpc version >= 1.59.0 + "io.grpc.internal.ForwardingServerBuilder" //grpc version >= 1.59.0 + ); } } From 611071ad8c9c31b27b8209dd5c07be9a332be73c Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 09:46:10 +0800 Subject: [PATCH 16/28] Fix Repeat Add trace interceptor --- ...tractServerImplBuilderInstrumentation.java | 3 +- .../AbstractServerImplBuilderInterceptor.java | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java index d9c7fc7391..bd71445d7c 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/define/AbstractServerImplBuilderInstrumentation.java @@ -65,8 +65,7 @@ public boolean isOverrideArgs() { protected ClassMatch enhanceClass() { return MultiClassNameMatch.byMultiClassMatch( "io.grpc.internal.AbstractServerImplBuilder", //grpc version <= 1.58.1 - "io.grpc.internal.ServerImplBuilder", //grpc version >= 1.59.0 - "io.grpc.internal.ForwardingServerBuilder" //grpc version >= 1.59.0 + "io.grpc.internal.ServerImplBuilder" //grpc version >= 1.59.0 ); } } diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java index c02cf566de..b0a4654be3 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java @@ -20,7 +20,9 @@ import io.grpc.ServerBuilder; +import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.List; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; @@ -32,12 +34,23 @@ public class AbstractServerImplBuilderInterceptor implements InstanceMethodsAroundInterceptor { @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, - MethodInterceptResult result) { + MethodInterceptResult result) throws Throwable { if (objInst.getSkyWalkingDynamicField() == null) { ServerBuilder builder = (ServerBuilder) objInst; - ServerInterceptor interceptor = new ServerInterceptor(); - builder.intercept(interceptor); - objInst.setSkyWalkingDynamicField(interceptor); + Field field = findField(builder.getClass()); + if (field != null) { + field.setAccessible(true); + List interceptors = (List) field.get(builder); + boolean hasCustomInterceptor = interceptors.stream() + .anyMatch(i -> i.getClass() == ServerInterceptor.class); + + if (!hasCustomInterceptor) { + ServerInterceptor interceptor = new ServerInterceptor(); + builder.intercept(interceptor); + objInst.setSkyWalkingDynamicField(interceptor); + } + + } } } @@ -52,4 +65,16 @@ public void handleMethodException(EnhancedInstance objInst, Method method, Objec Class[] argumentsTypes, Throwable t) { } + + private static Field findField(Class clazz) { + while (clazz != null) { + for (Field f : clazz.getDeclaredFields()) { + if (f.getName().equals("interceptors")) { + return f; + } + } + clazz = clazz.getSuperclass(); + } + return null; + } } From 3b5f02fba711c183824db54203bf6fe05c384187 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 12:00:57 +0800 Subject: [PATCH 17/28] Add Field Cache --- .../AbstractServerImplBuilderInterceptor.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java index b0a4654be3..cf1bcf4f76 100644 --- a/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/grpc-1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/grpc/v1/server/AbstractServerImplBuilderInterceptor.java @@ -22,7 +22,9 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor; @@ -32,6 +34,8 @@ * {@link AbstractServerImplBuilderInterceptor} add the {@link ServerInterceptor} interceptor for every ServerService. */ public class AbstractServerImplBuilderInterceptor implements InstanceMethodsAroundInterceptor { + private final static Map, Field> FIELD_CACHE = new HashMap<>(); + @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { @@ -39,7 +43,6 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr ServerBuilder builder = (ServerBuilder) objInst; Field field = findField(builder.getClass()); if (field != null) { - field.setAccessible(true); List interceptors = (List) field.get(builder); boolean hasCustomInterceptor = interceptors.stream() .anyMatch(i -> i.getClass() == ServerInterceptor.class); @@ -67,9 +70,24 @@ public void handleMethodException(EnhancedInstance objInst, Method method, Objec } private static Field findField(Class clazz) { + if (FIELD_CACHE.containsKey(clazz)) { + return FIELD_CACHE.get(clazz); + } + synchronized (AbstractServerImplBuilderInterceptor.class) { + if (FIELD_CACHE.containsKey(clazz)) { + return FIELD_CACHE.get(clazz); + } + Field field = doFindField(clazz); + FIELD_CACHE.put(clazz, field); + return field; + } + } + + private static Field doFindField(Class clazz) { while (clazz != null) { for (Field f : clazz.getDeclaredFields()) { if (f.getName().equals("interceptors")) { + f.setAccessible(true); return f; } } From bd35702c3f33f0f4e7b88133a913332705b7ddfa Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 12:48:21 +0800 Subject: [PATCH 18/28] only support grpc 1.59-1.70.x --- .github/workflows/plugins-test.0.yaml | 2 +- .../bin/startup.sh | 21 - .../config/expectedData.yaml | 458 ------------------ .../configuration.yml | 22 - .../grpc-1.50.x-1.70.x-scenario/pom.xml | 162 ------- .../src/main/assembly/assembly.xml | 41 -- .../apm/testcase/grpc/Application.java | 34 -- .../grpc/consumr/ConsumerInterceptor.java | 109 ----- .../grpc/controller/CaseController.java | 137 ------ .../grpc/provider/ProviderConfiguration.java | 44 -- .../interceptor/ProviderInterceptor.java | 96 ---- .../GreeterBlockingErrorServiceImpl.java | 31 -- .../service/GreeterBlockingServiceImpl.java | 32 -- .../provider/service/GreeterServiceImpl.java | 52 -- .../src/main/proto/GreetService.proto | 43 -- .../src/main/resources/application.yaml | 23 - .../src/main/resources/log4j2.xml | 30 -- .../support-version.list | 44 -- 18 files changed, 1 insertion(+), 1380 deletions(-) delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml delete mode 100644 test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index b8b77df8d2..c5fc3b0b27 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -80,7 +80,7 @@ jobs: - gateway-2.1.x-scenario - gateway-2.0.x-scenario - grpc-scenario - - grpc-1.50.x-1.70.x-scenario + - grpc-1.59.x-1.70.x-scenario - gson-scenario - guava-cache-scenario - elasticjob-3.x-scenario diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh deleted file mode 100644 index 07b863807c..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/bin/startup.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -home="$(cd "$(dirname $0)"; pwd)" - -java -jar ${agent_opts} ${home}/../libs/grpc-1.50.x-1.70.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml deleted file mode 100644 index abe44de32c..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/config/expectedData.yaml +++ /dev/null @@ -1,458 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -segmentItems: - - serviceName: grpc-1.50.x-1.70.x-scenario - segmentSize: gt 10 - segments: - - segmentId: not null - spans: - - operationName: GreeterBlocking.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Request/onComplete - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onMessage - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: not null, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlocking.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: OK} - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onMessage - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: OK} - skipAnalysis: 'false' - - operationName: Greeter.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onMessage - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello/client/Response/onClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, - parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlockingError.sayHello - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Entry - peer: '' - refs: - - {parentEndpoint: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', - refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: GreeterBlockingError.sayHello/server/Response/onClose - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: UNKNOWN} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: java.lang.Exception} - - {key: message, value: ''} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose - parentSpanId: -1 - spanId: 0 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - refs: - - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, - parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.50.x-1.70.x-scenario, traceId: not null} - skipAnalysis: 'false' - - segmentId: not null - spans: - - operationName: Greeter.sayHello - parentSpanId: 0 - spanId: 1 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Exit - peer: '127.0.0.1:18080' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/client/Request/onComplete - parentSpanId: 2 - spanId: 3 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello/client/Response/onClose - parentSpanId: 2 - spanId: 4 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlocking.sayHello - parentSpanId: 0 - panId: 2 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Exit - peer: '127.0.0.1:18080' - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Request/onComplete - parentSpanId: 5 - spanId: 6 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: false - spanType: Local - peer: '' - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Response/onClose - parentSpanId: 5 - spanId: 7 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - tags: - - {key: rpc.status_code, value: UNKNOWN} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello/client/Request/onCancel - parentSpanId: 5 - spanId: 8 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Local - peer: '' - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GreeterBlockingError.sayHello - parentSpanId: 0 - spanId: 5 - spanLayer: RPCFramework - startTime: nq 0 - endTime: nq 0 - componentId: 23 - isError: true - spanType: Exit - peer: 127.0.0.1:18080 - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: io.grpc.StatusRuntimeException} - - {key: message, value: UNKNOWN} - - {key: stack, value: not null} - skipAnalysis: 'false' - - operationName: GET:/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario - parentSpanId: -1 - spanId: 0 - spanLayer: Http - startTime: nq 0 - endTime: nq 0 - componentId: 1 - isError: true - spanType: Entry - peer: '' - tags: - - {key: url, value: 'http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario'} - - {key: http.method, value: GET} - - {key: http.status_code, value: '500'} - logs: - - logEvent: - - {key: event, value: error} - - {key: error.kind, value: org.springframework.web.util.NestedServletException} - - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: - UNKNOWN'} - - {key: stack, value: not null} - - logEvent: - - {key: forward-url, value: /grpc-1.50.x-1.70.x-scenario/error} - skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml deleted file mode 100644 index da7a8357cb..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/configuration.yml +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -type: jvm -entryService: http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/grpc-1.50.x-1.70.x-scenario -healthCheck: http://localhost:8080/grpc-1.50.x-1.70.x-scenario/case/healthCheck -startScript: ./bin/startup.sh -environment: -dependencies: diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml deleted file mode 100644 index 4a8ca711b0..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/pom.xml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - org.apache.skywalking.apm.testcase - grpc-1.50.x-1.70.x-scenario - 1.0.0 - jar - - 4.0.0 - - - UTF-8 - 1.8 - 3.8.1 - 1.6.2 - - 1.50.0 - - 2.1.6.RELEASE - - - skywalking-grpc-1.50.x-1.70.x-scenario - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - - - io.grpc - grpc-all - ${test.framework.version} - - - - - grpc-1.50.x-1.70.x-scenario - - - kr.motd.maven - os-maven-plugin - ${os-maven-plugin.version} - - - initialize - - detect - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${compiler.version} - ${compiler.version} - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-assembly-plugin - - - assemble - package - - single - - - - src/main/assembly/assembly.xml - - ./target/ - - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.6.1 - - - com.google.protobuf:protoc:3.23.4:exe:${os.detected.classifier} - - grpc-java - io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:${os.detected.classifier} - - - - - - compile - compile-custom - - - - - - - diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml deleted file mode 100644 index c148c146ad..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/assembly/assembly.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - zip - - - - - ./bin - 0775 - - - - - - ${project.build.directory}/grpc-1.50.x-1.70.x-scenario.jar - ./libs - 0775 - - - diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java deleted file mode 100644 index 052e0f7e3b..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.grpc; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - try { - SpringApplication.run(Application.class, args); - } catch (Exception e) { - // Never do this - } - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java deleted file mode 100644 index e8a35d0359..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * 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.grpc.consumr; - -import io.grpc.CallOptions; -import io.grpc.Channel; -import io.grpc.ClientCall; -import io.grpc.ClientInterceptor; -import io.grpc.ForwardingClientCall; -import io.grpc.ForwardingClientCallListener; -import io.grpc.Metadata; -import io.grpc.MethodDescriptor; -import io.grpc.Status; -import javax.annotation.Nullable; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ConsumerInterceptor implements ClientInterceptor { - - private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); - - @Override - public ClientCall interceptCall(MethodDescriptor descriptor, - CallOptions options, Channel channel) { - LOGGER.info("start interceptor!"); - LOGGER.info("method type: {}", descriptor.getType()); - return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { - @Override - public void start(Listener responseListener, Metadata headers) { - LOGGER.info("Peer: {}", channel.authority()); - LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); - Interceptor tracingResponseListener = new Interceptor(responseListener); - tracingResponseListener.contextSnapshot = "contextSnapshot"; - delegate().start(tracingResponseListener, headers); - } - - @Override - public void cancel(@Nullable String message, @Nullable Throwable cause) { - LOGGER.info("cancel"); - super.cancel(message, cause); - } - - @Override - public void halfClose() { - LOGGER.info("halfClose"); - super.halfClose(); - } - - @Override - public void sendMessage(REQ_T message) { - LOGGER.info("sendMessage ...."); - super.sendMessage(message); - } - }; - } - - private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { - private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); - - private Object contextSnapshot; - - protected Interceptor(ClientCall.Listener delegate) { - super(delegate); - } - - @Override - public void onHeaders(Metadata headers) { - LOGGER.info("on Headers"); - for (String key : headers.keys()) { - LOGGER.info("Receive key: {}", key); - } - delegate().onHeaders(headers); - } - - @Override - public void onMessage(RESP_T message) { - LOGGER.info("contextSnapshot: {}", contextSnapshot); - delegate().onMessage(message); - } - - @Override - public void onClose(Status status, Metadata trailers) { - LOGGER.info("on close"); - delegate().onClose(status, trailers); - } - - @Override - public void onReady() { - LOGGER.info("on Ready"); - super.onReady(); - } - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java deleted file mode 100644 index 24f5279a9f..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.grpc.controller; - -import io.grpc.ClientInterceptors; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; -import io.grpc.stub.ClientCallStreamObserver; -import io.grpc.stub.ClientResponseObserver; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import javax.annotation.PostConstruct; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/case") -public class CaseController { - - private static final Logger LOGGER = LogManager.getLogger(CaseController.class); - - private static final String SUCCESS = "Success"; - - private final String grpcProviderHost = "127.0.0.1"; - private final int grpcProviderPort = 18080; - private ManagedChannel channel; - private GreeterGrpc.GreeterStub greeterStub; - private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; - private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; - - @PostConstruct - public void up() { - channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); - greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); - } - - @RequestMapping("/grpc-1.50.x-1.70.x-scenario") - @ResponseBody - public String testcase() { - greetService(); - greetBlockingService(); - greetBlockingErrorService(); - return SUCCESS; - } - - @RequestMapping("/healthCheck") - @ResponseBody - public String healthCheck() { - // your codes - return SUCCESS; - } - - private static List names() { - return Arrays.asList("Sophia", "Jackson"); - } - - private void greetService() { - ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { - private ClientCallStreamObserver requestStream; - - @Override - public void beforeStart(ClientCallStreamObserver observer) { - this.requestStream = observer; - this.requestStream.setOnReadyHandler(new Runnable() { - Iterator iterator = names().iterator(); - - @Override - public void run() { - while (requestStream.isReady()) { - if (iterator.hasNext()) { - String name = iterator.next(); - HelloRequest request = HelloRequest.newBuilder().setName(name).build(); - requestStream.onNext(request); - } else { - requestStream.onCompleted(); - } - } - } - }); - } - - @Override - public void onNext(HelloReply reply) { - LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); - requestStream.request(1); - } - - public void onError(Throwable throwable) { - LOGGER.error("Failed to send data", throwable); - } - - public void onCompleted() { - LOGGER.info("All Done"); - } - }; - - greeterStub.sayHello(helloReplyStreamObserver); - } - - private void greetBlockingService() { - HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); - greeterBlockingStub.sayHello(request); - } - - private void greetBlockingErrorService() { - HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); - greeterBlockingErrorStub.sayHello(request); - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java deleted file mode 100644 index 8541c403b1..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.grpc.provider; - -import io.grpc.Server; -import io.grpc.ServerBuilder; -import io.grpc.ServerInterceptors; -import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; -import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; -import org.springframework.beans.factory.annotation.Configurable; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -@Configurable -@Component -public class ProviderConfiguration { - - @Bean(initMethod = "start", destroyMethod = "shutdown") - public Server server() { - return ServerBuilder.forPort(18080) - .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) - .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) - .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) - .build(); - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java deleted file mode 100644 index 26647b41a8..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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.grpc.provider.interceptor; - -import io.grpc.ForwardingServerCall; -import io.grpc.ForwardingServerCallListener; -import io.grpc.Metadata; -import io.grpc.ServerCall; -import io.grpc.ServerCallHandler; -import io.grpc.ServerInterceptor; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class ProviderInterceptor implements ServerInterceptor { - private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); - - @Override - public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, - ServerCallHandler handler) { - Map headerMap = new HashMap(); - for (String key : metadata.keys()) { - LOGGER.info("Receive key: {}", key); - if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { - String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); - - headerMap.put(key, value); - } - } - LOGGER.info("authority : {}", call.getAuthority()); - return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { - @Override - public void sendHeaders(Metadata responseHeaders) { - LOGGER.info("sendHeaders...."); - Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); - responseHeaders.put(headerKey, "test-server"); - delegate().sendHeaders(responseHeaders); - } - - @Override - public void sendMessage(RESQ_T message) { - delegate().sendMessage(message); - } - - }, metadata)) { - @Override - public void onReady() { - LOGGER.info("onReady...."); - delegate().onReady(); - } - - @Override - public void onCancel() { - LOGGER.info("onCancel...."); - delegate().onCancel(); - } - - @Override - public void onComplete() { - LOGGER.info("onComplete...."); - delegate().onComplete(); - } - - @Override - public void onHalfClose() { - LOGGER.info("onHalfClose...."); - delegate().onHalfClose(); - } - - @Override - public void onMessage(REQ_T message) { - LOGGER.info("onMessage...."); - delegate().onMessage(message); - } - }; - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java deleted file mode 100644 index 3cd6394a48..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { - @Override - public void sayHello(HelloRequest request, StreamObserver responseObserver) { - responseObserver.onError(new Exception()); - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java deleted file mode 100644 index 2f156bc62f..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { - @Override - public void sayHello(HelloRequest request, StreamObserver responseObserver) { - responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); - responseObserver.onCompleted(); - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java deleted file mode 100644 index 5235d09318..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.grpc.provider.service; - -import io.grpc.stub.StreamObserver; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; - -public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { - - private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); - - @Override - public StreamObserver sayHello(final StreamObserver responseObserver) { - StreamObserver requestStreamObserver = new StreamObserver() { - - public void onNext(HelloRequest request) { - LOGGER.info("Receive an message from client. Message: {}", request.getName()); - responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); - } - - public void onError(Throwable throwable) { - responseObserver.onError(throwable); - } - - public void onCompleted() { - LOGGER.info("End the stream."); - responseObserver.onCompleted(); - } - }; - return requestStreamObserver; - } -} diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto deleted file mode 100644 index fd5ba4a8f1..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/proto/GreetService.proto +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - * - */ -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; - -service Greeter { - rpc SayHello (stream HelloRequest) returns (stream HelloReply) { - } -} - -service GreeterBlocking { - rpc SayHello (HelloRequest) returns (HelloReply) { - } -} -service GreeterBlockingError { - rpc SayHello (HelloRequest) returns (HelloReply) { - } -} - -message HelloRequest { - string name = 1; -} - -message HelloReply { - string message = 1; -} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml deleted file mode 100644 index 1ed0f442a1..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/application.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# -server: - port: 8080 - servlet: - context-path: /grpc-1.50.x-1.70.x-scenario -logging: - config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml deleted file mode 100644 index 9849ed5a8a..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list deleted file mode 100644 index ebc1703006..0000000000 --- a/test/plugin/scenarios/grpc-1.50.x-1.70.x-scenario/support-version.list +++ /dev/null @@ -1,44 +0,0 @@ -# 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. - -# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 -# So these versions were not included in support-version.list. if you know what caused it, please help us. - -# Contains only the last version number of each minor version - -1.73.0 -1.72.0 -1.71.0 -1.70.0 -1.69.0 -1.68.0 -1.67.1 -1.66.0 -1.65.0 -1.64.0 -1.63.0 -1.62.2 -1.61.0 -1.60.0 -1.59.0 -1.58.0 -1.57.0 -1.56.0 -1.55.1 -1.54.0 -1.53.0 -1.52.0 -1.51.0 From 22b38a6449ae9d387a42d7697df79f37dfb6b6d6 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 12:49:06 +0800 Subject: [PATCH 19/28] only support grpc 1.59-1.70.x --- .../bin/startup.sh | 21 + .../config/expectedData.yaml | 458 ++++++++++++++++++ .../configuration.yml | 22 + .../grpc-1.59.x-1.70.x-scenario/pom.xml | 163 +++++++ .../src/main/assembly/assembly.xml | 41 ++ .../apm/testcase/grpc/Application.java | 34 ++ .../grpc/consumr/ConsumerInterceptor.java | 109 +++++ .../grpc/controller/CaseController.java | 137 ++++++ .../grpc/provider/ProviderConfiguration.java | 44 ++ .../interceptor/ProviderInterceptor.java | 96 ++++ .../GreeterBlockingErrorServiceImpl.java | 31 ++ .../service/GreeterBlockingServiceImpl.java | 32 ++ .../provider/service/GreeterServiceImpl.java | 52 ++ .../src/main/proto/GreetService.proto | 43 ++ .../src/main/resources/application.yaml | 23 + .../src/main/resources/log4j2.xml | 30 ++ .../support-version.list | 35 ++ 17 files changed, 1371 insertions(+) create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/proto/GreetService.proto create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/support-version.list diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..54d5003fe6 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/grpc-1.59.x-1.70.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..2cbf91a2ea --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/config/expectedData.yaml @@ -0,0 +1,458 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: grpc-1.59.x-1.70.x-scenario + segmentSize: gt 10 + segments: + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onComplete + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.Exception} + - {key: message, value: ''} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.59.x-1.70.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Request/onComplete + parentSpanId: 2 + spanId: 3 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Response/onClose + parentSpanId: 2 + spanId: 4 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello + parentSpanId: 0 + panId: 2 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onComplete + parentSpanId: 5 + spanId: 6 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Response/onClose + parentSpanId: 5 + spanId: 7 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onCancel + parentSpanId: 5 + spanId: 8 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello + parentSpanId: 0 + spanId: 5 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Exit + peer: 127.0.0.1:18080 + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GET:/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: true + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: org.springframework.web.util.NestedServletException} + - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: + UNKNOWN'} + - {key: stack, value: not null} + - logEvent: + - {key: forward-url, value: /grpc-1.59.x-1.70.x-scenario/error} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/configuration.yml new file mode 100644 index 0000000000..858c323d01 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/configuration.yml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/grpc-1.59.x-1.70.x-scenario/case/grpc-1.59.x-1.70.x-scenario +healthCheck: http://localhost:8080/grpc-1.59.x-1.70.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/pom.xml new file mode 100644 index 0000000000..0794a1cb21 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/pom.xml @@ -0,0 +1,163 @@ + + + + + org.apache.skywalking.apm.testcase + grpc-1.59.x-1.70.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 1.6.2 + + 1.59.0 + + 2.1.6.RELEASE + + + skywalking-grpc-1.59.x-1.70.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + io.grpc + grpc-all + ${test.framework.version} + + + + + + grpc-1.59.x-1.70.x-scenario + + + kr.motd.maven + os-maven-plugin + ${os-maven-plugin.version} + + + initialize + + detect + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + com.google.protobuf:protoc:3.23.4:exe:${os.detected.classifier} + + grpc-java + io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:${os.detected.classifier} + + + + + + compile + compile-custom + + + + + + + diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..11d5b1f62c --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/grpc-1.59.x-1.70.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java new file mode 100644 index 0000000000..052e0f7e3b --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java new file mode 100644 index 0000000000..e8a35d0359 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java @@ -0,0 +1,109 @@ +/* + * 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.grpc.consumr; + +import io.grpc.CallOptions; +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.ClientInterceptor; +import io.grpc.ForwardingClientCall; +import io.grpc.ForwardingClientCallListener; +import io.grpc.Metadata; +import io.grpc.MethodDescriptor; +import io.grpc.Status; +import javax.annotation.Nullable; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ConsumerInterceptor implements ClientInterceptor { + + private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); + + @Override + public ClientCall interceptCall(MethodDescriptor descriptor, + CallOptions options, Channel channel) { + LOGGER.info("start interceptor!"); + LOGGER.info("method type: {}", descriptor.getType()); + return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { + @Override + public void start(Listener responseListener, Metadata headers) { + LOGGER.info("Peer: {}", channel.authority()); + LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); + Interceptor tracingResponseListener = new Interceptor(responseListener); + tracingResponseListener.contextSnapshot = "contextSnapshot"; + delegate().start(tracingResponseListener, headers); + } + + @Override + public void cancel(@Nullable String message, @Nullable Throwable cause) { + LOGGER.info("cancel"); + super.cancel(message, cause); + } + + @Override + public void halfClose() { + LOGGER.info("halfClose"); + super.halfClose(); + } + + @Override + public void sendMessage(REQ_T message) { + LOGGER.info("sendMessage ...."); + super.sendMessage(message); + } + }; + } + + private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { + private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); + + private Object contextSnapshot; + + protected Interceptor(ClientCall.Listener delegate) { + super(delegate); + } + + @Override + public void onHeaders(Metadata headers) { + LOGGER.info("on Headers"); + for (String key : headers.keys()) { + LOGGER.info("Receive key: {}", key); + } + delegate().onHeaders(headers); + } + + @Override + public void onMessage(RESP_T message) { + LOGGER.info("contextSnapshot: {}", contextSnapshot); + delegate().onMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + LOGGER.info("on close"); + delegate().onClose(status, trailers); + } + + @Override + public void onReady() { + LOGGER.info("on Ready"); + super.onReady(); + } + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java new file mode 100644 index 0000000000..2a26b99e96 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -0,0 +1,137 @@ +/* + * 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.grpc.controller; + +import io.grpc.ClientInterceptors; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.stub.ClientCallStreamObserver; +import io.grpc.stub.ClientResponseObserver; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import javax.annotation.PostConstruct; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + private final String grpcProviderHost = "127.0.0.1"; + private final int grpcProviderPort = 18080; + private ManagedChannel channel; + private GreeterGrpc.GreeterStub greeterStub; + private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; + private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; + + @PostConstruct + public void up() { + channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); + greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + } + + @RequestMapping("/grpc-1.59.x-1.70.x-scenario") + @ResponseBody + public String testcase() { + greetService(); + greetBlockingService(); + greetBlockingErrorService(); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + + private static List names() { + return Arrays.asList("Sophia", "Jackson"); + } + + private void greetService() { + ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { + private ClientCallStreamObserver requestStream; + + @Override + public void beforeStart(ClientCallStreamObserver observer) { + this.requestStream = observer; + this.requestStream.setOnReadyHandler(new Runnable() { + Iterator iterator = names().iterator(); + + @Override + public void run() { + while (requestStream.isReady()) { + if (iterator.hasNext()) { + String name = iterator.next(); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + requestStream.onNext(request); + } else { + requestStream.onCompleted(); + } + } + } + }); + } + + @Override + public void onNext(HelloReply reply) { + LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); + requestStream.request(1); + } + + public void onError(Throwable throwable) { + LOGGER.error("Failed to send data", throwable); + } + + public void onCompleted() { + LOGGER.info("All Done"); + } + }; + + greeterStub.sayHello(helloReplyStreamObserver); + } + + private void greetBlockingService() { + HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); + greeterBlockingStub.sayHello(request); + } + + private void greetBlockingErrorService() { + HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); + greeterBlockingErrorStub.sayHello(request); + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java new file mode 100644 index 0000000000..8541c403b1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java @@ -0,0 +1,44 @@ +/* + * 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.grpc.provider; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import io.grpc.ServerInterceptors; +import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Configurable +@Component +public class ProviderConfiguration { + + @Bean(initMethod = "start", destroyMethod = "shutdown") + public Server server() { + return ServerBuilder.forPort(18080) + .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) + .build(); + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java new file mode 100644 index 0000000000..26647b41a8 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java @@ -0,0 +1,96 @@ +/* + * 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.grpc.provider.interceptor; + +import io.grpc.ForwardingServerCall; +import io.grpc.ForwardingServerCallListener; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ProviderInterceptor implements ServerInterceptor { + private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); + + @Override + public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, + ServerCallHandler handler) { + Map headerMap = new HashMap(); + for (String key : metadata.keys()) { + LOGGER.info("Receive key: {}", key); + if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { + String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); + + headerMap.put(key, value); + } + } + LOGGER.info("authority : {}", call.getAuthority()); + return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { + @Override + public void sendHeaders(Metadata responseHeaders) { + LOGGER.info("sendHeaders...."); + Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); + responseHeaders.put(headerKey, "test-server"); + delegate().sendHeaders(responseHeaders); + } + + @Override + public void sendMessage(RESQ_T message) { + delegate().sendMessage(message); + } + + }, metadata)) { + @Override + public void onReady() { + LOGGER.info("onReady...."); + delegate().onReady(); + } + + @Override + public void onCancel() { + LOGGER.info("onCancel...."); + delegate().onCancel(); + } + + @Override + public void onComplete() { + LOGGER.info("onComplete...."); + delegate().onComplete(); + } + + @Override + public void onHalfClose() { + LOGGER.info("onHalfClose...."); + delegate().onHalfClose(); + } + + @Override + public void onMessage(REQ_T message) { + LOGGER.info("onMessage...."); + delegate().onMessage(message); + } + }; + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java new file mode 100644 index 0000000000..3cd6394a48 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onError(new Exception()); + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java new file mode 100644 index 0000000000..2f156bc62f --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.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.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + responseObserver.onCompleted(); + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java new file mode 100644 index 0000000000..5235d09318 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { + + private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); + + @Override + public StreamObserver sayHello(final StreamObserver responseObserver) { + StreamObserver requestStreamObserver = new StreamObserver() { + + public void onNext(HelloRequest request) { + LOGGER.info("Receive an message from client. Message: {}", request.getName()); + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + } + + public void onError(Throwable throwable) { + responseObserver.onError(throwable); + } + + public void onCompleted() { + LOGGER.info("End the stream."); + responseObserver.onCompleted(); + } + }; + return requestStreamObserver; + } +} diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/proto/GreetService.proto new file mode 100644 index 0000000000..fd5ba4a8f1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/proto/GreetService.proto @@ -0,0 +1,43 @@ +/* + * 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. + * + */ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; + +service Greeter { + rpc SayHello (stream HelloRequest) returns (stream HelloReply) { + } +} + +service GreeterBlocking { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} +service GreeterBlockingError { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..37d6d01659 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +server: + port: 8080 + servlet: + context-path: /grpc-1.59.x-1.70.x-scenario +logging: + config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/support-version.list new file mode 100644 index 0000000000..dd10211b8e --- /dev/null +++ b/test/plugin/scenarios/grpc-1.59.x-1.70.x-scenario/support-version.list @@ -0,0 +1,35 @@ +# 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. + +# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 +# So these versions were not included in support-version.list. if you know what caused it, please help us. + +# Contains only the last version number of each minor version + +1.73.0 +1.72.0 +1.71.0 +1.70.0 +1.69.0 +1.68.0 +1.67.1 +1.66.0 +1.65.0 +1.64.0 +1.63.0 +1.62.2 +1.61.0 +1.60.0 From 3e9fd79571f2ba5dfa56d3c4d54a608f0eb37ae6 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 14:36:37 +0800 Subject: [PATCH 20/28] Add grpc 1.26.0->1.58.0 test case support usePlaintext differential calling --- .../grpc/controller/CaseController.java | 16 ++++++++- .../grpc-scenario/support-version.list | 34 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index 398dbd3853..eb514e24cf 100644 --- a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -23,6 +23,8 @@ import io.grpc.ManagedChannelBuilder; import io.grpc.stub.ClientCallStreamObserver; import io.grpc.stub.ClientResponseObserver; + +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -35,6 +37,8 @@ import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.springframework.cglib.core.ReflectUtils; +import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -56,7 +60,17 @@ public class CaseController { @PostConstruct public void up() { - channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext(true).build(); + ManagedChannelBuilder managedChannelBuilder = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort); + Method usePlaintext = ReflectionUtils.findMethod(managedChannelBuilder.getClass(), "usePlaintext"); + if (usePlaintext != null) { + int paramCount = usePlaintext.getParameterCount(); + if (paramCount == 0) {// no parame method usePlaintext() + ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder); + } else if (paramCount == 1 && usePlaintext.getParameterTypes()[0] == boolean.class) {// boolean method usePlaintext(true) + ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder, true); + } + } + channel = managedChannelBuilder.build(); greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); diff --git a/test/plugin/scenarios/grpc-scenario/support-version.list b/test/plugin/scenarios/grpc-scenario/support-version.list index 824c5bdfea..a7d10e35d4 100644 --- a/test/plugin/scenarios/grpc-scenario/support-version.list +++ b/test/plugin/scenarios/grpc-scenario/support-version.list @@ -19,6 +19,40 @@ # Contains only the last version number of each minor version +1.58.0 +1.57.0 +1.57.0 +1.56.0 +1.55.1 +1.54.0 +1.53.0 +1.52.0 +1.51.0 +1.50.0 +1.49.0 +1.48.0 +1.47.0 +1.46.0 +1.45.0 +1.44.0 +1.43.0 +1.42.0 +1.41.0 +1.40.0 +1.39.0 +1.38.0 +1.37.0 +1.36.0 +1.35.0 +1.34.0 +1.33.0 +1.32.1 +1.31.0 +1.30.0 +1.29.0 +1.28.0 +1.27.0 +1.26.0 1.25.0 1.24.2 1.23.1 From 797d850ee8911b37d580245ccfdfe415458b2893 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 14:46:08 +0800 Subject: [PATCH 21/28] fix code style --- .../skywalking/apm/testcase/grpc/controller/CaseController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index eb514e24cf..1902a6accc 100644 --- a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -37,7 +37,6 @@ import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.springframework.cglib.core.ReflectUtils; import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; From d0ed0a7c9a37941eb7040d288317722d377f0991 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 14:56:07 +0800 Subject: [PATCH 22/28] fix code style 2 --- .../apm/testcase/grpc/controller/CaseController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index 1902a6accc..1513bea233 100644 --- a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -63,9 +63,11 @@ public void up() { Method usePlaintext = ReflectionUtils.findMethod(managedChannelBuilder.getClass(), "usePlaintext"); if (usePlaintext != null) { int paramCount = usePlaintext.getParameterCount(); - if (paramCount == 0) {// no parame method usePlaintext() + if (paramCount == 0) { + // no parame method usePlaintext() ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder); - } else if (paramCount == 1 && usePlaintext.getParameterTypes()[0] == boolean.class) {// boolean method usePlaintext(true) + } else if (paramCount == 1 && usePlaintext.getParameterTypes()[0] == boolean.class) { + // boolean method usePlaintext(true) ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder, true); } } From 5dd664ebce2569e291f59b08edfc35ada6633a39 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 15:49:39 +0800 Subject: [PATCH 23/28] reset old grpc case --- .../grpc/controller/CaseController.java | 17 +--------- .../grpc-scenario/support-version.list | 34 ------------------- 2 files changed, 1 insertion(+), 50 deletions(-) diff --git a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index 1513bea233..398dbd3853 100644 --- a/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -23,8 +23,6 @@ import io.grpc.ManagedChannelBuilder; import io.grpc.stub.ClientCallStreamObserver; import io.grpc.stub.ClientResponseObserver; - -import java.lang.reflect.Method; import java.util.Arrays; import java.util.Iterator; import java.util.List; @@ -37,7 +35,6 @@ import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; -import org.springframework.util.ReflectionUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; @@ -59,19 +56,7 @@ public class CaseController { @PostConstruct public void up() { - ManagedChannelBuilder managedChannelBuilder = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort); - Method usePlaintext = ReflectionUtils.findMethod(managedChannelBuilder.getClass(), "usePlaintext"); - if (usePlaintext != null) { - int paramCount = usePlaintext.getParameterCount(); - if (paramCount == 0) { - // no parame method usePlaintext() - ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder); - } else if (paramCount == 1 && usePlaintext.getParameterTypes()[0] == boolean.class) { - // boolean method usePlaintext(true) - ReflectionUtils.invokeMethod(usePlaintext, managedChannelBuilder, true); - } - } - channel = managedChannelBuilder.build(); + channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext(true).build(); greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); diff --git a/test/plugin/scenarios/grpc-scenario/support-version.list b/test/plugin/scenarios/grpc-scenario/support-version.list index a7d10e35d4..824c5bdfea 100644 --- a/test/plugin/scenarios/grpc-scenario/support-version.list +++ b/test/plugin/scenarios/grpc-scenario/support-version.list @@ -19,40 +19,6 @@ # Contains only the last version number of each minor version -1.58.0 -1.57.0 -1.57.0 -1.56.0 -1.55.1 -1.54.0 -1.53.0 -1.52.0 -1.51.0 -1.50.0 -1.49.0 -1.48.0 -1.47.0 -1.46.0 -1.45.0 -1.44.0 -1.43.0 -1.42.0 -1.41.0 -1.40.0 -1.39.0 -1.38.0 -1.37.0 -1.36.0 -1.35.0 -1.34.0 -1.33.0 -1.32.1 -1.31.0 -1.30.0 -1.29.0 -1.28.0 -1.27.0 -1.26.0 1.25.0 1.24.2 1.23.1 From a6b609fdee1980cf1c6d896045f38b142e3bf2f4 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 15:50:35 +0800 Subject: [PATCH 24/28] Add grpc 1.30.0 -> 1.58.0 --- .github/workflows/plugins-test.0.yaml | 1 + .../bin/startup.sh | 21 + .../config/expectedData.yaml | 458 ++++++++++++++++++ .../configuration.yml | 22 + .../grpc-1.30.x-1.58.x-scenario/pom.xml | 170 +++++++ .../src/main/assembly/assembly.xml | 41 ++ .../apm/testcase/grpc/Application.java | 34 ++ .../grpc/consumr/ConsumerInterceptor.java | 109 +++++ .../grpc/controller/CaseController.java | 137 ++++++ .../grpc/provider/ProviderConfiguration.java | 44 ++ .../interceptor/ProviderInterceptor.java | 96 ++++ .../GreeterBlockingErrorServiceImpl.java | 31 ++ .../service/GreeterBlockingServiceImpl.java | 32 ++ .../provider/service/GreeterServiceImpl.java | 52 ++ .../src/main/proto/GreetService.proto | 43 ++ .../src/main/resources/application.yaml | 23 + .../src/main/resources/log4j2.xml | 30 ++ .../support-version.list | 51 ++ 18 files changed, 1395 insertions(+) create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml create mode 100644 test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index c5fc3b0b27..155de4edd2 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -81,6 +81,7 @@ jobs: - gateway-2.0.x-scenario - grpc-scenario - grpc-1.59.x-1.70.x-scenario + - grpc-1.30.x-1.58.x-scenario - gson-scenario - guava-cache-scenario - elasticjob-3.x-scenario diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..2eb9f5ed0b --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +home="$(cd "$(dirname $0)"; pwd)" + +java -jar ${agent_opts} ${home}/../libs/grpc-1.30.x-1.58.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..30f0a13037 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml @@ -0,0 +1,458 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +segmentItems: + - serviceName: grpc-1.30.x-1.58.x-scenario + segmentSize: gt 10 + segments: + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Request/onComplete + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: not null, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlocking.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onMessage + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: OK} + skipAnalysis: 'false' + - operationName: Greeter.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onMessage + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello/client/Response/onClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Entry + peer: '' + refs: + - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: GreeterBlockingError.sayHello/server/Response/onClose + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: java.lang.Exception} + - {key: message, value: ''} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/server/Request/onHalfClose + parentSpanId: -1 + spanId: 0 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + refs: + - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, + parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: Greeter.sayHello + parentSpanId: 0 + spanId: 1 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Request/onComplete + parentSpanId: 2 + spanId: 3 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello/client/Response/onClose + parentSpanId: 2 + spanId: 4 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlocking.sayHello + parentSpanId: 0 + panId: 2 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onComplete + parentSpanId: 5 + spanId: 6 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: false + spanType: Local + peer: '' + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Response/onClose + parentSpanId: 5 + spanId: 7 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + tags: + - {key: rpc.status_code, value: UNKNOWN} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello/client/Request/onCancel + parentSpanId: 5 + spanId: 8 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Local + peer: '' + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GreeterBlockingError.sayHello + parentSpanId: 0 + spanId: 5 + spanLayer: RPCFramework + startTime: nq 0 + endTime: nq 0 + componentId: 23 + isError: true + spanType: Exit + peer: 127.0.0.1:18080 + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: io.grpc.StatusRuntimeException} + - {key: message, value: UNKNOWN} + - {key: stack, value: not null} + skipAnalysis: 'false' + - operationName: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: true + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '500'} + logs: + - logEvent: + - {key: event, value: error} + - {key: error.kind, value: org.springframework.web.util.NestedServletException} + - {key: message, value: 'Request processing failed; nested exception is io.grpc.StatusRuntimeException: + UNKNOWN'} + - {key: stack, value: not null} + - logEvent: + - {key: forward-url, value: /grpc-1.30.x-1.58.x-scenario/error} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml new file mode 100644 index 0000000000..f9ce9575d7 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario +healthCheck: http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml new file mode 100644 index 0000000000..f860c1f59a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml @@ -0,0 +1,170 @@ + + + + + org.apache.skywalking.apm.testcase + grpc-1.30.x-1.58.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + 1.6.2 + + 1.58.0 + + 2.1.6.RELEASE + + + skywalking-grpc-1.30.x-1.58.x-scenario + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + + + io.grpc + grpc-all + ${test.framework.version} + + + io.grpc + grpc-rls + + + + + + + + + grpc-1.30.x-1.58.x-scenario + + + kr.motd.maven + os-maven-plugin + ${os-maven-plugin.version} + + + initialize + + detect + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.6.1 + + + com.google.protobuf:protoc:3.11.4:exe:osx-x86_64 + + grpc-java + io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:osx-x86_64 + + + + + + compile + compile-custom + + + + + + + diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..589cea7469 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/grpc-1.30.x-1.58.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java new file mode 100644 index 0000000000..052e0f7e3b --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + try { + SpringApplication.run(Application.class, args); + } catch (Exception e) { + // Never do this + } + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java new file mode 100644 index 0000000000..e8a35d0359 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java @@ -0,0 +1,109 @@ +/* + * 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.grpc.consumr; + +import io.grpc.CallOptions; +import io.grpc.Channel; +import io.grpc.ClientCall; +import io.grpc.ClientInterceptor; +import io.grpc.ForwardingClientCall; +import io.grpc.ForwardingClientCallListener; +import io.grpc.Metadata; +import io.grpc.MethodDescriptor; +import io.grpc.Status; +import javax.annotation.Nullable; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ConsumerInterceptor implements ClientInterceptor { + + private static final Logger LOGGER = LogManager.getLogger(ConsumerInterceptor.class); + + @Override + public ClientCall interceptCall(MethodDescriptor descriptor, + CallOptions options, Channel channel) { + LOGGER.info("start interceptor!"); + LOGGER.info("method type: {}", descriptor.getType()); + return new ForwardingClientCall.SimpleForwardingClientCall(channel.newCall(descriptor, options)) { + @Override + public void start(Listener responseListener, Metadata headers) { + LOGGER.info("Peer: {}", channel.authority()); + LOGGER.info("Operation Name : {}", descriptor.getFullMethodName()); + Interceptor tracingResponseListener = new Interceptor(responseListener); + tracingResponseListener.contextSnapshot = "contextSnapshot"; + delegate().start(tracingResponseListener, headers); + } + + @Override + public void cancel(@Nullable String message, @Nullable Throwable cause) { + LOGGER.info("cancel"); + super.cancel(message, cause); + } + + @Override + public void halfClose() { + LOGGER.info("halfClose"); + super.halfClose(); + } + + @Override + public void sendMessage(REQ_T message) { + LOGGER.info("sendMessage ...."); + super.sendMessage(message); + } + }; + } + + private static class Interceptor extends ForwardingClientCallListener.SimpleForwardingClientCallListener { + private static final Logger LOGGER = LogManager.getLogger(Interceptor.class); + + private Object contextSnapshot; + + protected Interceptor(ClientCall.Listener delegate) { + super(delegate); + } + + @Override + public void onHeaders(Metadata headers) { + LOGGER.info("on Headers"); + for (String key : headers.keys()) { + LOGGER.info("Receive key: {}", key); + } + delegate().onHeaders(headers); + } + + @Override + public void onMessage(RESP_T message) { + LOGGER.info("contextSnapshot: {}", contextSnapshot); + delegate().onMessage(message); + } + + @Override + public void onClose(Status status, Metadata trailers) { + LOGGER.info("on close"); + delegate().onClose(status, trailers); + } + + @Override + public void onReady() { + LOGGER.info("on Ready"); + super.onReady(); + } + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java new file mode 100644 index 0000000000..b16a447808 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -0,0 +1,137 @@ +/* + * 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.grpc.controller; + +import io.grpc.ClientInterceptors; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import io.grpc.stub.ClientCallStreamObserver; +import io.grpc.stub.ClientResponseObserver; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import javax.annotation.PostConstruct; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.consumr.ConsumerInterceptor; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String SUCCESS = "Success"; + + private final String grpcProviderHost = "127.0.0.1"; + private final int grpcProviderPort = 18080; + private ManagedChannel channel; + private GreeterGrpc.GreeterStub greeterStub; + private GreeterBlockingGrpc.GreeterBlockingBlockingStub greeterBlockingStub; + private GreeterBlockingErrorGrpc.GreeterBlockingErrorBlockingStub greeterBlockingErrorStub; + + @PostConstruct + public void up() { + channel = ManagedChannelBuilder.forAddress(grpcProviderHost, grpcProviderPort).usePlaintext().build(); + greeterStub = GreeterGrpc.newStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingStub = GreeterBlockingGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); + } + + @RequestMapping("/grpc-1.30.x-1.58.x-scenario") + @ResponseBody + public String testcase() { + greetService(); + greetBlockingService(); + greetBlockingErrorService(); + return SUCCESS; + } + + @RequestMapping("/healthCheck") + @ResponseBody + public String healthCheck() { + // your codes + return SUCCESS; + } + + private static List names() { + return Arrays.asList("Sophia", "Jackson"); + } + + private void greetService() { + ClientResponseObserver helloReplyStreamObserver = new ClientResponseObserver() { + private ClientCallStreamObserver requestStream; + + @Override + public void beforeStart(ClientCallStreamObserver observer) { + this.requestStream = observer; + this.requestStream.setOnReadyHandler(new Runnable() { + Iterator iterator = names().iterator(); + + @Override + public void run() { + while (requestStream.isReady()) { + if (iterator.hasNext()) { + String name = iterator.next(); + HelloRequest request = HelloRequest.newBuilder().setName(name).build(); + requestStream.onNext(request); + } else { + requestStream.onCompleted(); + } + } + } + }); + } + + @Override + public void onNext(HelloReply reply) { + LOGGER.info("Receive an message from provider. message: {}", reply.getMessage()); + requestStream.request(1); + } + + public void onError(Throwable throwable) { + LOGGER.error("Failed to send data", throwable); + } + + public void onCompleted() { + LOGGER.info("All Done"); + } + }; + + greeterStub.sayHello(helloReplyStreamObserver); + } + + private void greetBlockingService() { + HelloRequest request = HelloRequest.newBuilder().setName("Sophia").build(); + greeterBlockingStub.sayHello(request); + } + + private void greetBlockingErrorService() { + HelloRequest request = HelloRequest.newBuilder().setName("Tony").build(); + greeterBlockingErrorStub.sayHello(request); + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java new file mode 100644 index 0000000000..8541c403b1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java @@ -0,0 +1,44 @@ +/* + * 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.grpc.provider; + +import io.grpc.Server; +import io.grpc.ServerBuilder; +import io.grpc.ServerInterceptors; +import org.apache.skywalking.apm.testcase.grpc.provider.interceptor.ProviderInterceptor; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingErrorServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterBlockingServiceImpl; +import org.apache.skywalking.apm.testcase.grpc.provider.service.GreeterServiceImpl; +import org.springframework.beans.factory.annotation.Configurable; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Configurable +@Component +public class ProviderConfiguration { + + @Bean(initMethod = "start", destroyMethod = "shutdown") + public Server server() { + return ServerBuilder.forPort(18080) + .addService(ServerInterceptors.intercept(new GreeterServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingServiceImpl(), new ProviderInterceptor())) + .addService(ServerInterceptors.intercept(new GreeterBlockingErrorServiceImpl(), new ProviderInterceptor())) + .build(); + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java new file mode 100644 index 0000000000..26647b41a8 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java @@ -0,0 +1,96 @@ +/* + * 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.grpc.provider.interceptor; + +import io.grpc.ForwardingServerCall; +import io.grpc.ForwardingServerCallListener; +import io.grpc.Metadata; +import io.grpc.ServerCall; +import io.grpc.ServerCallHandler; +import io.grpc.ServerInterceptor; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class ProviderInterceptor implements ServerInterceptor { + private static final Logger LOGGER = LogManager.getLogger(ProviderInterceptor.class); + + @Override + public ServerCall.Listener interceptCall(ServerCall call, Metadata metadata, + ServerCallHandler handler) { + Map headerMap = new HashMap(); + for (String key : metadata.keys()) { + LOGGER.info("Receive key: {}", key); + if (!key.endsWith(Metadata.BINARY_HEADER_SUFFIX)) { + String value = metadata.get(Metadata.Key.of(key, Metadata.ASCII_STRING_MARSHALLER)); + + headerMap.put(key, value); + } + } + LOGGER.info("authority : {}", call.getAuthority()); + return new ForwardingServerCallListener.SimpleForwardingServerCallListener(handler.startCall(new ForwardingServerCall.SimpleForwardingServerCall(call) { + @Override + public void sendHeaders(Metadata responseHeaders) { + LOGGER.info("sendHeaders...."); + Metadata.Key headerKey = Metadata.Key.of("test-server", Metadata.ASCII_STRING_MARSHALLER); + responseHeaders.put(headerKey, "test-server"); + delegate().sendHeaders(responseHeaders); + } + + @Override + public void sendMessage(RESQ_T message) { + delegate().sendMessage(message); + } + + }, metadata)) { + @Override + public void onReady() { + LOGGER.info("onReady...."); + delegate().onReady(); + } + + @Override + public void onCancel() { + LOGGER.info("onCancel...."); + delegate().onCancel(); + } + + @Override + public void onComplete() { + LOGGER.info("onComplete...."); + delegate().onComplete(); + } + + @Override + public void onHalfClose() { + LOGGER.info("onHalfClose...."); + delegate().onHalfClose(); + } + + @Override + public void onMessage(REQ_T message) { + LOGGER.info("onMessage...."); + delegate().onMessage(message); + } + }; + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java new file mode 100644 index 0000000000..3cd6394a48 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingErrorGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingErrorServiceImpl extends GreeterBlockingErrorGrpc.GreeterBlockingErrorImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onError(new Exception()); + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java new file mode 100644 index 0000000000..2f156bc62f --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.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.testcase.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterBlockingGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterBlockingServiceImpl extends GreeterBlockingGrpc.GreeterBlockingImplBase { + @Override + public void sayHello(HelloRequest request, StreamObserver responseObserver) { + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + responseObserver.onCompleted(); + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java new file mode 100644 index 0000000000..5235d09318 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java @@ -0,0 +1,52 @@ +/* + * 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.grpc.provider.service; + +import io.grpc.stub.StreamObserver; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.skywalking.apm.testcase.grpc.proto.GreeterGrpc; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloReply; +import org.apache.skywalking.apm.testcase.grpc.proto.HelloRequest; + +public class GreeterServiceImpl extends GreeterGrpc.GreeterImplBase { + + private static final Logger LOGGER = LogManager.getLogger(GreeterServiceImpl.class); + + @Override + public StreamObserver sayHello(final StreamObserver responseObserver) { + StreamObserver requestStreamObserver = new StreamObserver() { + + public void onNext(HelloRequest request) { + LOGGER.info("Receive an message from client. Message: {}", request.getName()); + responseObserver.onNext(HelloReply.newBuilder().setMessage("Hi," + request.getName()).build()); + } + + public void onError(Throwable throwable) { + responseObserver.onError(throwable); + } + + public void onCompleted() { + LOGGER.info("End the stream."); + responseObserver.onCompleted(); + } + }; + return requestStreamObserver; + } +} diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto new file mode 100644 index 0000000000..fd5ba4a8f1 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto @@ -0,0 +1,43 @@ +/* + * 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. + * + */ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "org.apache.skywalking.apm.testcase.grpc.proto"; + +service Greeter { + rpc SayHello (stream HelloRequest) returns (stream HelloReply) { + } +} + +service GreeterBlocking { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} +service GreeterBlockingError { + rpc SayHello (HelloRequest) returns (HelloReply) { + } +} + +message HelloRequest { + string name = 1; +} + +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml new file mode 100644 index 0000000000..e9f089335a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# +server: + port: 8080 + servlet: + context-path: /grpc-1.30.x-1.58.x-scenario +logging: + config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list new file mode 100644 index 0000000000..e6e3bad377 --- /dev/null +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# INTERNAL: HTTP/2 error code: INTERNAL_ERROR Received Goaway occur in test cases 1.0.0 to 1.5.0 +# So these versions were not included in support-version.list. if you know what caused it, please help us. + +# Contains only the last version number of each minor version + +1.58.0 +1.57.0 +1.57.0 +1.56.0 +1.55.1 +1.54.0 +1.53.0 +1.52.0 +1.51.0 +1.50.0 +1.49.0 +1.48.0 +1.47.0 +1.46.0 +1.45.0 +1.44.0 +1.43.0 +1.42.0 +1.41.0 +1.40.0 +1.39.0 +1.38.0 +1.37.0 +1.36.0 +1.35.0 +1.34.0 +1.33.0 +1.32.1 +1.31.0 +1.30.0 From 13fa3d4ea42b60efbe4d6e5466f98e18c5f6e3c1 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 16:05:16 +0800 Subject: [PATCH 25/28] Add grpc 1.30.0 -> 1.58.0 --- test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml index f860c1f59a..2de633b56c 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml @@ -150,10 +150,10 @@ protobuf-java directly, you will be transitively depending on the protobuf-java version that grpc depends on. --> - com.google.protobuf:protoc:3.11.4:exe:osx-x86_64 + com.google.protobuf:protoc:3.11.4:exe:${os.detected.classifier} grpc-java - io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:osx-x86_64 + io.grpc:protoc-gen-grpc-java:${test.framework.version}:exe:${os.detected.classifier} From 0b3f5a00e0024484174feea45378a12a71a69ae3 Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 17:03:54 +0800 Subject: [PATCH 26/28] Add grpc 1.30.0 -> 1.39.0 --- .../bin/startup.sh | 2 +- .../config/expectedData.yaml | 48 +++++++++---------- .../configuration.yml | 4 +- .../grpc-1.30.x-1.58.x-scenario/pom.xml | 8 ++-- .../src/main/assembly/assembly.xml | 2 +- .../grpc/controller/CaseController.java | 2 +- .../src/main/resources/application.yaml | 2 +- .../support-version.list | 20 -------- 8 files changed, 34 insertions(+), 54 deletions(-) diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh index 2eb9f5ed0b..aeac2a7b77 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh @@ -18,4 +18,4 @@ home="$(cd "$(dirname $0)"; pwd)" -java -jar ${agent_opts} ${home}/../libs/grpc-1.30.x-1.58.x-scenario.jar & +java -jar ${agent_opts} ${home}/../libs/grpc-1.30.x-1.39.x-scenario.jar & diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml index 30f0a13037..b4551acf3e 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. segmentItems: - - serviceName: grpc-1.30.x-1.58.x-scenario + - serviceName: grpc-1.30.x-1.39.x-scenario segmentSize: gt 10 segments: - segmentId: not null @@ -30,9 +30,9 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 2, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -47,7 +47,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null} skipAnalysis: 'false' @@ -64,9 +64,9 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -81,9 +81,9 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -98,9 +98,9 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -143,7 +143,7 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null} skipAnalysis: 'false' @@ -175,7 +175,7 @@ segmentItems: refs: - {parentEndpoint: GreeterBlocking.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -203,7 +203,7 @@ segmentItems: refs: - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -233,7 +233,7 @@ segmentItems: refs: - {parentEndpoint: Greeter.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -248,9 +248,9 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -265,9 +265,9 @@ segmentItems: spanType: Local peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '', refType: CrossThread, + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '', refType: CrossThread, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -282,9 +282,9 @@ segmentItems: spanType: Entry peer: '' refs: - - {parentEndpoint: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario, networkAddress: '127.0.0.1:18080', + - {parentEndpoint: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario, networkAddress: '127.0.0.1:18080', refType: CrossProcess, parentSpanId: 5, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -320,7 +320,7 @@ segmentItems: refs: - {parentEndpoint: GreeterBlockingError.sayHello, networkAddress: '', refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not - null, parentService: grpc-1.30.x-1.58.x-scenario, traceId: not null} + null, parentService: grpc-1.30.x-1.39.x-scenario, traceId: not null} skipAnalysis: 'false' - segmentId: not null spans: @@ -432,7 +432,7 @@ segmentItems: - {key: message, value: UNKNOWN} - {key: stack, value: not null} skipAnalysis: 'false' - - operationName: GET:/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario + - operationName: GET:/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario parentSpanId: -1 spanId: 0 spanLayer: Http @@ -443,7 +443,7 @@ segmentItems: spanType: Entry peer: '' tags: - - {key: url, value: 'http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario'} + - {key: url, value: 'http://localhost:8080/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario'} - {key: http.method, value: GET} - {key: http.status_code, value: '500'} logs: @@ -454,5 +454,5 @@ segmentItems: UNKNOWN'} - {key: stack, value: not null} - logEvent: - - {key: forward-url, value: /grpc-1.30.x-1.58.x-scenario/error} + - {key: forward-url, value: /grpc-1.30.x-1.39.x-scenario/error} skipAnalysis: 'false' diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml index f9ce9575d7..932097e647 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml @@ -15,8 +15,8 @@ # limitations under the License. type: jvm -entryService: http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/grpc-1.30.x-1.58.x-scenario -healthCheck: http://localhost:8080/grpc-1.30.x-1.58.x-scenario/case/healthCheck +entryService: http://localhost:8080/grpc-1.30.x-1.39.x-scenario/case/grpc-1.30.x-1.39.x-scenario +healthCheck: http://localhost:8080/grpc-1.30.x-1.39.x-scenario/case/healthCheck startScript: ./bin/startup.sh environment: dependencies: diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml index 2de633b56c..de23b46190 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml @@ -21,7 +21,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> org.apache.skywalking.apm.testcase - grpc-1.30.x-1.58.x-scenario + grpc-1.30.x-1.39.x-scenario 1.0.0 jar @@ -33,12 +33,12 @@ 3.8.1 1.6.2 - 1.58.0 + 1.39.0 2.1.6.RELEASE - skywalking-grpc-1.30.x-1.58.x-scenario + skywalking-grpc-1.30.x-1.39.x-scenario @@ -85,7 +85,7 @@ - grpc-1.30.x-1.58.x-scenario + grpc-1.30.x-1.39.x-scenario kr.motd.maven diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml index 589cea7469..9ba3b28c36 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml @@ -33,7 +33,7 @@ - ${project.build.directory}/grpc-1.30.x-1.58.x-scenario.jar + ${project.build.directory}/grpc-1.30.x-1.39.x-scenario.jar ./libs 0775 diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java index b16a447808..c97804e90b 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java @@ -62,7 +62,7 @@ public void up() { greeterBlockingErrorStub = GreeterBlockingErrorGrpc.newBlockingStub(ClientInterceptors.intercept(channel, new ConsumerInterceptor())); } - @RequestMapping("/grpc-1.30.x-1.58.x-scenario") + @RequestMapping("/grpc-1.30.x-1.39.x-scenario") @ResponseBody public String testcase() { greetService(); diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml index e9f089335a..5f9c909a1b 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml @@ -18,6 +18,6 @@ server: port: 8080 servlet: - context-path: /grpc-1.30.x-1.58.x-scenario + context-path: /grpc-1.30.x-1.39.x-scenario logging: config: classpath:log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list index e6e3bad377..5c01dfaf60 100644 --- a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list +++ b/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list @@ -19,26 +19,6 @@ # Contains only the last version number of each minor version -1.58.0 -1.57.0 -1.57.0 -1.56.0 -1.55.1 -1.54.0 -1.53.0 -1.52.0 -1.51.0 -1.50.0 -1.49.0 -1.48.0 -1.47.0 -1.46.0 -1.45.0 -1.44.0 -1.43.0 -1.42.0 -1.41.0 -1.40.0 1.39.0 1.38.0 1.37.0 From 1975779aeccb02ff72e92d29a684031c72d43efa Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 17:05:06 +0800 Subject: [PATCH 27/28] Add grpc 1.30.0 -> 1.39.0 --- .github/workflows/plugins-test.0.yaml | 2 +- .../bin/startup.sh | 0 .../config/expectedData.yaml | 0 .../configuration.yml | 0 .../pom.xml | 0 .../src/main/assembly/assembly.xml | 0 .../org/apache/skywalking/apm/testcase/grpc/Application.java | 0 .../apm/testcase/grpc/consumr/ConsumerInterceptor.java | 0 .../skywalking/apm/testcase/grpc/controller/CaseController.java | 0 .../apm/testcase/grpc/provider/ProviderConfiguration.java | 0 .../testcase/grpc/provider/interceptor/ProviderInterceptor.java | 0 .../grpc/provider/service/GreeterBlockingErrorServiceImpl.java | 0 .../grpc/provider/service/GreeterBlockingServiceImpl.java | 0 .../apm/testcase/grpc/provider/service/GreeterServiceImpl.java | 0 .../src/main/proto/GreetService.proto | 0 .../src/main/resources/application.yaml | 0 .../src/main/resources/log4j2.xml | 0 .../support-version.list | 0 18 files changed, 1 insertion(+), 1 deletion(-) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/bin/startup.sh (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/config/expectedData.yaml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/configuration.yml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/pom.xml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/assembly/assembly.xml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/proto/GreetService.proto (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/resources/application.yaml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/src/main/resources/log4j2.xml (100%) rename test/plugin/scenarios/{grpc-1.30.x-1.58.x-scenario => grpc-1.30.x-1.39.x-scenario}/support-version.list (100%) diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml index 155de4edd2..a3f2653a1e 100644 --- a/.github/workflows/plugins-test.0.yaml +++ b/.github/workflows/plugins-test.0.yaml @@ -81,7 +81,7 @@ jobs: - gateway-2.0.x-scenario - grpc-scenario - grpc-1.59.x-1.70.x-scenario - - grpc-1.30.x-1.58.x-scenario + - grpc-1.30.x-1.39.x-scenario - gson-scenario - guava-cache-scenario - elasticjob-3.x-scenario diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/bin/startup.sh similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/bin/startup.sh rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/bin/startup.sh diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/config/expectedData.yaml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/config/expectedData.yaml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/config/expectedData.yaml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/configuration.yml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/configuration.yml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/configuration.yml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/pom.xml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/pom.xml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/pom.xml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/assembly/assembly.xml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/assembly/assembly.xml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/assembly/assembly.xml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/Application.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/consumr/ConsumerInterceptor.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/controller/CaseController.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/ProviderConfiguration.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/interceptor/ProviderInterceptor.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingErrorServiceImpl.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterBlockingServiceImpl.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/grpc/provider/service/GreeterServiceImpl.java diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/proto/GreetService.proto similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/proto/GreetService.proto rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/proto/GreetService.proto diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/resources/application.yaml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/application.yaml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/resources/application.yaml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/resources/log4j2.xml similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/src/main/resources/log4j2.xml rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/src/main/resources/log4j2.xml diff --git a/test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list b/test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/support-version.list similarity index 100% rename from test/plugin/scenarios/grpc-1.30.x-1.58.x-scenario/support-version.list rename to test/plugin/scenarios/grpc-1.30.x-1.39.x-scenario/support-version.list From fafe941ea89c32d57df7e7c21bfce2689ff13afd Mon Sep 17 00:00:00 2001 From: lidiwei Date: Mon, 28 Jul 2025 19:12:06 +0800 Subject: [PATCH 28/28] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index fada7555a0..4f1bc7cee8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,7 +16,7 @@ Release Notes. * Fix RabbitMQ Consumer could not receive handleCancelOk callback. * Support for tracking in lettuce versions 6.5.x and above. * Upgrade byte-buddy version to 1.17.6. -* Support gRPC 1.60.x and 1.70.x server interceptor trace +* Support gRPC 1.59.x and 1.70.x server interceptor trace All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/236?closed=1)