You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/12/02 03:46:25 UTC

[GitHub] [skywalking] haoyann commented on issue #5905: skywalking 8.3 add springmvc plugin reactive api support , but that cant collect HTTP statusCode

haoyann commented on issue #5905:
URL: https://github.com/apache/skywalking/issues/5905#issuecomment-736971167


   org.apache.skywalking.apm.plugin.spring.mvc.commons.interceptor.AbstractMethodInterceptor add code 
   ```
       private static final String REACTIVE_RESPONSE_CLASS = "org.springframework.http.server.reactive.ServerHttpResponse";
       private static final String REACTIVE_GET_STATUS_METHOD = "getStatusCode";
   
       static {
           IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(
               AbstractMethodInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD)
           ||  MethodUtil.isMethodExist(
                   AbstractMethodInterceptor.class.getClassLoader(), REACTIVE_RESPONSE_CLASS, REACTIVE_GET_STATUS_METHOD)
           ;
       }
   ```
   if want collect all statusCode change 
   ```
                   if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.statusCode() >= 400) {
                       span.errorOccurred();
                       Tags.STATUS_CODE.set(span, Integer.toString(response.statusCode()));
                   }
   ```
   
   ```
                   if (IS_SERVLET_GET_STATUS_METHOD_EXIST) {
                      if(response.statusCode() >= 400){
                          span.errorOccurred();
                      }
                   
                       Tags.STATUS_CODE.set(span, Integer.toString(response.statusCode()));
                   }
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org