Hands-On Enterprise Java Microservices with Eclipse MicroProfile
上QQ阅读APP看书,第一时间看更新

Human operators

The primary use case for the JSON response payload is to provide a way for operators to investigate the application state. To support this, health checks allow for additional data to be attached to a health check response as we have seen in the CheckDiskspace and ServiceCheck examples. Consider the following fragment:

[...]
return HealthCheckResponse
.named("memory-check")
.withData("free-heap", "64mb")
.up()
.build();
[...]

Here, the additional information about free-heap is provided and will become part of the response payload, as shown in this response fragment. The JSON response fragment showing memory-check procedure content is as follows:

{
...
"checks": [
{
"name": "memory-check",
"state": "UP",
"data": {
"free-heap": "64mb"
}
}
],
"outcome": "UP"
}

Here, we see the memory-check procedure with its UP state and additional free-heap data item of the string type with the value of 64mb.

Eclipse resources/GitHub coordinates for MP-Health:
The MP-Health project source code can be found at  https://github.com/eclipse/microprofile-health.