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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]