gpt4 book ai didi

spring-boot - Spring Boot Actuator PoolingHttpClientConnectionManager 指标

转载 作者:行者123 更新时间:2023-12-04 13:56:22 24 4
gpt4 key购买 nike

我们使用 Spring Boot 2 与 Actuator 和 Prometheus 来显示 Grafana 仪表板。我想添加 Apache Http Client PoolingHttpClientConnectionManager 指标来报告连接池统计信息。我看到这已添加到 micrometer-core:1.3.0 ( https://github.com/micrometer-metrics/micrometer/pull/1223 )。但是,我在/actuator/metrics 或/actuator/prometheus 端点中没有看到任何相关的指标。我尝试更新 pom.xml 中的依赖项:

    <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.4.2</version>
</dependency>

应用程序.yml
# Spring Actuator Configuration
management:
endpoint:
health:
show-details: always

endpoints:
web:
exposure:
include: "*"
metrics:
enable:
all: true

/执行器/指标
{
"names": [
"jvm.buffer.memory.used",
"jvm.threads.states",
"tomcat.servlet.error",
"process.uptime",
"jvm.memory.used",
"system.load.average.1m",
"tomcat.servlet.request.max",
"tomcat.cache.hit",
"tomcat.global.request.max",
"tomcat.global.error",
"tomcat.cache.access",
"logback.events",
"jvm.memory.committed",
"tomcat.sessions.active.current",
"jvm.buffer.total.capacity",
"jvm.gc.pause",
"jvm.memory.max",
"system.cpu.usage",
"jvm.threads.live",
"jvm.classes.unloaded",
"tomcat.global.sent",
"jvm.classes.loaded",
"jvm.threads.peak",
"tomcat.threads.config.max",
"tomcat.sessions.rejected",
"tomcat.sessions.alive.max",
"jvm.gc.memory.promoted",
"jvm.buffer.count",
"jvm.gc.memory.allocated",
"tomcat.global.received",
"tomcat.sessions.expired",
"tomcat.sessions.created",
"jvm.gc.max.data.size",
"system.cpu.count",
"tomcat.threads.busy",
"process.start.time",
"jvm.threads.daemon",
"process.files.max",
"tomcat.threads.current",
"tomcat.sessions.active.max",
"tomcat.global.request",
"process.files.open",
"jvm.gc.live.data.size",
"tomcat.servlet.request",
"process.cpu.usage"
]
}

Spring 执行器是否需要支持更改,还是我遗漏了一些配置?任何帮助或建议表示赞赏。

最佳答案

io.micrometer.core.instrument.binder.httpcomponents @Incubating(since = "1.4.0") 
public class MicrometerHttpClientInterceptor
extends Object
Provides HttpRequestInterceptor and HttpResponseInterceptor for configuring with an org.apache.http.nio.client.HttpAsyncClient. Usage example:

MicrometerHttpClientInterceptor interceptor = new MicrometerHttpClientInterceptor(registry,
request -> request.getRequestLine().getUri(),
Tags.empty(),
true);

CloseableHttpAsyncClient httpAsyncClient = HttpAsyncClients.custom()
.addInterceptorFirst(interceptor.getRequestInterceptor())
.addInterceptorLast(interceptor.getResponseInterceptor())
.build();

自从:
1.4.0

关于spring-boot - Spring Boot Actuator PoolingHttpClientConnectionManager 指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61640005/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com