Currently, the /health endpoint returns a 204 when it becomes Ready, which isn't a great indicator of whether the service is healthy or not.
// New creates a HealthCheck with the specified initial state.
func New() *HealthCheck {
hc := &HealthCheck{
state: int32(Unavailable),
mapping: map[Status]int{
Unavailable: http.StatusServiceUnavailable,
Ready: http.StatusNoContent,
},
logger: zap.NewNop(),
}
return hc
}
However, it would be nice to return a 200 and something like:
{"ok":true,"status":"up"} or even {"uptime":1h20m}, etc.
I can probably tackle this when I get some time.
We indicate the status via HTTP status code, but I don't mind returning it in JSON as well. And I like the idea of uptime, so:
{
"status": "unavailable"
}
{
"status": "up",
"uptime": "1h20m"
}
The initial idea was to indeed return some content, like the status of the connection to the backing storage, but we never ended up doing that.
Uptime is indeed something we can return right now. Perhaps another field indicating when it has started could also be helpful? Parsing 2019-04-03T09:31:07+02:00 is usually easier (and more accurate) than the uptime.
Most helpful comment
We indicate the status via HTTP status code, but I don't mind returning it in JSON as well. And I like the idea of uptime, so: