WebClient + Spring Sleuth

Viewed 31

im trying to use webclient to make my requests but im not getting the sleuth headers. I created a Bean to make my clients but i gotta be doing something wrong 'cause its not working.

This is my class with a bean to return a webclient:

@Component
public class WebClientUtil {

  @Bean
  public WebClient webClientBuilder() {
    
      return WebClient.builder()
          .baseUrl("https://httpbin.org/get")
          .clientConnector(new ReactorClientHttpConnector(HttpClient.create().responseTimeout(Duration.ofSeconds(CUSTOM_TIMEOUT))))
          .build();
  }
}

I make the calls like this:

@Component
@Slf4j
public class CallTester {

    @Autowired
    private WebClientUtil webClientUtil;

    public void teste() {
        
     log.info(webClientUtil.webClientBuilder().get()
        .retrieve().bodyToMono(String.class).block());
        
    }
}

But the return is this:

{
    "args": {},
    "headers": {
        "Accept": "*/*",
        "Host": "httpbin.org",
        "User-Agent": "ReactorNetty/1.0.19",
        "X-Amzn-Trace-Id": "Root=1-632b20ad-6dfb5c9d30f0433158a6b8b2"
    },
    "url": "https://httpbin.org/get"
}
0 Answers
Related