简体   繁体   English

普罗米修斯端点中缺少 Spring Boot Webclient 指标

[英]Spring Boot Webclient metrics missing in prometheus endpoint

Http client metrics in Prometheus endpoint is missing while creating the WebClient Manually.手动创建 WebClient 时,Prometheus 端点中的 Http 客户端指标丢失。

Below code is able to generate the expected http client metrics as shown below,下面的代码能够生成预期的 http 客户端指标,如下所示,

@Autowired
WebClient.Builder webClientBuilder;

@GetMapping("client")
public Mono<String> getClientData() {
   return webClientBuilder.baseUrl("http://localhost:8080").build().get().retrieve().bodyToMono(String.class);
}

**Prometheus Metrics**
http_client_requests_seconds_count{clientName="localhost",method="GET",metric1="firstmetric",metric2="secondmetric",outcome="CLIENT_ERROR",status="404",uri="/",} 1.0
  http_client_requests_seconds_sum{clientName="localhost",method="GET",metric1="firstmetric",metric2="secondmetric",outcome="CLIENT_ERROR",status="404",uri="/",} 0.2275663

While creating the WebClient.Builder manually as shown below, the expected metrics(above shown) are missing from Prometheus endpoint.如下所示手动创建 WebClient.Builder 时,Prometheus 端点缺少预期的指标(如上所示)。

@GetMapping("client")
    public Mono<String> getClientData() {
        return WebClient.builder().baseUrl("http://localhost:8080").build().get().retrieve().bodyToMono(String.class);
    }

Is there any solution available to get the metrics without Auto wiring the WebClient or WebClient builder(Have explored about MetricsWebClientFilterFunction, But it seems to be deprecated in recent version of spring boot)?是否有任何解决方案可以在不自动连接 WebClient 或 WebClient 构建器的情况下获取指标(已经探索了 MetricsWebClientFilterFunction,但它似乎在最新版本的 spring boot 中已弃用)?

The preferred way of getting instrumentation right is to indeed use the WebClient.Builder instance provided by Spring Boot.获得正确检测的首选方法是确实使用 Spring Boot 提供的WebClient.Builder实例。

If you don't want that (as a separate question, maybe explain why that choice, maybe there's a way to work around a problem that made you consider that choice), you should in fact wire manually the MetricsWebClientFilterFunction in the client.如果您不想这样做(作为一个单独的问题,也许可以解释为什么要选择该选择,也许有办法解决使您考虑该选择的问题),实际上您应该在客户端中手动连接MetricsWebClientFilterFunction

I'm not seeing any deprecation notice on that class, did I miss anything?我没有看到有关该课程的任何弃用通知,我错过了什么吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM