You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2021/04/04 12:01:24 UTC

[skywalking] branch master updated: Fix spanLayer is null in optional plugin(gateway-2.0.x-plugin gateway-2.1.x-plugin) (#6683)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/master by this push:
     new 776f19c  Fix spanLayer is null in optional plugin(gateway-2.0.x-plugin gateway-2.1.x-plugin) (#6683)
776f19c is described below

commit 776f19c702a52830f1ae9a2b9b82d218f6fc5c3c
Author: liqiangz <li...@gmail.com>
AuthorDate: Sun Apr 4 20:01:06 2021 +0800

    Fix spanLayer is null in optional plugin(gateway-2.0.x-plugin gateway-2.1.x-plugin) (#6683)
---
 CHANGES.md                                                             | 1 +
 .../plugin/spring/cloud/gateway/v20x/HttpClientRequestInterceptor.java | 3 ++-
 .../spring/cloud/gateway/v21x/HttpClientFinalizerSendInterceptor.java  | 3 ++-
 test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml  | 1 +
 test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml  | 1 +
 5 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 75e24e0..874566c 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -31,6 +31,7 @@ Release Notes.
 * Fix NullPointerException with `ReactiveRequestHolder.getHeaders`.
 * Fix springmvc reactive api can't collect HTTP statusCode.
 * Fix bug that asynchttpclient plugin does not record the response status code
+* Fix spanLayer is null in optional plugin(gateway-2.0.x-plugin gateway-2.1.x-plugin).
 
 #### OAP-Backend
 * Allow user-defined `JAVA_OPTS` in the startup script.
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
index 8509eb6..e055979 100644
--- 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
@@ -26,6 +26,7 @@ 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;
@@ -52,7 +53,7 @@ public class HttpClientRequestInterceptor implements InstanceMethodsAroundInterc
             "SpringCloudGateway/sendRequest", contextCarrier, getPeer(url));
         abstractSpan.prepareForAsync();
         Tags.URL.set(abstractSpan, String.valueOf(allArguments[1]));
-
+        abstractSpan.setLayer(SpanLayer.HTTP);
         abstractSpan.setComponent(SPRING_CLOUD_GATEWAY);
         ContextManager.stopSpan(abstractSpan);
 
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
index c1da2bc..c8fe43c 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/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
@@ -25,6 +25,7 @@ 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;
@@ -53,7 +54,7 @@ public class HttpClientFinalizerSendInterceptor implements InstanceMethodsAround
             Tags.URL.set(abstractSpan, enhanceObjectCache.getUrl());
             abstractSpan.prepareForAsync();
             abstractSpan.setComponent(SPRING_CLOUD_GATEWAY);
-
+            abstractSpan.setLayer(SpanLayer.HTTP);
             ContextManager.stopSpan(abstractSpan);
             ContextManager.stopSpan(span);
 
diff --git a/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
index d3e3678..bdc66a3 100644
--- a/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/gateway-2.0.x-scenario/config/expectedData.yaml
@@ -65,6 +65,7 @@ segmentItems:
       operationId: 0
       parentSpanId: 0
       spanId: 1
+      spanLayer: Http
       startTime: nq 0
       endTime: nq 0
       componentId: 61
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
index d3e3678..bdc66a3 100644
--- a/test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
+++ b/test/plugin/scenarios/gateway-2.1.x-scenario/config/expectedData.yaml
@@ -65,6 +65,7 @@ segmentItems:
       operationId: 0
       parentSpanId: 0
       spanId: 1
+      spanLayer: Http
       startTime: nq 0
       endTime: nq 0
       componentId: 61