在我的一项服务 /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.发布
谢谢,
哈里
基本上health
端点的实现方式是它包含实现该接口的所有 Spring bean 的列表HealthIndicator
.
每个健康指示器负责提供有关一个子系统的健康信息(此类子系统的示例有:disk、postgres、mongo 等),spring boot 附带了一些预定义的 HealthIndicators。
这样当health
端点被调用时,它会迭代此列表并获取有关每个子系统的信息,然后构造答案。
因此,您可以在相关运行状况指标中放置一个断点(假设您知道检查了哪些子系统)并查看会发生什么。
如果您正在寻找 HTTP 入口点 - 当您调用时会调用的代码http://<host-port>/health
(可能会根据您的设置而有所不同,但您明白了)`,可以找到here https://github.com/spring-projects/spring-boot/blob/0ddd1b6ce81a24c14518ef715527aa72b524d7eb/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthEndpoint.java
我想到的另一种方法是禁用“可疑”健康检查并通过消除找到缓慢的检查。
例如,如果您有一个 elasticsearch 并且想要禁用它,请在application.properties
:
management.health.elasticsearch.enabled = false
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)