You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ta...@apache.org on 2019/05/06 09:35:50 UTC

[skywalking] branch fix_webflux updated: fix

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

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


The following commit(s) were added to refs/heads/fix_webflux by this push:
     new bc3cb49  fix
bc3cb49 is described below

commit bc3cb497be0dcf34376355aa54bc09c90e91494f
Author: Jared.Tan <ji...@daocloud.io>
AuthorDate: Mon May 6 17:32:07 2019 +0800

    fix
---
 .../apm/plugin/spring/webflux/v5/StatusInterceptor.java      | 12 +++++++++---
 .../v5/define/HttpServerOperations20xInstrumentation.java    |  3 +--
 .../v5/define/HttpServerOperations21xInstrumentation.java    |  5 ++---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/StatusInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/StatusInterceptor.java
index e271765..5edc770 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/StatusInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/StatusInterceptor.java
@@ -29,10 +29,16 @@ public class StatusInterceptor implements InstanceMethodsAroundInterceptor {
     @Override
     public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
         MethodInterceptResult result) throws Throwable {
-        HttpResponseStatus status = (HttpResponseStatus)allArguments[0];
-        if (status.code() > 400) {
+        int code;
+        if (allArguments[0] instanceof Integer) {
+            code = (Integer)allArguments[0];
+        } else {
+            HttpResponseStatus status = (HttpResponseStatus)allArguments[0];
+            code = status.code();
+        }
+        if (code > 400) {
             ContextManager.activeSpan().errorOccurred();
-            Tags.STATUS_CODE.set(ContextManager.activeSpan(), String.valueOf(status.code()));
+            Tags.STATUS_CODE.set(ContextManager.activeSpan(), String.valueOf(code));
         }
     }
 
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java
index bd26e37..fa70cd3 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations20xInstrumentation.java
@@ -25,7 +25,6 @@ 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 net.bytebuddy.matcher.ElementMatchers.takesArguments;
 import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
 import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
 
@@ -48,7 +47,7 @@ public class HttpServerOperations20xInstrumentation extends ClassInstanceMethods
         return new InstanceMethodsInterceptPoint[] {
             new InstanceMethodsInterceptPoint() {
                 @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
-                    return named("status").and(takesArguments(1));
+                    return named("status").and(takesArgumentWithType(0, "io.netty.handler.codec.http.HttpResponseStatus"));
                 }
 
                 @Override public String getMethodsInterceptor() {
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java
index 3d19bbe..83efc53 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/webflux-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/webflux/v5/define/HttpServerOperations21xInstrumentation.java
@@ -25,7 +25,6 @@ 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 net.bytebuddy.matcher.ElementMatchers.takesArguments;
 import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
 import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
 
@@ -48,7 +47,7 @@ public class HttpServerOperations21xInstrumentation extends ClassInstanceMethods
         return new InstanceMethodsInterceptPoint[] {
             new InstanceMethodsInterceptPoint() {
                 @Override public ElementMatcher<MethodDescription> getMethodsMatcher() {
-                    return named("status").and(takesArguments(1));
+                    return named("status").and(takesArgumentWithType(0, "io.netty.handler.codec.http.HttpResponseStatus"));
                 }
 
                 @Override public String getMethodsInterceptor() {
@@ -104,4 +103,4 @@ public class HttpServerOperations21xInstrumentation extends ClassInstanceMethods
     @Override protected ClassMatch enhanceClass() {
         return byName("reactor.netty.http.server.HttpServerOperations");
     }
-}
\ No newline at end of file
+}