I constructed the web client using the following method.
@Bean
public XXXApiService deeplApiClient(HttpClient httpClient, WebClient.Builder builder) {
WebClient webClient = builder
.baseUrl("XX")
.clientConnector(new ReactorClientHttpConnector(httpClient))
.defaultStatusHandler(
httpStatusCode -> HttpStatus.NOT_FOUND == httpStatusCode,
response -> Mono.empty())
.defaultStatusHandler(
HttpStatusCode::is5xxServerError,
response -> Mono.error(new RuntimeException(response.statusCode().toString())))
.build();
return HttpServiceProxyFactory
.builder(WebClientAdapter.forClient(webClient))
.build()
.createClient(XXXApiService.class);
}
I found that when entering from webflux and directly calling webclient, the trace can be successfully connected.
However, if it is first done in the form of Flux.fromIterable(xx).flatMap(xx -> webClient.xxx), for example. There is no way to connect the entire trace.
So, may I ask how should I go about solving this problem?
Comment From: bclozel
Thanks for getting in touch, but it feels like this is a question that would be better suited to StackOverflow. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: asasas234
I think this is a BUG, as I mentioned above. In a simple scenario, calling the webclient directly from the webflux controller works fine. However, it fails when there is a combination of reactor stream orchestration.
Comment From: asasas234
@bclozel Please reopen it.
Comment From: bclozel
This looks more like a question, which could be more generally useful for the community on StackOverflow. Please create a question there and point us to it so we can have a look. Also join the code snippet showing how the client is used within a controller. Thanks!
Comment From: bclozel
Note: we had regressions around observability in Spring Boot 3.1.6. Does it work with Spring Boot 3.1.5?
Comment From: asasas234
@bclozel I'll give it a try.
Comment From: asasas234
@bclozel Still not working. If it is the following situation, he can work.
@GetMapping("/test")
public Mono<String> test() {
return webclient.xxx()
}
But in the following scenario, it cannot work and can only see the entire monitoring information of the controller. However, the webclient calls inside cannot be seen. I also found that the webclient inside becomes an independent trace but is not associated with the main trace.
@GetMapping("/test")
public Mono<List> test() {
return Flux.fromIterable(xx).flatMap(xx-> webclient.xxx).collectList();
}