armeria icon indicating copy to clipboard operation
armeria copied to clipboard

HealthCheckService does not return dynamic messages or errors

Open himangi-db opened this issue 2 years ago • 4 comments

A user of the HealthCheckService will often want to see additional information from a healthcheck about why a component is healthy/unhealthy along with an error. However, the HealthChecker interface does not allow for that currently as it has a single (non-static) method boolean isHealthy().

We should support returning a Result object with state (boolean), optional message (string) and optional error (throwable) from a HealthChecker. We would also need to add support for serialisation of the Result to return in the HealthCheckService responses.

himangi-db avatar Jul 15 '22 10:07 himangi-db

I think this is a good idea 👍

Maybe we can add an option at HealthCheckServiceBuilder whether to return a "verbose" health check response. We could make this option exclusive with the HealthCheckServiceBuilder#healthyResponse and HealthCheckServiceBuilder#unhealthyResponse options.

jrhee17 avatar Jul 17 '22 15:07 jrhee17

support returning a Result object with state (boolean), optional message (string) and optional error (throwable)

Curious about the distinction between message and error. I was original thinking message and error would always be returned regardless of whether the health-check response is healthy or not. Does this make sense for your use-case? Or were you expecting error is only included in the health-check response if a health check is unhealthy?

jrhee17 avatar Jul 17 '22 15:07 jrhee17

One option is that the Result contains an Optional error and that is set only when the health check is unhealthy. Another option is that the error is empty ( null) for healthy responses. Both will work for the use-case as the goal is to communicate additional info about the health of a component.

himangi-db avatar Jul 18 '22 03:07 himangi-db

Both will work for the use-case as the goal is to communicate additional info about the health of a component.

I see. Would it also make sense for your use-case if Result just has a single message field in this case? (without the error field)?

jrhee17 avatar Jul 18 '22 03:07 jrhee17