diff --git a/.github/workflows/plugins-test.0.yaml b/.github/workflows/plugins-test.0.yaml
index 7effcb0b4..05d3372b7 100644
--- a/.github/workflows/plugins-test.0.yaml
+++ b/.github/workflows/plugins-test.0.yaml
@@ -51,7 +51,8 @@ jobs:
- { name: 'finagle-17.10.x-scenario', title: 'Finagle 17.10.0-20.1.0(19)' }
- { name: 'finagle-6.25.x-scenario', title: 'Finagle 6.25.0-6.43.0 (18)' }
- { name: 'finagle-6.44.x-scenario', title: 'Finagle 6.44.0-7.1.0 (4)' }
- - { name: 'gateway-scenario', title: 'Spring-Cloud-Gateway 2.1.x (3)' }
+ - { name: 'gateway-2.1.x-scenario', title: 'Spring-Cloud-Gateway 2.1.x (7)' }
+ - { name: 'gateway-2.0.x-scenario', title: 'Spring-Cloud-Gateway 2.0.x (3)' }
- { name: 'grpc-scenario', title: 'gRPC 1.6.0-1.25.0 (22)' }
- { name: 'gson-scenario', title: 'Gson (7)' }
steps:
diff --git a/CHANGES.md b/CHANGES.md
index 70d73560c..fa785d7db 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -22,6 +22,8 @@ Release Notes.
* Support Correlation protocol v1.
* Fix Finagle plugin bug, in processing Noop Span.
* Make `CommandService` daemon to avoid blocking target application shutting down gracefully.
+* Refactor spring cloud gateway plugin and support tracing spring cloud gateway 2.2.x
+
#### OAP-Backend
* Support meter system for Prometheus adoption. In future releases, we will add native meter APIs and MicroMeter(Sleuth) system.
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
index 1bfc94239..5d6f3bf57 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/DispatcherHandlerHandleMethodInterceptor.java
@@ -41,17 +41,10 @@ import org.springframework.web.util.pattern.PathPattern;
import reactor.core.publisher.Mono;
public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethodsAroundInterceptor {
- private static final String DEFAULT_OPERATION_NAME = "WEBFLUX.handle";
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
-
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
+ MethodInterceptResult result) throws Throwable {
EnhancedInstance instance = getInstance(allArguments[0]);
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
@@ -67,7 +60,7 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
}
}
- AbstractSpan span = ContextManager.createEntrySpan(DEFAULT_OPERATION_NAME, carrier);
+ AbstractSpan span = ContextManager.createEntrySpan(exchange.getRequest().getURI().getPath(), carrier);
span.setComponent(ComponentsDefine.SPRING_WEBFLUX);
SpanLayer.asHttp(span);
Tags.URL.set(span, exchange.getRequest().getURI().toString());
@@ -76,6 +69,15 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
span.prepareForAsync();
ContextManager.stopSpan(span);
+ objInst.setSkyWalkingDynamicField(span);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ AbstractSpan span = (AbstractSpan) objInst.getSkyWalkingDynamicField();
+
return ((Mono) ret).doFinally(s -> {
try {
Object pathPattern = exchange.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
@@ -99,7 +101,7 @@ public class DispatcherHandlerHandleMethodInterceptor implements InstanceMethods
@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/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml
new file mode 100644
index 000000000..0200cfc93
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/pom.xml
@@ -0,0 +1,55 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.skywalking
+ optional-spring-cloud
+ 8.0.0-SNAPSHOT
+
+
+ apm-spring-cloud-gateway-2.0.x-plugin
+ jar
+
+ gateway-2.0.x-plugin
+ http://maven.apache.org
+
+
+ 2.1.1.RELEASE
+ 1.8
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+ ${spring-cloud-starter-gateway.version}
+ provided
+
+
+ io.projectreactor.ipc
+ reactor-netty
+ 0.7.5.RELEASE
+ provided
+
+
+
+
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java
new file mode 100644
index 000000000..c63a3fae1
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java
@@ -0,0 +1,116 @@
+/*
+ * 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.spring.cloud.gateway.v20x;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+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;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.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.spring.cloud.gateway.v20x.define.EnhanceCacheObject;
+import org.reactivestreams.Publisher;
+import reactor.core.publisher.Mono;
+import reactor.ipc.netty.http.client.HttpClientRequest;
+import reactor.ipc.netty.http.client.HttpClientResponse;
+
+import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.SPRING_CLOUD_GATEWAY;
+
+public class HttpClientRequestInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final MethodInterceptResult result) throws Throwable {
+ AbstractSpan span = ContextManager.activeSpan();
+
+ URL url = new URL((String) allArguments[1]);
+ ContextCarrier contextCarrier = new ContextCarrier();
+ AbstractSpan abstractSpan = ContextManager.createExitSpan(
+ "SpringCloudGateway/sendRequest", contextCarrier, getPeer(url));
+ abstractSpan.prepareForAsync();
+ Tags.URL.set(abstractSpan, String.valueOf(allArguments[1]));
+
+ abstractSpan.setComponent(SPRING_CLOUD_GATEWAY);
+ ContextManager.stopSpan(abstractSpan);
+
+ Function super HttpClientRequest, ? extends Publisher> handler = (Function super HttpClientRequest, ? extends Publisher>) allArguments[2];
+ allArguments[2] = new Function>() {
+ @Override
+ public Publisher apply(final HttpClientRequest httpClientRequest) {
+ //
+ CarrierItem next = contextCarrier.items();
+ if (httpClientRequest instanceof EnhancedInstance) {
+ ((EnhancedInstance) httpClientRequest).setSkyWalkingDynamicField(next);
+ }
+ return handler.apply(httpClientRequest);
+ }
+ };
+
+ objInst.setSkyWalkingDynamicField(new EnhanceCacheObject(span, abstractSpan));
+ }
+
+ @Override
+ public Object afterMethod(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final Object ret) throws Throwable {
+ EnhanceCacheObject enhanceCacheObject = (EnhanceCacheObject) objInst.getSkyWalkingDynamicField();
+ Mono responseMono = (Mono) ret;
+ return responseMono.doAfterSuccessOrError(new BiConsumer() {
+ @Override
+ public void accept(final HttpClientResponse httpClientResponse, final Throwable throwable) {
+
+ AbstractSpan abstractSpan = enhanceCacheObject.getSendSpan();
+ if (abstractSpan != null) {
+ if (throwable != null) {
+ abstractSpan.errorOccurred().log(throwable);
+ } else if (httpClientResponse.status().code() > 400) {
+ abstractSpan.errorOccurred();
+ }
+ Tags.STATUS_CODE.set(abstractSpan, String.valueOf(httpClientResponse.status().code()));
+ abstractSpan.asyncFinish();
+ }
+
+ objInst.setSkyWalkingDynamicField(null);
+ enhanceCacheObject.getFilterSpan().asyncFinish();
+ }
+ });
+ }
+
+ private String getPeer(URL url) {
+ return url.getHost() + ":" + url.getPort();
+ }
+
+ @Override
+ public void handleMethodException(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpclientRequestHeadersInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpclientRequestHeadersInterceptor.java
new file mode 100644
index 000000000..e723ecf68
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/HttpclientRequestHeadersInterceptor.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x;
+
+import io.netty.handler.codec.http.HttpHeaders;
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+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;
+
+public class HttpclientRequestHeadersInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final MethodInterceptResult result) throws Throwable {
+ CarrierItem next = (CarrierItem) objInst.getSkyWalkingDynamicField();
+ if (next != null) {
+ HttpHeaders headers = (HttpHeaders) allArguments[0];
+ while (next.hasNext()) {
+ next = next.next();
+ headers.remove(next.getHeadKey());
+ headers.set(next.getHeadKey(), next.getHeadValue());
+ }
+ }
+ }
+
+ @Override
+ public Object afterMethod(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final Object ret) throws Throwable {
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(final EnhancedInstance objInst,
+ final Method method,
+ final Object[] allArguments,
+ final Class>[] argumentsTypes,
+ final Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java
new file mode 100644
index 000000000..776723bae
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/NettyRoutingFilterInterceptor.java
@@ -0,0 +1,71 @@
+/*
+ * 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.spring.cloud.gateway.v20x;
+
+import java.lang.reflect.Method;
+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.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.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.ServerWebExchangeDecorator;
+import org.springframework.web.server.adapter.DefaultServerWebExchange;
+
+import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.SPRING_CLOUD_GATEWAY;
+
+public class NettyRoutingFilterInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ EnhancedInstance enhancedInstance = getInstance(exchange);
+
+ AbstractSpan span = ContextManager.createLocalSpan("SpringCloudGateway/RoutingFilter");
+ if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) {
+ ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField());
+ }
+ span.setComponent(SPRING_CLOUD_GATEWAY);
+ span.prepareForAsync();
+ }
+
+ public static EnhancedInstance getInstance(Object o) {
+ EnhancedInstance instance = null;
+ if (o instanceof DefaultServerWebExchange) {
+ instance = (EnhancedInstance) o;
+ } else if (o instanceof ServerWebExchangeDecorator) {
+ ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
+ return getInstance(delegate);
+ }
+ return instance;
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/Constants.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/Constants.java
new file mode 100644
index 000000000..450699c95
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/Constants.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define;
+
+public interface Constants {
+ // NettyRoutingFilter
+ String INTERCEPT_CLASS_NETTY_ROUTING_FILTER = "org.springframework.cloud.gateway.filter.NettyRoutingFilter";
+ String NETTY_ROUTING_FILTER_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.NettyRoutingFilterInterceptor";
+
+ // HttpClient
+ String INTERCEPT_CLASS_HTTP_CLIENT = "reactor.ipc.netty.http.client.HttpClient";
+ String REQUEST_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.HttpClientRequestInterceptor";
+
+ // HttpClientRequest
+ String INTERCEPT_CLASS_HTTP_CLIENT_REQUEST = "reactor.ipc.netty.http.client.HttpClientRequest";
+ String HTTPCLIENT_REQUEST_HEADERS_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.HttpclientRequestHeadersInterceptor";
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/EnhanceCacheObject.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/EnhanceCacheObject.java
new file mode 100644
index 000000000..14964a305
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/EnhanceCacheObject.java
@@ -0,0 +1,38 @@
+/*
+ * 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.spring.cloud.gateway.v20x.define;
+
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+
+public class EnhanceCacheObject {
+ private final AbstractSpan filterSpan;
+ private final AbstractSpan sendSpan;
+
+ public EnhanceCacheObject(final AbstractSpan filterSpan, final AbstractSpan sendSpan) {
+ this.filterSpan = filterSpan;
+ this.sendSpan = sendSpan;
+ }
+
+ public AbstractSpan getFilterSpan() {
+ return filterSpan;
+ }
+
+ public AbstractSpan getSendSpan() {
+ return sendSpan;
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientInstrumentation.java
new file mode 100644
index 000000000..d865cb22a
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientInstrumentation.java
@@ -0,0 +1,63 @@
+/*
+ * 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.spring.cloud.gateway.v20x.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+public class HttpClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(Constants.INTERCEPT_CLASS_HTTP_CLIENT);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[]{
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named("request");
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return Constants.REQUEST_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ }
+ };
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/FilteringWebHandlerInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientRequestInstrumentation.java
similarity index 54%
rename from apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/FilteringWebHandlerInstrumentation.java
rename to apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientRequestInstrumentation.java
index 3aaf02d64..c8da53530 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/FilteringWebHandlerInstrumentation.java
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/HttpClientRequestInstrumentation.java
@@ -1,22 +1,21 @@
/*
- * 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
+ * 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.
+ * 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.spring.cloud.gateway.v21x.define;
+package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
@@ -26,9 +25,14 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInst
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
-import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.apache.skywalking.apm.agent.core.plugin.match.HierarchyMatch.byHierarchyMatch;
-public class FilteringWebHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+public class HttpClientRequestInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byHierarchyMatch(Constants.INTERCEPT_CLASS_HTTP_CLIENT_REQUEST);
+ }
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@@ -41,12 +45,12 @@ public class FilteringWebHandlerInstrumentation extends ClassInstanceMethodsEnha
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher getMethodsMatcher() {
- return named("handle");
+ return named("headers");
}
@Override
public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.FilteringWebHandlerInterceptor";
+ return Constants.HTTPCLIENT_REQUEST_HEADERS_INTERCEPTOR;
}
@Override
@@ -56,10 +60,4 @@ public class FilteringWebHandlerInstrumentation extends ClassInstanceMethodsEnha
}
};
}
-
- @Override
- public ClassMatch enhanceClass() {
- return byName("org.springframework.cloud.gateway.handler.FilteringWebHandler");
- }
-
}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/NettyRoutingFilterInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/NettyRoutingFilterInstrumentation.java
new file mode 100644
index 000000000..516fdce0f
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v20x/define/NettyRoutingFilterInstrumentation.java
@@ -0,0 +1,65 @@
+/*
+ * 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.spring.cloud.gateway.v20x.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(Constants.INTERCEPT_CLASS_NETTY_ROUTING_FILTER);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named("filter").and(
+ takesArgumentWithType(0, "org.springframework.web.server.ServerWebExchange"));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return Constants.NETTY_ROUTING_FILTER_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ }
+ };
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 000000000..fb06a42a5
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.0.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,19 @@
+# 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.
+
+spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.NettyRoutingFilterInstrumentation
+spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.HttpClientInstrumentation
+spring-cloud-gateway-2.0.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v20x.define.HttpClientRequestInstrumentation
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
index 0ec01b035..4bb571690 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/pom.xml
@@ -26,10 +26,10 @@
8.0.0-SNAPSHOT
- apm-spring-cloud-gateway-2.x-plugin
+ apm-spring-cloud-gateway-2.1.x-pluginjar
- gateway-2.x-plugin
+ gateway-2.1.x-pluginhttp://maven.apache.org
@@ -44,6 +44,12 @@
${spring-cloud-starter-gateway.version}provided
+
+ io.projectreactor.netty
+ reactor-netty
+ 0.8.11.RELEASE
+ provided
+
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/DefaultHttpHeadersInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/DefaultHttpHeadersInterceptor.java
deleted file mode 100644
index 0b922b045..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/DefaultHttpHeadersInterceptor.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.plugin.spring.cloud.gateway.v21x;
-
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
-import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.Constants;
-
-public class DefaultHttpHeadersInterceptor implements InstanceConstructorInterceptor {
- @Override
- public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
- Object transmitter = ContextManager.getRuntimeContext().get(Constants.SPRING_CLOUD_GATEWAY_TRANSMITTER);
- if (transmitter != null) {
- objInst.setSkyWalkingDynamicField(transmitter);
- ContextManager.getRuntimeContext().remove(Constants.SPRING_CLOUD_GATEWAY_TRANSMITTER);
- }
- }
-}
\ No newline at end of file
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java
deleted file mode 100644
index adb958fb5..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/FilteringWebHandlerInterceptor.java
+++ /dev/null
@@ -1,94 +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.plugin.spring.cloud.gateway.v21x;
-
-import static org.springframework.cloud.gateway.support.ServerWebExchangeUtils.GATEWAY_ROUTE_ATTR;
-
-import java.lang.reflect.Method;
-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.tag.Tags;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter;
-import org.springframework.cloud.gateway.route.Route;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.server.ServerWebExchange;
-import reactor.core.publisher.Mono;
-
-public class FilteringWebHandlerInterceptor implements InstanceMethodsAroundInterceptor {
-
- private static final String SPRING_CLOUD_GATEWAY_ROUTE_PREFIX = "GATEWAY/";
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- EnhancedInstance instance = NettyRoutingFilterInterceptor.getInstance(allArguments[0]);
- if (instance == null) {
- return;
- }
- ContextSnapshot contextSnapshot = (ContextSnapshot) instance.getSkyWalkingDynamicField();
- if (contextSnapshot == null) {
- return;
- }
-
- ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
- String operationName = SPRING_CLOUD_GATEWAY_ROUTE_PREFIX;
- Route route = exchange.getRequiredAttribute(GATEWAY_ROUTE_ATTR);
- operationName = operationName + route.getId();
- SWTransmitter transmitter = new SWTransmitter(contextSnapshot, operationName);
- instance.setSkyWalkingDynamicField(transmitter);
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- EnhancedInstance instance = NettyRoutingFilterInterceptor.getInstance(allArguments[0]);
- if (instance == null) {
- return ret;
- }
- SWTransmitter swTransmitter = (SWTransmitter) instance.getSkyWalkingDynamicField();
- if (swTransmitter == null) {
- return ret;
- }
- Mono mono = (Mono) ret;
- return mono.doFinally(d -> {
- ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
- HttpStatus statusCode = exchange.getResponse().getStatusCode();
- if (statusCode == HttpStatus.TOO_MANY_REQUESTS) {
- AbstractSpan localSpan = ContextManager.createLocalSpan(swTransmitter.getOperationName());
- Tags.STATUS_CODE.set(localSpan, statusCode.toString());
- SpanLayer.asHttp(localSpan);
- localSpan.setComponent(ComponentsDefine.SPRING_CLOUD_GATEWAY);
- ContextManager.continued(swTransmitter.getSnapshot());
- ContextManager.stopSpan(localSpan);
- }
- });
- }
-
- @Override
- public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- }
-
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerConstructorInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerConstructorInterceptor.java
new file mode 100644
index 000000000..e6efdd979
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerConstructorInterceptor.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.plugin.spring.cloud.gateway.v21x;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.EnhanceObjectCache;
+
+public class HttpClientFinalizerConstructorInterceptor implements InstanceConstructorInterceptor {
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+ EnhancedInstance tcpClient = (EnhancedInstance) allArguments[0];
+ if (tcpClient.getSkyWalkingDynamicField() == null) {
+ tcpClient.setSkyWalkingDynamicField(new EnhanceObjectCache());
+ }
+
+ objInst.setSkyWalkingDynamicField(tcpClient.getSkyWalkingDynamicField());
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerResponseConnectionInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerResponseConnectionInterceptor.java
new file mode 100644
index 000000000..9c9fd191c
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerResponseConnectionInterceptor.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x;
+
+import java.lang.reflect.Method;
+import java.util.function.BiFunction;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.EnhanceObjectCache;
+import org.reactivestreams.Publisher;
+import reactor.netty.Connection;
+import reactor.netty.http.client.HttpClientResponse;
+
+public class HttpClientFinalizerResponseConnectionInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ BiFunction super HttpClientResponse, ? super Connection, ? extends Publisher> finalReceiver = (BiFunction super HttpClientResponse, ? super Connection, ? extends Publisher>) allArguments[0];
+ EnhanceObjectCache cache = (EnhanceObjectCache) objInst.getSkyWalkingDynamicField();
+ allArguments[0] = new BiFunction() {
+ @Override
+ public Publisher apply(final HttpClientResponse response, final Connection connection) {
+ Publisher publisher = finalReceiver.apply(response, connection);
+ // receive the response. Stop the span.
+ if (cache.getSpan() != null) {
+ if (response.status().code() >= 400) {
+ cache.getSpan().errorOccurred();
+ }
+ Tags.STATUS_CODE.set(cache.getSpan(), String.valueOf(response.status().code()));
+ cache.getSpan().asyncFinish();
+ }
+
+ if (cache.getSpan1() != null) {
+ cache.getSpan1().asyncFinish();
+ }
+ return publisher;
+ }
+ };
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java
new file mode 100644
index 000000000..c1da2bce7
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java
@@ -0,0 +1,97 @@
+/*
+ * 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.spring.cloud.gateway.v21x;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.function.BiFunction;
+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;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.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.spring.cloud.gateway.v21x.define.EnhanceObjectCache;
+import org.apache.skywalking.apm.util.StringUtil;
+import org.reactivestreams.Publisher;
+import reactor.netty.NettyOutbound;
+import reactor.netty.http.client.HttpClientRequest;
+
+import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.SPRING_CLOUD_GATEWAY;
+
+public class HttpClientFinalizerSendInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ EnhanceObjectCache enhanceObjectCache = (EnhanceObjectCache) objInst.getSkyWalkingDynamicField();
+ AbstractSpan span = ContextManager.activeSpan();
+ span.prepareForAsync();
+
+ if (!StringUtil.isEmpty(enhanceObjectCache.getUrl())) {
+ URL url = new URL(enhanceObjectCache.getUrl());
+
+ ContextCarrier contextCarrier = new ContextCarrier();
+ AbstractSpan abstractSpan = ContextManager.createExitSpan(
+ "SpringCloudGateway/sendRequest", contextCarrier, getPeer(url));
+ Tags.URL.set(abstractSpan, enhanceObjectCache.getUrl());
+ abstractSpan.prepareForAsync();
+ abstractSpan.setComponent(SPRING_CLOUD_GATEWAY);
+
+ ContextManager.stopSpan(abstractSpan);
+ ContextManager.stopSpan(span);
+
+ BiFunction super HttpClientRequest, ? super NettyOutbound, ? extends Publisher> finalSender = (BiFunction super HttpClientRequest, ? super NettyOutbound, ? extends Publisher>) allArguments[0];
+ allArguments[0] = new BiFunction>() {
+ @Override
+ public Publisher apply(HttpClientRequest request, NettyOutbound outbound) {
+ Publisher publisher = finalSender.apply(request, outbound);
+
+ CarrierItem next = contextCarrier.items();
+ while (next.hasNext()) {
+ next = next.next();
+ request.requestHeaders().remove(next.getHeadKey());
+ request.requestHeaders().set(next.getHeadKey(), next.getHeadValue());
+ }
+ return publisher;
+ }
+ };
+ enhanceObjectCache.setCacheSpan(abstractSpan);
+ }
+
+ enhanceObjectCache.setSpan1(span);
+ }
+
+ private String getPeer(URL url) {
+ return url.getHost() + ":" + url.getPort();
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ ((EnhancedInstance) ret).setSkyWalkingDynamicField(objInst.getSkyWalkingDynamicField());
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerURIInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerURIInterceptor.java
new file mode 100644
index 000000000..1d8921f9c
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientFinalizerURIInterceptor.java
@@ -0,0 +1,46 @@
+/*
+ * 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.spring.cloud.gateway.v21x;
+
+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.spring.cloud.gateway.v21x.define.EnhanceObjectCache;
+
+public class HttpClientFinalizerURIInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (ret instanceof EnhancedInstance) {
+ EnhanceObjectCache enhanceObjectCache = (EnhanceObjectCache) ((EnhancedInstance) ret).getSkyWalkingDynamicField();
+ enhanceObjectCache.setUrl(String.valueOf(allArguments[0]));
+ }
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsHeadersInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsHeadersInterceptor.java
deleted file mode 100644
index 4c9ee91bf..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsHeadersInterceptor.java
+++ /dev/null
@@ -1,53 +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.plugin.spring.cloud.gateway.v21x;
-
-import org.apache.skywalking.apm.agent.core.logging.api.ILog;
-import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-
-import java.lang.reflect.Method;
-
-public class HttpClientOperationsHeadersInterceptor implements InstanceMethodsAroundInterceptor {
-
- private static final ILog logger = LogManager.getLogger(HttpClientOperationsHeadersInterceptor.class);
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- Object transmitter = ((EnhancedInstance) allArguments[0]).getSkyWalkingDynamicField();
- if (transmitter != null) {
- objInst.setSkyWalkingDynamicField(transmitter);
- ((EnhancedInstance) allArguments[0]).setSkyWalkingDynamicField(null);
- }
- return ret;
- }
-
- @Override
- public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- }
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsSendInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsSendInterceptor.java
deleted file mode 100644
index 301dfe64d..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsSendInterceptor.java
+++ /dev/null
@@ -1,84 +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.plugin.spring.cloud.gateway.v21x;
-
-import io.netty.handler.codec.http.HttpHeaders;
-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;
-import org.apache.skywalking.apm.agent.core.context.tag.Tags;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter;
-import reactor.netty.channel.ChannelOperations;
-import reactor.netty.http.client.HttpClientRequest;
-
-import java.lang.reflect.Method;
-import java.net.InetSocketAddress;
-
-public class HttpClientOperationsSendInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- SWTransmitter transmitter = (SWTransmitter) objInst.getSkyWalkingDynamicField();
- if (transmitter != null) {
- HttpClientRequest request = (HttpClientRequest) objInst;
-
- HttpHeaders header = request.requestHeaders();
- ChannelOperations channelOpt = (ChannelOperations) objInst;
- InetSocketAddress remote = (InetSocketAddress) (channelOpt.channel().remoteAddress());
- String peer = remote.getHostName() + ":" + remote.getPort();
-
- AbstractSpan span = ContextManager.createExitSpan(transmitter.getOperationName(), peer);
- ContextManager.continued(transmitter.getSnapshot());
- ContextCarrier contextCarrier = new ContextCarrier();
- ContextManager.inject(contextCarrier);
-
- span.setComponent(ComponentsDefine.SPRING_CLOUD_GATEWAY);
- Tags.URL.set(span, peer + request.uri());
- Tags.HTTP.METHOD.set(span, request.method().name());
- SpanLayer.asHttp(span);
-
- CarrierItem next = contextCarrier.items();
- while (next.hasNext()) {
- next = next.next();
- header.set(next.getHeadKey(), next.getHeadValue());
- }
- transmitter.setSpanGateway(span.prepareForAsync());
- ContextManager.stopSpan(span);
- }
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- return ret;
- }
-
- @Override
- public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsStatusInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsStatusInterceptor.java
deleted file mode 100644
index a60986132..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/HttpClientOperationsStatusInterceptor.java
+++ /dev/null
@@ -1,59 +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.plugin.spring.cloud.gateway.v21x;
-
-import io.netty.handler.codec.http.HttpResponseStatus;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.context.tag.Tags;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter;
-
-import java.lang.reflect.Method;
-
-public class HttpClientOperationsStatusInterceptor implements InstanceMethodsAroundInterceptor {
-
- @Override
- public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- }
-
- @Override
- public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
-
- SWTransmitter transmitter = (SWTransmitter) objInst.getSkyWalkingDynamicField();
- if (transmitter != null) {
- HttpResponseStatus response = (HttpResponseStatus) ret;
- if (response.code() >= 400) {
- Tags.STATUS_CODE.set(transmitter.getSpanGateway().errorOccurred(), String.valueOf(response.code()));
- }
- transmitter.getSpanGateway().asyncFinish();
- objInst.setSkyWalkingDynamicField(null);
- }
- return ret;
- }
-
- @Override
- public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
- ContextManager.activeSpan().errorOccurred().log(t);
- }
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
index 70422773a..a9035d60a 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/NettyRoutingFilterInterceptor.java
@@ -1,79 +1,69 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * 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.
+ * 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.spring.cloud.gateway.v21x;
+import java.lang.reflect.Method;
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.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.spring.cloud.gateway.v21x.context.Constants;
-import org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context.SWTransmitter;
+import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;
import org.springframework.web.server.adapter.DefaultServerWebExchange;
-import java.lang.reflect.Method;
+
+import static org.apache.skywalking.apm.network.trace.component.ComponentsDefine.SPRING_CLOUD_GATEWAY;
public class NettyRoutingFilterInterceptor implements InstanceMethodsAroundInterceptor {
-
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- MethodInterceptResult result) throws Throwable {
- EnhancedInstance instance = NettyRoutingFilterInterceptor.getInstance(allArguments[0]);
- if (instance != null) {
- SWTransmitter swTransmitter = (SWTransmitter) instance.getSkyWalkingDynamicField();
- ContextManager.getRuntimeContext().put(Constants.SPRING_CLOUD_GATEWAY_TRANSMITTER, swTransmitter);
+ MethodInterceptResult result) throws Throwable {
+ ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
+ EnhancedInstance enhancedInstance = getInstance(exchange);
+
+ AbstractSpan span = ContextManager.createLocalSpan("SpringCloudGateway/RoutingFilter");
+ if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) {
+ ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField());
}
+ span.setComponent(SPRING_CLOUD_GATEWAY);
+ }
+
+ public static EnhancedInstance getInstance(Object o) {
+ EnhancedInstance instance = null;
+ if (o instanceof DefaultServerWebExchange) {
+ instance = (EnhancedInstance) o;
+ } else if (o instanceof ServerWebExchangeDecorator) {
+ ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
+ return getInstance(delegate);
+ }
+ return instance;
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
- Object ret) throws Throwable {
- if (ContextManager.getRuntimeContext().get(Constants.SPRING_CLOUD_GATEWAY_TRANSMITTER) != null) {
- ContextManager.getRuntimeContext().remove(Constants.SPRING_CLOUD_GATEWAY_TRANSMITTER);
- }
+ Object ret) throws Throwable {
return ret;
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
- Class>[] argumentsTypes, Throwable t) {
+ Class>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
}
-
- public static EnhancedInstance getInstance(Object o) {
- EnhancedInstance instance = null;
- if (o instanceof ServerWebExchangeDecorator) {
- instance = getEnhancedInstance((ServerWebExchangeDecorator) o);
- } else if (o instanceof DefaultServerWebExchange) {
- instance = (EnhancedInstance) o;
- }
- return instance;
- }
-
- private static EnhancedInstance getEnhancedInstance(ServerWebExchangeDecorator serverWebExchangeDecorator) {
- Object o = serverWebExchangeDecorator.getDelegate();
- if (o instanceof ServerWebExchangeDecorator) {
- return getEnhancedInstance((ServerWebExchangeDecorator) o);
- } else if (o instanceof DefaultServerWebExchange) {
- return (EnhancedInstance) o;
- } else if (o == null) {
- throw new NullPointerException("The expected class DefaultServerWebExchange is null");
- } else {
- throw new RuntimeException("Unknown parameter types:" + o.getClass());
- }
- }
-}
\ No newline at end of file
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/TcpClientConstructorInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/TcpClientConstructorInterceptor.java
new file mode 100644
index 000000000..fcbf5892a
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/TcpClientConstructorInterceptor.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 org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+
+public class TcpClientConstructorInterceptor implements InstanceConstructorInterceptor {
+
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/SWTransmitter.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/SWTransmitter.java
deleted file mode 100644
index ac4f61aae..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/SWTransmitter.java
+++ /dev/null
@@ -1,58 +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.plugin.spring.cloud.gateway.v21x.context;
-
-import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
-
-public class SWTransmitter {
-
- private AbstractSpan spanGateway;
- private ContextSnapshot snapshot;
- private String operationName;
-
- public SWTransmitter(ContextSnapshot snapshot, String operationName) {
- this.snapshot = snapshot;
- this.operationName = operationName;
- }
-
- public AbstractSpan getSpanGateway() {
- return spanGateway;
- }
-
- public void setSpanGateway(AbstractSpan spanGateway) {
- this.spanGateway = spanGateway;
- }
-
- public ContextSnapshot getSnapshot() {
- return snapshot;
- }
-
- public void setSnapshot(ContextSnapshot snapshot) {
- this.snapshot = snapshot;
- }
-
- public String getOperationName() {
- return operationName;
- }
-
- public void setOperationName(String operationName) {
- this.operationName = operationName;
- }
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/AbstractGateway210EnhancePluginDefine.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/AbstractGateway210EnhancePluginDefine.java
new file mode 100644
index 000000000..97f0cf8d7
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/AbstractGateway210EnhancePluginDefine.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+
+public abstract class AbstractGateway210EnhancePluginDefine extends ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected String[] witnessClasses() {
+ return new String[] {
+ "org.springframework.cloud.gateway.config.GatewayEnvironmentPostProcessor"
+ };
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/Constants.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/Constants.java
new file mode 100644
index 000000000..1dbb09ff1
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/Constants.java
@@ -0,0 +1,36 @@
+/*
+ * 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.spring.cloud.gateway.v21x.define;
+
+public interface Constants {
+ // HttpClientFinalizer
+ String INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER = "reactor.netty.http.client.HttpClientFinalizer";
+ String CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerConstructorInterceptor";
+ String HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerSendInterceptor";
+ String HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerURIInterceptor";
+ String HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientFinalizerResponseConnectionInterceptor";
+
+ // NettyRoutingFilter
+ String INTERCEPT_CLASS_NETTY_ROUTING_FILTER = "org.springframework.cloud.gateway.filter.NettyRoutingFilter";
+ String NETTY_ROUTING_FILTER_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.NettyRoutingFilterInterceptor";
+
+ // TcpClient
+ String INTERCEPT_CLASS_TCP_CLIENT = "reactor.netty.tcp.TcpClient";
+ String TCP_CLIENT_CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.TcpClientConstructorInterceptor";
+
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/DefaultHttpHeadersInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/DefaultHttpHeadersInstrumentation.java
deleted file mode 100644
index 4fc43a73e..000000000
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/DefaultHttpHeadersInstrumentation.java
+++ /dev/null
@@ -1,59 +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.plugin.spring.cloud.gateway.v21x.define;
-
-import net.bytebuddy.description.method.MethodDescription;
-import net.bytebuddy.matcher.ElementMatcher;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
-
-import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
-import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-
-public class DefaultHttpHeadersInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
-
- @Override
- public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[] {
- new ConstructorInterceptPoint() {
- @Override
- public ElementMatcher getConstructorMatcher() {
- return takesArgumentWithType(0, "io.netty.handler.codec.DefaultHeaders");
- }
-
- @Override
- public String getConstructorInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.DefaultHttpHeadersInterceptor";
- }
- }
- };
- }
-
- @Override
- public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
- return new InstanceMethodsInterceptPoint[0];
- }
-
- @Override
- public ClassMatch enhanceClass() {
- return byName("io.netty.handler.codec.http.DefaultHttpHeaders");
- }
-}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/EnhanceObjectCache.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/EnhanceObjectCache.java
new file mode 100644
index 000000000..4b2c21107
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/EnhanceObjectCache.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.spring.cloud.gateway.v21x.define;
+
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+
+public class EnhanceObjectCache {
+ private String url;
+ private AbstractSpan span;
+ private AbstractSpan span1;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setCacheSpan(AbstractSpan span) {
+ this.span = span;
+ }
+
+ public AbstractSpan getSpan() {
+ return span;
+ }
+
+ public void setSpan1(final AbstractSpan span) {
+ span1 = span;
+ }
+
+ public AbstractSpan getSpan1() {
+ return span1;
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientOperationsInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientFinalizerInstrumentation.java
similarity index 51%
rename from apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientOperationsInstrumentation.java
rename to apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientFinalizerInstrumentation.java
index 35605ecce..14d85b2e0 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientOperationsInstrumentation.java
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/HttpClientFinalizerInstrumentation.java
@@ -1,19 +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
+ * 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.
+ * 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.spring.cloud.gateway.v21x.define;
@@ -22,18 +21,34 @@ import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-public class HttpClientOperationsInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+public class HttpClientFinalizerInstrumentation extends AbstractGateway210EnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(Constants.INTERCEPT_CLASS_HTTP_CLIENT_FINALIZER);
+ }
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return new ConstructorInterceptPoint[0];
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override
+ public ElementMatcher getConstructorMatcher() {
+ return takesArgumentWithType(0, "reactor.netty.tcp.TcpClient");
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return Constants.CLIENT_FINALIZER_CONSTRUCTOR_INTERCEPTOR;
+ }
+ }
+ };
}
@Override
@@ -42,12 +57,28 @@ public class HttpClientOperationsInstrumentation extends ClassInstanceMethodsEnh
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher getMethodsMatcher() {
- return named("headers").and(takesArgumentWithType(0, "io.netty.handler.codec.http.HttpHeaders"));
+ return named("send");
}
@Override
public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsHeadersInterceptor";
+ return Constants.HTTP_CLIENT_FINALIZER_SEND_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named("uri");
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return Constants.HTTP_CLIENT_FINALIZER_URI_INTERCEPTOR;
}
@Override
@@ -58,40 +89,19 @@ public class HttpClientOperationsInstrumentation extends ClassInstanceMethodsEnh
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher getMethodsMatcher() {
- return named("send").and(takesArgumentWithType(0, "org.reactivestreams.Publisher"));
+ return named("responseConnection");
}
@Override
public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsSendInterceptor";
+ return Constants.HTTP_CLIENT_FINALIZER_RESPONSE_CONNECTION_INTERCEPTOR;
}
@Override
public boolean isOverrideArgs() {
- return false;
+ return true;
}
- },
- new InstanceMethodsInterceptPoint() {
- @Override
- public ElementMatcher getMethodsMatcher() {
- return named("status");
- }
-
- @Override
- public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.HttpClientOperationsStatusInterceptor";
- }
-
- @Override
- public boolean isOverrideArgs() {
- return false;
- }
- },
- };
- }
-
- @Override
- public ClassMatch enhanceClass() {
- return byName("reactor.netty.http.client.HttpClientOperations");
+ }
+ };
}
}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java
index 9339b27b7..e76deff20 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/NettyRoutingFilterInstrumentation.java
@@ -1,19 +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
+ * 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.
+ * 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.spring.cloud.gateway.v21x.define;
@@ -22,14 +21,18 @@ import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
-import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
-public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+public class NettyRoutingFilterInstrumentation extends AbstractGateway210EnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(Constants.INTERCEPT_CLASS_NETTY_ROUTING_FILTER);
+ }
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
@@ -42,32 +45,20 @@ public class NettyRoutingFilterInstrumentation extends ClassInstanceMethodsEnhan
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher getMethodsMatcher() {
- return named("filter").and(takesArgumentWithType(0, "org.springframework.web.server.ServerWebExchange"));
+ return named("filter").and(
+ takesArgumentWithType(0, "org.springframework.web.server.ServerWebExchange"));
}
@Override
public String getMethodsInterceptor() {
- return "org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.NettyRoutingFilterInterceptor";
+ return Constants.NETTY_ROUTING_FILTER_INTERCEPTOR;
}
@Override
public boolean isOverrideArgs() {
- return false;
+ return true;
}
}
};
}
-
- @Override
- public ClassMatch enhanceClass() {
- return byName("org.springframework.cloud.gateway.filter.NettyRoutingFilter");
- }
-
- @Override
- protected final String[] witnessClasses() {
- return new String[] {
- "org.springframework.cloud.gateway.handler.FilteringWebHandler",
- "reactor.netty.http.client.HttpClientOperations"
- };
- }
}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/TcpClientInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/TcpClientInstrumentation.java
new file mode 100644
index 000000000..eea278579
--- /dev/null
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/define/TcpClientInstrumentation.java
@@ -0,0 +1,57 @@
+/*
+ * 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.spring.cloud.gateway.v21x.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.any;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+public class TcpClientInstrumentation extends AbstractGateway210EnhancePluginDefine {
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(Constants.INTERCEPT_CLASS_TCP_CLIENT);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override
+ public ElementMatcher getConstructorMatcher() {
+ return any();
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return Constants.TCP_CLIENT_CONSTRUCTOR_INTERCEPTOR;
+ }
+ }
+ };
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[0];
+ }
+}
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def
index f2f821eaf..d87713949 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/resources/skywalking-plugin.def
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.DefaultHttpHeadersInstrumentation
-spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.HttpClientOperationsInstrumentation
+spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.HttpClientFinalizerInstrumentation
spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.NettyRoutingFilterInstrumentation
-spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.FilteringWebHandlerInstrumentation
\ No newline at end of file
+spring-cloud-gateway-2.1.x=org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.define.TcpClientInstrumentation
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
index 18f061a99..0e89ed9e4 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
+++ b/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/pom.xml
@@ -28,6 +28,7 @@
optional-spring-cloud
+ gateway-2.0.x-plugingateway-2.1.x-pluginpom
diff --git a/docs/en/guides/Plugin-test.md b/docs/en/guides/Plugin-test.md
index efd3687af..2cf26782e 100644
--- a/docs/en/guides/Plugin-test.md
+++ b/docs/en/guides/Plugin-test.md
@@ -188,7 +188,7 @@ as the version number, it will be changed in the test for every version.
**Take following test cases as examples**
* [dubbo-2.7.x with JVM-container](../../../test/plugin/scenarios/dubbo-2.7.x-scenario/configuration.yml)
* [jetty with JVM-container](../../../test/plugin/scenarios/jetty-scenario/configuration.yml)
-* [gateway with runningMode](../../../test/plugin/scenarios/gateway-scenario/configuration.yml)
+* [gateway with runningMode](../../../test/plugin/scenarios/gateway-2.1.x-scenario/configuration.yml)
* [canal with docker-compose](../../../test/plugin/scenarios/canal-scenario/configuration.yml)
### expectedData.yaml
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 800a30c2c..467e3cd97 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -24,7 +24,7 @@
* [Jetty Client](http://www.eclipse.org/jetty/) 9
* [Apache httpcomponent AsyncClient](https://hc.apache.org/httpcomponents-asyncclient-dev/) 4.x
* HTTP Gateway
- * [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway) 2.1.x.RELEASE (Optional²)
+ * [Spring Cloud Gateway](https://spring.io/projects/spring-cloud-gateway) 2.0.2.RELEASE -> 2.2.x.RELEASE (Optional²)
* JDBC
* Mysql Driver 5.x, 6.x, 8.x
* Oracle Driver (Optional¹)
diff --git a/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml b/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
similarity index 77%
rename from test/plugin/scenarios/gateway-scenario/config/expectedData.yaml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
index 68387a0ed..d3e36787d 100644
--- a/test/plugin/scenarios/gateway-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
@@ -34,8 +34,8 @@ segmentItems:
- {key: url, value: not null}
- {key: http.method, value: GET}
refs:
- - {parentEndpoint: GATEWAY/provider_route, networkAddress: 'localhost:18070',
- refType: CrossProcess, parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
+ - {parentEndpoint: SpringCloudGateway/RoutingFilter, networkAddress: 'localhost:18070',
+ refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
null, parentService: not null, traceId: not null}
skipAnalysis: 'false'
- serviceName: gateway-projectA-scenario
@@ -43,28 +43,7 @@ segmentItems:
segments:
- segmentId: not null
spans:
- - operationName: GATEWAY/provider_route
- operationId: 0
- parentSpanId: -1
- spanId: 0
- spanLayer: Http
- startTime: nq 0
- endTime: nq 0
- componentId: 61
- isError: false
- spanType: Exit
- peer: not null
- tags:
- - {key: url, value: not null}
- - {key: http.method, value: GET}
- refs:
- - {parentEndpoint: WEBFLUX.handle, networkAddress: '', refType: CrossThread,
- parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
- null, parentService: not null, traceId: not null}
- skipAnalysis: 'false'
- - segmentId: not null
- spans:
- - operationName: WEBFLUX.handle
+ - operationName: /provider/b/testcase
operationId: 0
parentSpanId: -1
spanId: 0
@@ -74,9 +53,40 @@ segmentItems:
componentId: 67
isError: false
spanType: Entry
- peer: ''
+ peer: not null
tags:
- {key: url, value: 'http://localhost:8080/provider/b/testcase'}
- {key: http.method, value: GET}
- {key: status_code, value: '200'}
skipAnalysis: 'false'
+ - segmentId: not null
+ spans:
+ - operationName: SpringCloudGateway/sendRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 1
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 61
+ isError: false
+ spanType: Exit
+ peer: 'localhost:18070'
+ tags:
+ - {key: url, value: not null}
+ - {key: status_code, value: '200'}
+ skipAnalysis: 'false'
+ - operationName: SpringCloudGateway/RoutingFilter
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 61
+ isError: false
+ spanType: Local
+ peer: ''
+ refs:
+ - {parentEndpoint: '/provider/b/testcase', networkAddress: '', refType: CrossThread,
+ parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
+ null, parentService: not null, traceId: not null}
+ skipAnalysis: 'false'
diff --git a/test/plugin/scenarios/gateway-scenario/configuration.yml b/test/plugin/scenarios/gateway-2.0.x-scenario/configuration.yml
similarity index 94%
rename from test/plugin/scenarios/gateway-scenario/configuration.yml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/configuration.yml
index 86b0909f6..06d871a13 100644
--- a/test/plugin/scenarios/gateway-scenario/configuration.yml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/configuration.yml
@@ -19,4 +19,4 @@ entryService: http://localhost:8080/provider/b/testcase
healthCheck: http://localhost:8080/provider/b/healthCheck
startScript: ./bin/startup.sh
runningMode: with_optional
-withPlugins: apm-spring-cloud-gateway-2.x-plugin-*.jar
+withPlugins: apm-spring-cloud-gateway-2.0.x-plugin-*.jar
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-dist/bin/startup.sh b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/bin/startup.sh
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-dist/bin/startup.sh
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/bin/startup.sh
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-dist/pom.xml b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/pom.xml
similarity index 97%
rename from test/plugin/scenarios/gateway-scenario/gateway-dist/pom.xml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/pom.xml
index 440a40925..b7284490f 100644
--- a/test/plugin/scenarios/gateway-scenario/gateway-dist/pom.xml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/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
- gateway-scenario
+ gateway-2.0.x-scenario5.0.04.0.0
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/src/main/assembly/assembly.xml
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-dist/src/main/assembly/assembly.xml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-dist/src/main/assembly/assembly.xml
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/pom.xml b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/pom.xml
similarity index 90%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/pom.xml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/pom.xml
index 23935dac2..bdfa254b2 100644
--- a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/pom.xml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-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
- gateway-scenario
+ gateway-2.0.x-scenario5.0.04.0.0
@@ -34,12 +34,6 @@
spring-cloud-starter-gateway${test.framework.version}
-
- org.springframework.boot
- spring-boot-starter-data-redis
- 2.1.2.RELEASE
-
-
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/resources/application.yml b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
similarity index 79%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/resources/application.yml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
index ad477dc0b..da55c58a4 100644
--- a/test/plugin/scenarios/gateway-scenario/gateway-projectA-scenario/src/main/resources/application.yml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
@@ -25,12 +25,3 @@ spring:
uri: http://localhost:18070
predicates:
- Path=/provider/b/*
- filters:
- - name: RequestRateLimiter
- args:
- redis-rate-limiter.replenishRate: 1
- redis-rate-limiter.burstCapacity: 1
- key-resolver: "#{@apiKeyResolver}"
- redis:
- host: 127.0.0.1
- port: 6379
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/pom.xml b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/pom.xml
similarity index 96%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/pom.xml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/pom.xml
index 44e0337cf..e83487af5 100644
--- a/test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/pom.xml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/pom.xml
@@ -20,7 +20,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- gateway-scenario
+ gateway-2.0.x-scenarioorg.apache.skywalking5.0.0
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
diff --git a/test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/resources/application.properties b/test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
similarity index 100%
rename from test/plugin/scenarios/gateway-scenario/gateway-projectB-scenario/src/main/resources/application.properties
rename to test/plugin/scenarios/gateway-2.0.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
diff --git a/test/plugin/scenarios/gateway-scenario/pom.xml b/test/plugin/scenarios/gateway-2.0.x-scenario/pom.xml
similarity index 90%
rename from test/plugin/scenarios/gateway-scenario/pom.xml
rename to test/plugin/scenarios/gateway-2.0.x-scenario/pom.xml
index 69fddf09c..6d4784a43 100644
--- a/test/plugin/scenarios/gateway-scenario/pom.xml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/pom.xml
@@ -22,7 +22,7 @@
4.0.0org.apache.skywalking
- gateway-scenario
+ gateway-2.0.x-scenariopom5.0.0
@@ -31,16 +31,16 @@
gateway-dist
- skywalking-gateway-scenario
+ skywalking-gateway-2.0.x-scenarioUTF-8
- 2.1.1.RELEASE
+ 2.0.2.RELEASE${test.framework.version}
- gateway-scenario
+ gateway-2.0.x-scenarioorg.apache.maven.plugins
diff --git a/test/plugin/scenarios/gateway-scenario/support-version.list b/test/plugin/scenarios/gateway-2.0.x-scenario/support-version.list
similarity index 94%
rename from test/plugin/scenarios/gateway-scenario/support-version.list
rename to test/plugin/scenarios/gateway-2.0.x-scenario/support-version.list
index 71cf2612f..74df4f9ac 100644
--- a/test/plugin/scenarios/gateway-scenario/support-version.list
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/support-version.list
@@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-2.1.2.RELEASE
-2.1.1.RELEASE
-2.1.0.RELEASE
+2.0.2.RELEASE
+2.0.3.RELEASE
+2.0.4.RELEASE
\ No newline at end of file
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
new file mode 100644
index 000000000..d3e36787d
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
@@ -0,0 +1,92 @@
+# 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: gateway-projectB-scenario
+ segmentSize: nq 0
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: /provider/b/testcase
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: nq 0
+ isError: false
+ spanType: Entry
+ peer: ''
+ tags:
+ - {key: url, value: not null}
+ - {key: http.method, value: GET}
+ refs:
+ - {parentEndpoint: SpringCloudGateway/RoutingFilter, networkAddress: 'localhost:18070',
+ refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not
+ null, parentService: not null, traceId: not null}
+ skipAnalysis: 'false'
+- serviceName: gateway-projectA-scenario
+ segmentSize: nq 0
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: /provider/b/testcase
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 67
+ isError: false
+ spanType: Entry
+ peer: not null
+ tags:
+ - {key: url, value: 'http://localhost:8080/provider/b/testcase'}
+ - {key: http.method, value: GET}
+ - {key: status_code, value: '200'}
+ skipAnalysis: 'false'
+ - segmentId: not null
+ spans:
+ - operationName: SpringCloudGateway/sendRequest
+ operationId: 0
+ parentSpanId: 0
+ spanId: 1
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 61
+ isError: false
+ spanType: Exit
+ peer: 'localhost:18070'
+ tags:
+ - {key: url, value: not null}
+ - {key: status_code, value: '200'}
+ skipAnalysis: 'false'
+ - operationName: SpringCloudGateway/RoutingFilter
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 61
+ isError: false
+ spanType: Local
+ peer: ''
+ refs:
+ - {parentEndpoint: '/provider/b/testcase', networkAddress: '', refType: CrossThread,
+ parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not
+ null, parentService: not null, traceId: not null}
+ skipAnalysis: 'false'
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/configuration.yml b/test/plugin/scenarios/gateway-2.1.x-scenario/configuration.yml
new file mode 100644
index 000000000..3ad1df716
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.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/provider/b/testcase
+healthCheck: http://localhost:8080/provider/b/healthCheck
+startScript: ./bin/startup.sh
+runningMode: with_optional
+withPlugins: apm-spring-cloud-gateway-2.1.x-plugin-*.jar
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh
new file mode 100644
index 000000000..0d2867563
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/bin/startup.sh
@@ -0,0 +1,24 @@
+#!/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=gateway-projectA-scenario" ${home}/../libs/gateway-projectA-scenario.jar &
+sleep 1
+
+java -jar ${agent_opts} "-Dskywalking.agent.service_name=gateway-projectB-scenario" ${home}/../libs/gateway-projectB-scenario.jar &
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml
new file mode 100644
index 000000000..7c34ff415
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/pom.xml
@@ -0,0 +1,54 @@
+
+
+
+
+ org.apache.skywalking
+ gateway-2.1.x-scenario
+ 5.0.0
+
+ 4.0.0
+
+ gateway-dist
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ assemble
+ package
+
+ single
+
+
+
+ src/main/assembly/assembly.xml
+
+ ../target/
+
+
+
+
+
+
+
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/src/main/assembly/assembly.xml b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/src/main/assembly/assembly.xml
new file mode 100644
index 000000000..00d04e28e
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-dist/src/main/assembly/assembly.xml
@@ -0,0 +1,46 @@
+
+
+
+
+ zip
+
+
+
+
+ ./bin
+ 0775
+
+
+
+
+
+ ../gateway-projectA-scenario/target/gateway-projectA-scenario.jar
+ ./libs
+ 0775
+
+
+ ../gateway-projectB-scenario/target/gateway-projectB-scenario.jar
+ ./libs
+ 0775
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml
new file mode 100644
index 000000000..09c8e9061
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/pom.xml
@@ -0,0 +1,67 @@
+
+
+
+
+ org.apache.skywalking
+ gateway-2.1.x-scenario
+ 5.0.0
+
+ 4.0.0
+
+ gateway-projectA-scenario
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-gateway
+ ${test.framework.version}
+
+
+
+
+ gateway-projectA-scenario
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.5.9.RELEASE
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+
+ spring-snapshots
+ http://repo.spring.io/snapshot
+
+
+ spring-milestones
+ http://repo.spring.io/milestone
+
+
+
diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/Constants.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
similarity index 62%
rename from apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/Constants.java
rename to test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
index 614b441c5..f39c04564 100644
--- a/apm-sniffer/optional-plugins/optional-spring-plugins/optional-spring-cloud/gateway-2.1.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/cloud/gateway/v21x/context/Constants.java
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/ApiKeyResolver.java
@@ -16,8 +16,17 @@
*
*/
-package org.apache.skywalking.apm.plugin.spring.cloud.gateway.v21x.context;
+package org.apache.skywalking.apm.testcase.sc.gateway.projectA;
-public interface Constants {
- String SPRING_CLOUD_GATEWAY_TRANSMITTER = "spring.cloud.gateway.transmitter";
+import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@Component
+public class ApiKeyResolver implements KeyResolver {
+
+ public Mono resolve(ServerWebExchange exchange) {
+ return Mono.just(exchange.getRequest().getPath().value());
+ }
}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.java
new file mode 100644
index 000000000..513af9e14
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Application.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 org.apache.skywalking.apm.testcase.sc.gateway.projectA;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
new file mode 100644
index 000000000..ee7a1bf3e
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test1Filter.java
@@ -0,0 +1,38 @@
+/*
+ * 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.sc.gateway.projectA;
+
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
+import org.springframework.core.Ordered;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+public class Test1Filter implements GlobalFilter, Ordered {
+ @Override
+ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
+ ServerHttpRequest buildRequest = exchange.getRequest().mutate().build();
+ return chain.filter(exchange.mutate().request(buildRequest).build());
+ }
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
new file mode 100644
index 000000000..62f060411
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/Test2Filter.java
@@ -0,0 +1,39 @@
+/*
+ * 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.sc.gateway.projectA;
+
+import org.springframework.cloud.gateway.filter.GatewayFilterChain;
+import org.springframework.cloud.gateway.filter.GlobalFilter;
+import org.springframework.core.Ordered;
+import org.springframework.http.server.reactive.ServerHttpRequest;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+public class Test2Filter implements GlobalFilter, Ordered {
+
+ @Override
+ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) {
+ ServerHttpRequest buildRequest = exchange.getRequest().mutate().build();
+ return chain.filter(exchange.mutate().request(buildRequest).build());
+ }
+
+ @Override
+ public int getOrder() {
+ return 1;
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
new file mode 100644
index 000000000..b62539353
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectA/TestFilterConfig.java
@@ -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.
+ */
+
+package org.apache.skywalking.apm.testcase.sc.gateway.projectA;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class TestFilterConfig {
+
+ @Bean
+ public Test1Filter test1Filter() {
+ return new Test1Filter();
+ }
+
+ @Bean
+ public Test2Filter test2Filter() {
+ return new Test2Filter();
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
new file mode 100644
index 000000000..da55c58a4
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectA-scenario/src/main/resources/application.yml
@@ -0,0 +1,27 @@
+#
+# 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
+spring:
+ cloud:
+ gateway:
+ routes:
+ - id: provider_route
+ uri: http://localhost:18070
+ predicates:
+ - Path=/provider/b/*
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml
new file mode 100644
index 000000000..40e4bafb7
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/pom.xml
@@ -0,0 +1,57 @@
+
+
+
+
+ gateway-2.1.x-scenario
+ org.apache.skywalking
+ 5.0.0
+
+ 4.0.0
+
+ gateway-projectB-scenario
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 2.1.0.RELEASE
+
+
+
+
+ gateway-projectB-scenario
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 1.5.9.RELEASE
+
+
+
+ repackage
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.java
new file mode 100644
index 000000000..136f0693d
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/Application.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.sc.gateway.projectB;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(value = {"org.apache.skywalking.apm.testcase.sc.gateway.projectB.controller"})
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
new file mode 100644
index 000000000..417c45a10
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/java/org/apache/skywalking/apm/testcase/sc/gateway/projectB/controller/TestController.java
@@ -0,0 +1,36 @@
+/*
+ * 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.sc.gateway.projectB.controller;
+
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class TestController {
+
+ @RequestMapping("/provider/b/testcase")
+ public String testcase() {
+ System.out.println(1);
+ return "1";
+ }
+
+ @RequestMapping("/provider/b/healthCheck")
+ public String healthCheck() {
+ return "Success";
+ }
+}
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
new file mode 100644
index 000000000..cac2c4d5a
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/gateway-projectB-scenario/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+#
+# 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=18070
\ No newline at end of file
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml b/test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml
new file mode 100644
index 000000000..24d02d813
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/pom.xml
@@ -0,0 +1,58 @@
+
+
+
+ 4.0.0
+
+ org.apache.skywalking
+ gateway-2.1.x-scenario
+ pom
+ 5.0.0
+
+ gateway-projectA-scenario
+ gateway-projectB-scenario
+ gateway-dist
+
+
+ skywalking-gateway-2.1.x-scenario
+
+
+ UTF-8
+ 2.0.2.RELEASE
+ ${test.framework.version}
+
+
+
+ gateway-2.1.x-scenario
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.0
+
+ 1.8
+ 1.8
+ ${project.build.sourceEncoding}
+
+
+
+
+
+
diff --git a/test/plugin/scenarios/gateway-2.1.x-scenario/support-version.list b/test/plugin/scenarios/gateway-2.1.x-scenario/support-version.list
new file mode 100644
index 000000000..4e64323f1
--- /dev/null
+++ b/test/plugin/scenarios/gateway-2.1.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.
+
+2.1.2.RELEASE
+2.1.1.RELEASE
+2.1.0.RELEASE
+2.2.0.RELEASE
+2.2.1.RELEASE
+2.2.2.RELEASE
+2.2.3.RELEASE
\ No newline at end of file