The next vital part of successfully monitoring the application is through operational metrics gathering. Of course, a Spring Boot actuator covers this aspect too and provides monitoring for basic JVM characteristics such as the process uptime, memory usage, CPU usage, and GC pauses. Furthermore, WebFlux provides some statistics regarding the processing of incoming HTTP requests. However, to provide a meaningful insight into what is going on in the service from a business standpoint, we have to extend operational metrics on our own.
Starting with Spring Boot 2.0, an actuator changed an underlying library used for metrics gathering and now uses a micrometer library: https://micrometer.io.
If exposed, the /actuator/metrics REST endpoint provides a list of tracked metrics and makes it possible to navigate to a desired gauge or timer, also giving additional contextual information in the form of tags. A summary for one metric, let's say jvm.gc.pause, may look the following way:
{
"name": "jvm.gc.pause",
"measurements": [
{
"statistic": "COUNT",
"value": 5
},
{
"statistic": "TOTALTIME",
"value": 0.347
}
],
"availableTags": [
{
"tag": "cause",
"values": [
"Heap Dump Initiated GC",
"Metadata GC Threshold",
"Allocation Failure"
]
}
]
}
One drawback of the new metrics endpoint, when compared to its Spring Boot 1.x counterpart, is the inability to retrieve all the tracked metric summaries with a single REST request. However, this is probably only a minor issue.
As usual, we are free to register new metrics using a micrometer metrics registry. Later in this chapter, we will cover the mechanics of this process and will see what operational metrics are useful for the reactive application.