在我的服务/actuator/health 端点之一中花费了更多时间(大约 9 秒)。我正在使用以下依赖项,如何调试它?
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
使用的Spring boot版本: 2.0.3.RELEASE
谢谢, 哈里
最佳答案
基本上health
端点的实现方式是它包含实现接口(interface) HealthIndicator
的所有 Spring bean 的列表。 .
每个健康指标负责提供一个关于一个子系统的健康信息(此类子系统的例子有:disk、postgres、mongo 等),spring boot 带有一些预定义的 HealthIndicators。
所以当health
调用端点时,它会遍历此列表并获取有关每个子系统的信息,然后构造答案。
因此,您可以在相关的健康指标中放置一个断点(假设您知道检查了哪些子系统),然后看看会发生什么。
如果您正在寻找 HTTP 入口点 - 当您调用 http://<host-port>/health
时调用的代码(可能会因您的设置而异,但您明白了)`,它可以在 here 中找到
想到的另一种方法是禁用“可疑的”健康检查并通过消除找到慢的。
例如,如果您有一个 elastricsearch 并想禁用它,请在 application.properties
中使用:
management.health.elasticsearch.enabled = false
关于 Spring Boot 2 : actuator/health endpoint is taking more time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63665192/