helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.44k stars 562 forks source link

Health check timeout message should identify which health check timed out #8869

Open tjquinno opened 3 weeks ago

tjquinno commented 3 weeks ago

Environment Details


Problem Description

The Helidon code which responds to /health requests applies a timeout (configurable) when it invokes each health check it finds.

The exception does not identify which health check(s) timed out and it would be helpful to developers if it did.

Steps to reproduce

  1. Start with the MP QuickStart app.
  2. Add this to the microprofile-config.properties file: health.timeout-millis=1000
  3. Add this class to the project:
    @Liveness
    @ApplicationScoped
    public class SlowLivenessCheck implements HealthCheck {
       @Override
       public HealthCheckResponse call() {
           try {
               TimeUnit.SECONDS.sleep(5);
           } catch (InterruptedException e) {
               throw new RuntimeException(e);
           }
           return HealthCheckResponse.named("SlowLivenessCheck")
                   .up()
                   .build();
       }
    }
  4. mvn package -DskipTests
  5. java -jar target/helidon-quickstart-mp.jar
  6. From another window: curl http://localhost:8080/health
  7. In the original window you see this (partial) stack trace, noting the timeout as the problem but not identifying the offending health check:
    2024.06.11 06:32:29 SEVERE io.helidon.health.HealthSupport Thread[#86,ft-mp-schedule-1,10,main]: Failed to call health checks
    java.util.concurrent.TimeoutException