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/10/14 05:34:16 UTC

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

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