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 2021/08/10 13:07:54 UTC

[GitHub] [skywalking] kin122 opened a new issue #7434: how to implement asynchronous tracking of the webclient in WebFlux.

kin122 opened a new issue #7434:
URL: https://github.com/apache/skywalking/issues/7434


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ * ] Question or discussion
   - [ ] Bug
   - [ ] Requirement
   - [ ] Feature or performance improvement
   
   ___
   ### Question
   - What do you want to know?
   hi ,Mr Wu.
   We want to implement asynchronous tracking of the webclient in WebFlux.
   So we try to modify the WebFluxWebClientInterceptor in spring-webflux-5.x-webclient-plugin.
   The code is as follows:
   ```
   public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInvocationContext context) throws Throwable {
           if (allArguments[0] == null) {
               //illegal args,can't trace ignore
               return;
           }
          // ################# here are the code we injected###########################
           LOGGER.info("getSkyWalkingDynamicField-------------{}", objInst.getSkyWalkingDynamicField());
           for (int i = 0; i < allArguments.length; i++) {
               LOGGER.info("----allArguments[{}]-----{}---------", i, allArguments[i]);
           }
           ClientRequest request = (ClientRequest) allArguments[0];
           final ContextCarrier contextCarrier = new ContextCarrier();
   
           URI uri = request.url();
           final String requestURIString = getRequestURIString(uri);
           final String operationName = requestURIString;
           final String remotePeer = getIPAndPort(uri);
           AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer);
   
           //set components name
           span.setComponent(ComponentsDefine.SPRING_WEBCLIENT);
           Tags.URL.set(span, uri.toString());
           Tags.HTTP.METHOD.set(span, request.method().toString());
           SpanLayer.asHttp(span);
   
           if (request instanceof EnhancedInstance) {
               ((EnhancedInstance) request).setSkyWalkingDynamicField(contextCarrier);
           }
   
           //user async interface
           span.prepareForAsync();
           ContextManager.stopSpan();
   
           context.setContext(span);
       }
   ```
   We would like to use objInst.getSkyWalkingDynamicField() to get the traceid, but always get null.
   
   May I ask if this method is feasible to get the traceid of the webclient ?
    Or give me some suggestion,please.
   
   
   
   ___
   ### Bug
   - Which version of SkyWalking, OS, and JRE?
   - skywalking8.7.0
   
   - Which company or project?
   
   - What happened?
   If possible, provide a way to reproduce the error. e.g. demo application, component version.
   
   ___
   ### Requirement or improvement
   - Please describe your requirements or improvement suggestions.
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] youzhagui2006 commented on issue #7434: how to implement asynchronous tracking of the webclient in WebFlux.

Posted by GitBox <gi...@apache.org>.
youzhagui2006 commented on issue #7434:
URL: https://github.com/apache/skywalking/issues/7434#issuecomment-942971312


   > Please answer these questions before submitting your issue.
   > 
   > * Why do you submit this issue?
   > * [ * ] Question or discussion
   > 
   > ### Question
   > * What do you want to know?
   >   hi ,Mr Wu.
   >   We want to implement asynchronous tracking of the webclient in WebFlux.
   >   So we try to modify the WebFluxWebClientInterceptor in spring-webflux-5.x-webclient-plugin.
   >   The code is as follows:
   > 
   > ```
   > public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInvocationContext context) throws Throwable {
   >         if (allArguments[0] == null) {
   >             //illegal args,can't trace ignore
   >             return;
   >         }
   >        // ################# here are the code we injected###########################
   >         LOGGER.info("getSkyWalkingDynamicField-------------{}", objInst.getSkyWalkingDynamicField());
   >         for (int i = 0; i < allArguments.length; i++) {
   >             LOGGER.info("----allArguments[{}]-----{}---------", i, allArguments[i]);
   >         }
   >         ClientRequest request = (ClientRequest) allArguments[0];
   >         final ContextCarrier contextCarrier = new ContextCarrier();
   > 
   >         URI uri = request.url();
   >         final String requestURIString = getRequestURIString(uri);
   >         final String operationName = requestURIString;
   >         final String remotePeer = getIPAndPort(uri);
   >         AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer);
   > 
   >         //set components name
   >         span.setComponent(ComponentsDefine.SPRING_WEBCLIENT);
   >         Tags.URL.set(span, uri.toString());
   >         Tags.HTTP.METHOD.set(span, request.method().toString());
   >         SpanLayer.asHttp(span);
   > 
   >         if (request instanceof EnhancedInstance) {
   >             ((EnhancedInstance) request).setSkyWalkingDynamicField(contextCarrier);
   >         }
   > 
   >         //user async interface
   >         span.prepareForAsync();
   >         ContextManager.stopSpan();
   > 
   >         context.setContext(span);
   >     }
   > ```
   > 
   > We would like to use objInst.getSkyWalkingDynamicField() to get the traceid, but always get null.
   > 
   > May I ask if this method is feasible to get the traceid of the webclient ? Or give me some suggestion,please.
   
   请问你解决没?我也碰到了


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng commented on issue #7434: how to implement asynchronous tracking of the webclient in WebFlux.

Posted by GitBox <gi...@apache.org>.
wu-sheng commented on issue #7434:
URL: https://github.com/apache/skywalking/issues/7434#issuecomment-896078938


   I don't know what is `objInst.getSkyWalkingDynamicField()` to get `traceid`. All values in it are set by the plugin itself. From the codes, it is used for contextCarrier. 
   Our doc is very clear, your question doesn't make sense.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] youzhagui2006 removed a comment on issue #7434: how to implement asynchronous tracking of the webclient in WebFlux.

Posted by GitBox <gi...@apache.org>.
youzhagui2006 removed a comment on issue #7434:
URL: https://github.com/apache/skywalking/issues/7434#issuecomment-942971312


   > Please answer these questions before submitting your issue.
   > 
   > * Why do you submit this issue?
   > * [ * ] Question or discussion
   > 
   > ### Question
   > * What do you want to know?
   >   hi ,Mr Wu.
   >   We want to implement asynchronous tracking of the webclient in WebFlux.
   >   So we try to modify the WebFluxWebClientInterceptor in spring-webflux-5.x-webclient-plugin.
   >   The code is as follows:
   > 
   > ```
   > public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInvocationContext context) throws Throwable {
   >         if (allArguments[0] == null) {
   >             //illegal args,can't trace ignore
   >             return;
   >         }
   >        // ################# here are the code we injected###########################
   >         LOGGER.info("getSkyWalkingDynamicField-------------{}", objInst.getSkyWalkingDynamicField());
   >         for (int i = 0; i < allArguments.length; i++) {
   >             LOGGER.info("----allArguments[{}]-----{}---------", i, allArguments[i]);
   >         }
   >         ClientRequest request = (ClientRequest) allArguments[0];
   >         final ContextCarrier contextCarrier = new ContextCarrier();
   > 
   >         URI uri = request.url();
   >         final String requestURIString = getRequestURIString(uri);
   >         final String operationName = requestURIString;
   >         final String remotePeer = getIPAndPort(uri);
   >         AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, remotePeer);
   > 
   >         //set components name
   >         span.setComponent(ComponentsDefine.SPRING_WEBCLIENT);
   >         Tags.URL.set(span, uri.toString());
   >         Tags.HTTP.METHOD.set(span, request.method().toString());
   >         SpanLayer.asHttp(span);
   > 
   >         if (request instanceof EnhancedInstance) {
   >             ((EnhancedInstance) request).setSkyWalkingDynamicField(contextCarrier);
   >         }
   > 
   >         //user async interface
   >         span.prepareForAsync();
   >         ContextManager.stopSpan();
   > 
   >         context.setContext(span);
   >     }
   > ```
   > 
   > We would like to use objInst.getSkyWalkingDynamicField() to get the traceid, but always get null.
   > 
   > May I ask if this method is feasible to get the traceid of the webclient ? Or give me some suggestion,please.
   
   请问你解决没?我也碰到了


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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



[GitHub] [skywalking] wu-sheng closed issue #7434: how to implement asynchronous tracking of the webclient in WebFlux.

Posted by GitBox <gi...@apache.org>.
wu-sheng closed issue #7434:
URL: https://github.com/apache/skywalking/issues/7434


   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

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