在 Spring 执行器中:HealthEndPoint.health() 是否给出与调用 /health 端点相同的结果?
in Spring actuator: does HealthEndPoint.health() give the same result as calling /health endpoint?
我有一个 Spring 引导 (2.1.10.RELEASE) 应用程序,我已经激活执行器来监控应用程序的运行状况。我在标题中的问题已经解释过了:调用 HealthEndPoint 的方法 health 将给出与调用 e.g. 相同的结果http://localhost:8080/health?还是后者会检查更多我不知道的东西?
是的,状态结果将相同,但您可以通过创建自定义运行状况指示器来自定义详细信息以执行某些特定的运行状况检查
自定义执行器运行状况端点
@Override
public Health health() {
int errorCode = check(); // perform some specific health check
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build();
}
我有一个 Spring 引导 (2.1.10.RELEASE) 应用程序,我已经激活执行器来监控应用程序的运行状况。我在标题中的问题已经解释过了:调用 HealthEndPoint 的方法 health 将给出与调用 e.g. 相同的结果http://localhost:8080/health?还是后者会检查更多我不知道的东西?
是的,状态结果将相同,但您可以通过创建自定义运行状况指示器来自定义详细信息以执行某些特定的运行状况检查
自定义执行器运行状况端点
@Override
public Health health() {
int errorCode = check(); // perform some specific health check
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build();
}