dropwizard / dropwizard-health

Provides a health check implementation that performs ongoing monitoring of an application's dependencies and includes an endpoint that can be called by a load balancer to determine if the application is healthy and thus able to receive traffic.
Apache License 2.0
18 stars 6 forks source link

Allow to add customizable health check statuses #38

Closed essobedo closed 2 years ago

essobedo commented 4 years ago

Up to now, we have only two possible health check statuses that are currently supported which are healthy and unhealthy. The idea behind this improvement would be to add more (customizable) heath check statuses, like for example:

Within the context of this improvement, it could also be interesting to be able to configure for each health check status which http status code we would like to use as response of HealthCheckServlet#doGet.

essobedo commented 4 years ago

@mzamani1 @joschi Hi, please tell me if this feature is clear enough and makes sense to you and if so and if you wish, I could contribute to add this feature to the project.

natalie-zamani commented 4 years ago

Hey @essobedo, thanks for the issue, and apologies it took me so long to get back to you. This should already be possible if you provide a custom health check servlet to use instead of the default one that comes with the library (specifically, you would override this method: https://github.com/dropwizard/dropwizard-health/blob/master/src/main/java/io/dropwizard/health/core/HealthCheckBundle.java#L101-L113)

Does this work for your needs, or were you thinking more enhancing the default behavior to include more statuses out of the box?

natalie-zamani commented 4 years ago

One potentially related issue would be: https://github.com/dropwizard/dropwizard-health/issues/2, and getting better out of the box support for the concept of liveness and readiness checks, as they exist in Kubernetes.

essobedo commented 4 years ago

@mzamani1 thank you for your feedback and happy new year by the way! Unless I miss something, if I override the method that you mention, I will only have AtomicBoolean isHealthy so 2 possible values true for healthy or false for unhealthy. At this point, I won't be able to know if at least one non critical dependency was unhealthy to be able to raise the intermediate state warn. Did I miss something?

natalie-zamani commented 4 years ago

I see, so what you’re envisioning would require more health state than the Boolean flag.

If you’d like to submit a PR, or let me know more details about what you’re thinking in terms of implementation, I’d definitely be open to that.