Spring Boot 指标 http.client.requests 不适用于 WebClient 反应式应用程序

Min*_*Liu 5 webclient spring-boot reactive

我有一个 Spring Boot 2.2.2 微服务,它使用 WebClient (retive) 与其他服务集成。根据 Spring 文档,执行器应该默认返回“http.client.requests”指标,因为计时器默认启用。但这对我不起作用。我能够获取 http.server.requests”指标。

我的 WebClient 是一个使用 WebClient.builder() 配置和构建的 bean,如下所示:https: //docs.spring.io/spring-boot/docs/current/reference/html/product-ready-features.html#product -ready-metrics-http-clients

wpn*_*ris 6

使用 Spring Boot 的预配置WebClient.Builder而不是WebClient.builder()拥有WebClient.

您可以在这里找到更多详细信息。

如下所示,您可以拥有一个WebClient.

@Configuration
public class ClientConfiguration {

    @Bean
    public WebClient webClient(WebClient.Builder webClientBuilder) {
        return webClientBuilder
                .baseUrl("https://example.org")
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

WebClient.Builder是自动配置,意味着上面的注入点将接收新克隆的构建器实例。

是来源WebClientAutoConfiguration