diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml
index 74419fcc4..655b1b5e2 100644
--- a/.github/workflows/plugins-test.3.yaml
+++ b/.github/workflows/plugins-test.3.yaml
@@ -99,6 +99,7 @@ jobs:
- guava-eventbus-scenario
- shenyu-2.4.x-scenario
- jdk-threadpool-scenario
+ - shenyu-2.4.x-dubbo-scenario
steps:
- uses: actions/checkout@v2
with:
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml
index 4d13809af..42f3c4048 100644
--- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/pom.xml
@@ -31,6 +31,7 @@
UTF-85.0.0.RELEASE
+ 2.7.0
@@ -46,6 +47,15 @@
apm-spring-webflux-5.x-plugin${project.version}
+
+
+ org.apache.dubbo
+ dubbo
+ ${apache-dubbo.version}
+ provided
+
+
+
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java
new file mode 100644
index 000000000..1a22f3612
--- /dev/null
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/ApacheDubboPluginInterceptor.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.shenyu.v24x;
+
+import java.lang.reflect.Method;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.shenyu.v24x.util.CommonUtil;
+
+/**
+ * shenyu ApacheDubboPlugin Interceptor.
+ */
+public class ApacheDubboPluginInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ CommonUtil.createLocalSpan(allArguments, "DubboPlugin");
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Object ret) throws Throwable {
+ return CommonUtil.stopLocalSpan(allArguments, ret);
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ CommonUtil.logErrorLocalSpan(allArguments, t);
+ }
+}
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java
new file mode 100644
index 000000000..5efeb737f
--- /dev/null
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/Constant.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.shenyu.v24x;
+
+public class Constant {
+ public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT";
+
+ public static final String PROXY_RPC_SPAN = "PROXY_RPC_SPAN";
+}
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java
index be727601b..5c65d9fe2 100644
--- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/GlobalPluginExecuteMethodInterceptor.java
@@ -18,11 +18,6 @@
package org.apache.skywalking.apm.plugin.shenyu.v24x;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@@ -39,21 +34,27 @@ import org.springframework.http.HttpHeaders;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;
import org.springframework.web.server.adapter.DefaultServerWebExchange;
-
import reactor.core.publisher.Mono;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+
+import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.SKYWALKING_CONTEXT_SNAPSHOT;
+
/**
* Apache shenyu global-plugin interceptor.
*/
public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsAroundInterceptor {
public static final String SHENYU_AGENT_TRACE_ID = "shenyu-agent-trace-id";
- public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT";
+
public static final String SKYWALKING_SPAN = "SKYWALKING_SPAN";
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
ContextCarrier carrier = new ContextCarrier();
@@ -85,7 +86,7 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
+ Object ret) throws Throwable {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
@@ -105,22 +106,22 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou
return monoReturn
.doOnError(throwable -> span.errorOccurred().log(throwable))
.doFinally(s -> {
- try {
- Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> {
- Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value());
- if (httpStatus.isError()) {
- span.errorOccurred();
- }
- });
- } finally {
- span.asyncFinish();
- }
+ try {
+ Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> {
+ Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value());
+ if (httpStatus.isError()) {
+ span.errorOccurred();
+ }
+ });
+ } finally {
+ span.asyncFinish();
+ }
});
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
+ Class>[] argumentsTypes, Throwable t) {
}
public static EnhancedInstance getInstance(Object o) {
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java
new file mode 100644
index 000000000..731caf4bf
--- /dev/null
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/define/ApacheDubboPluginInstrumentation.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.shenyu.v24x.define;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+
+public class ApacheDubboPluginInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private static final String ENHANCE_CLASS = "org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin";
+
+ private static final String INTERCEPT_CLASS =
+ "org.apache.skywalking.apm.plugin.shenyu.v24x.ApacheDubboPluginInterceptor";
+
+ private static final String INTERCEPT_METHOD = "doDubboInvoker";
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[]{
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(INTERCEPT_METHOD);
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPT_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+}
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java
new file mode 100644
index 000000000..be15215bc
--- /dev/null
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/shenyu/v24x/util/CommonUtil.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.shenyu.v24x.util;
+
+import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.PROXY_RPC_SPAN;
+
+import java.util.Objects;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.ServerWebExchangeDecorator;
+import org.springframework.web.server.adapter.DefaultServerWebExchange;
+
+public class CommonUtil {
+
+ public static EnhancedInstance getEnhancedServerWebExchange(Object o) {
+ EnhancedInstance instance = null;
+ if (o instanceof DefaultServerWebExchange) {
+ instance = (EnhancedInstance) o;
+ } else if (o instanceof ServerWebExchangeDecorator) {
+ ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
+ return getEnhancedServerWebExchange(delegate);
+ }
+ return instance;
+ }
+
+ public static void createLocalSpan(Object[] allArguments, String localOp) {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ EnhancedInstance enhancedInstance = CommonUtil.getEnhancedServerWebExchange(allArguments[0]);
+ AbstractSpan span = ContextManager.createLocalSpan(localOp);
+ span.setComponent(ComponentsDefine.APACHE_SHENYU);
+ SpanLayer.asRPCFramework(span);
+ if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) {
+ ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField());
+ }
+ exchange.getAttributes().put(PROXY_RPC_SPAN, span);
+ }
+
+ public static Object stopLocalSpan(Object[] allArguments, Object ret) {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN);
+ if (Objects.isNull(span)) {
+ return ret;
+ }
+ ContextManager.stopSpan(span);
+ return ret;
+ }
+
+ public static void logErrorLocalSpan(Object[] allArguments, Throwable t) {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN);
+ if (Objects.isNull(span)) {
+ return ;
+ }
+ span.errorOccurred().log(t);
+ }
+}
diff --git a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def
index 3aec1ba56..a2fb65952 100644
--- a/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/optional-plugins/shenyu-2.4.x-plugin/src/main/resources/skywalking-plugin.def
@@ -16,3 +16,5 @@
shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.GlobalPluginInstrumentation
shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ServerWebExchangeInstrumentation
+shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ApacheDubboPluginInstrumentation
+
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml
new file mode 100644
index 000000000..6df4aa21b
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/config/expectedData.yaml
@@ -0,0 +1,134 @@
+# 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: shenyu-gateway
+ segmentSize: nq 0
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[])
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: RPCFramework
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 3
+ isError: false
+ spanType: Exit
+ peer: localhost:9999
+ skipAnalysis: false
+ tags:
+ - { key: url, value: 'dubbo://localhost:9999/test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[])' }
+ - operationName: DubboPlugin
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: RPCFramework
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 127
+ isError: false
+ spanType: Local
+ peer: ''
+ skipAnalysis: false
+ refs:
+ - { parentEndpoint: /dubbo/findById, networkAddress: '', refType: CrossThread,
+ parentSpanId: 0, parentTraceSegmentId: not null,
+ parentServiceInstance: not null, parentService: shenyu-gateway,
+ traceId: not null }
+ - segmentId: not null
+ spans:
+ - operationName: /dubbo/findById
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 127
+ isError: false
+ spanType: Entry
+ peer: ''
+ skipAnalysis: false
+ tags:
+ - { key: url, value: 'http://localhost:9196/dubbo/findById?id=1' }
+ - { key: http.method, value: GET }
+ - { key: http.status_code, value: '200' }
+ refs:
+ - { parentEndpoint: 'GET:/entry/dubbo-service', networkAddress: 'localhost:9196',
+ refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
+ parentServiceInstance: not null, parentService: entry-service,
+ traceId: not null }
+
+ - serviceName: dubbo-provider
+ segmentSize: nq 0
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.findById(String)
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: RPCFramework
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 3
+ isError: false
+ spanType: Entry
+ peer: not null
+ skipAnalysis: false
+ tags:
+ - { key: url, value: not null }
+ refs:
+ - {parentEndpoint: DubboPlugin, networkAddress: 'localhost:9999', refType: CrossProcess,
+ parentSpanId: 1, parentTraceSegmentId: not null,
+ parentServiceInstance: not null , parentService: shenyu-gateway,
+ traceId: not null }
+
+ - serviceName: entry-service
+ segmentSize: nq 0
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: /dubbo/findById
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 13
+ isError: false
+ spanType: Exit
+ peer: localhost:9196
+ skipAnalysis: false
+ tags:
+ - {key: url, value: 'http://localhost:9196/dubbo/findById'}
+ - {key: http.method, value: GET}
+ - operationName: GET:/entry/dubbo-service
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 14
+ isError: false
+ spanType: Entry
+ peer: ''
+ skipAnalysis: false
+ tags:
+ - {key: url, value: 'http://localhost:8888/entry/dubbo-service'}
+ - {key: http.method, value: GET}
+
+meterItems: []
\ No newline at end of file
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml
new file mode 100644
index 000000000..7fcc25b22
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/configuration.yml
@@ -0,0 +1,24 @@
+# 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:8888/entry/dubbo-service
+healthCheck: http://localhost:8888/entry/check
+startScript: ./bin/startup.sh
+runningMode: with_optional
+withPlugins: apm-shenyu-2.4.x-plugin-*.jar
+environment:
+dependencies:
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml
new file mode 100644
index 000000000..126cafc97
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/pom.xml
@@ -0,0 +1,107 @@
+
+
+
+
+
+ org.apache.skywalking
+ shenyu-2.4.x-dubbo-scenario
+ 1.0.0
+ pom
+
+ 4.0.0
+
+
+ shenyu-dubbo-entry
+ shenyu-dubbo-gateway
+ shenyu-dubbo
+ shenyu-dubbo-dist
+
+
+
+ UTF-8
+ 1.8
+ 2.4.2
+ 2.2.2.RELEASE
+ 2.4.2
+ 1.18.20
+ 2.7.0
+
+ 1.2.79
+
+
+ skywalking-shenyu-2.4.x-dubbo-scenario
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring.boot.version}
+ pom
+ import
+
+
+ org.apache.shenyu
+ shenyu-spring-boot-starter-gateway
+ ${test.framework.version}
+
+
+ org.apache.shenyu
+ shenyu-spring-boot-starter-plugin-apache-dubbo
+ ${test.framework.version}
+
+
+
+ org.apache.dubbo
+ dubbo
+ ${dubbo.version}
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+
+
+
+ shenyu-2.4.x-dubbo-scenario
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.10.1
+
+ ${compiler.version}
+ ${compiler.version}
+ ${project.build.sourceEncoding}
+
+
+
+
+
+
+
+
+
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh
new file mode 100644
index 000000000..b93b655fe
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/bin/startup.sh
@@ -0,0 +1,29 @@
+#!/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} "-Dskywalking.agent.service_name=shenyu-gateway" ${home}/../libs/shenyu-dubbo-gateway.jar &
+sleep 2
+
+java -jar ${agent_opts} "-Dskywalking.agent.service_name=dubbo-provider" ${home}/../libs/shenyu-dubbo.jar &
+sleep 1
+
+java -jar ${agent_opts} "-Dskywalking.agent.service_name=entry-service" ${home}/../libs/shenyu-dubbo-entry.jar &
+sleep 1
+
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml
new file mode 100644
index 000000000..ae1c34acc
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/pom.xml
@@ -0,0 +1,59 @@
+
+
+
+
+ shenyu-2.4.x-dubbo-scenario
+ org.apache.skywalking
+ 1.0.0
+
+ 4.0.0
+
+ shenyu-dubbo-dist
+
+
+ 8
+ 8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ assemble
+ package
+
+ single
+
+
+
+ src/main/assembly/assembly.xml
+
+ ../target/
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml
new file mode 100644
index 000000000..82fd2b8ca
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-dist/src/main/assembly/assembly.xml
@@ -0,0 +1,51 @@
+
+
+
+
+ zip
+
+
+
+
+ ./bin
+ 0775
+
+
+
+
+
+ ../shenyu-dubbo-entry/target/shenyu-dubbo-entry.jar
+ ./libs
+ 0775
+
+
+ ../shenyu-dubbo-gateway/target/shenyu-dubbo-gateway.jar
+ ./libs
+ 0775
+
+
+ ../shenyu-dubbo/target/shenyu-dubbo.jar
+ ./libs
+ 0775
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml
new file mode 100644
index 000000000..5de653848
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/pom.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+ shenyu-2.4.x-dubbo-scenario
+ org.apache.skywalking
+ 1.0.0
+
+ 4.0.0
+
+ shenyu-dubbo-entry
+
+
+ 8
+ 8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+ shenyu-dubbo-entry
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring.boot.version}
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.java
new file mode 100644
index 000000000..7b7a477de
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/EntryApplication.java
@@ -0,0 +1,29 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.shenyu.entry;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class EntryApplication {
+
+ public static void main(final String[] args) {
+ SpringApplication.run(EntryApplication.class, args);
+ }
+}
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java
new file mode 100644
index 000000000..bc5e2b900
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/java/test/apache/skywalking/apm/testcase/shenyu/entry/http/HttpEntryController.java
@@ -0,0 +1,58 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.shenyu.entry.http;
+
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * http entry service.
+ */
+@RestController
+@RequestMapping("/entry")
+public class HttpEntryController {
+
+ private static final String ORDER_GATEWAY_URL = "http://localhost:9196/dubbo/findById?id=1";
+
+ private final RestTemplate restTemplate = new RestTemplate();
+
+ @RequestMapping("/check")
+ public String healthCheck() {
+ return "ok";
+ }
+
+ @GetMapping(value = "/dubbo-service", produces = {APPLICATION_JSON_VALUE})
+ public ResponseEntity httpService() throws Exception {
+ TimeUnit.MILLISECONDS.sleep(100);
+ ResponseEntity entity = restTemplate.getForEntity(ORDER_GATEWAY_URL, String.class);
+ if (entity.getStatusCode().is2xxSuccessful()) {
+ return ResponseEntity.ok(Optional.ofNullable(entity.getBody()).orElse(""));
+ }
+ return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("failed");
+ }
+
+}
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/resources/application.yml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/resources/application.yml
new file mode 100644
index 000000000..516dbbeca
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-entry/src/main/resources/application.yml
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+server:
+ port: 8888
+
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml
new file mode 100644
index 000000000..2e67518d4
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/pom.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+ shenyu-2.4.x-dubbo-scenario
+ org.apache.skywalking
+ 1.0.0
+
+ 4.0.0
+
+ shenyu-dubbo-gateway
+
+
+ 8
+ 8
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.apache.shenyu
+ shenyu-spring-boot-starter-gateway
+
+
+ org.apache.shenyu
+ shenyu-spring-boot-starter-plugin-apache-dubbo
+
+
+ org.apache.dubbo
+ dubbo
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ com.alibaba
+ fastjson
+
+
+
+
+ shenyu-dubbo-gateway
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring.boot.version}
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java
new file mode 100644
index 000000000..a9b9d8917
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/GatewayApplication.java
@@ -0,0 +1,33 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.shenyu.gateway;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * shenyu gateway application.
+ */
+@SpringBootApplication
+public class GatewayApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(GatewayApplication.class, args);
+ }
+
+}
diff --git a/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java
new file mode 100644
index 000000000..0f986929a
--- /dev/null
+++ b/test/plugin/scenarios/shenyu-2.4.x-dubbo-scenario/shenyu-dubbo-gateway/src/main/java/test/apache/skywalking/apm/testcase/shenyu/gateway/init/InitRouterRunner.java
@@ -0,0 +1,108 @@
+/*
+ * 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 test.apache.skywalking.apm.testcase.shenyu.gateway.init;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.shenyu.common.dto.MetaData;
+import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.dto.RuleData;
+import org.apache.shenyu.common.dto.SelectorData;
+import org.apache.shenyu.common.dto.convert.plugin.DubboRegisterConfig;
+import org.apache.shenyu.plugin.apache.dubbo.cache.ApacheDubboConfigCache;
+import org.apache.shenyu.plugin.global.cache.MetaDataCache;
+import org.apache.shenyu.sync.data.api.PluginDataSubscriber;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.parser.Feature;
+import com.fasterxml.jackson.core.type.TypeReference;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * init gateway router runner.
+ */
+@Slf4j
+@Component
+public class InitRouterRunner implements CommandLineRunner {
+
+ @Autowired
+ private PluginDataSubscriber subscriber;
+
+ @Override
+ public void run(String... args) throws Exception {
+ String pluginPath = "/shenyu-plugin.json";
+ String selectorPath = "/shenyu-selector.json";
+ String rulePath = "/shenyu-rule.json";
+
+ try (
+ InputStream pluginStream = getClass().getResourceAsStream(pluginPath);
+ InputStream selectorStream = getClass().getResourceAsStream(selectorPath);
+ InputStream ruleStream = getClass().getResourceAsStream(rulePath)) {
+
+ Map pluginDataMap = JSON.parseObject(pluginStream,
+ new TypeReference