By default, a Spring Boot actuator provides the most valuable information for system monitoring, scaling, and evolving over time. Depending on the application configuration, it exposes information about the application executable artifact (service group, artifact ID, artifact name, artifact version, build time) and Git coordinates (branch name, commit ID, commit time). Of course, we may extend this list with additional information, if required.
An actuator displays application information with an /actuator/info endpoint. In general, this endpoint is enabled by default, but its accessibility may be configured by the management.endpoint.info.enabled property.
We may add some custom information exposed over that REST endpoint by configuring the application.property file in the following way:
info: name: "Reactive Spring App" mode: "testing"
service-version: "2.0"
features:
feature-a: "enabled"
feature-b: "disabled"
Alternatively, we may provide similar information programmatically by registering a bean that implements the InfoContributor interface. The following code depicts this capability:
@Component
public class AppModeInfoProvider implements InfoContributor { // (1)
private final Random rnd = new Random();
@Override
public void contribute(Info.Builder builder) { // (2)
boolean appMode = rnd.nextBoolean();
builder
.withDetail("application-mode", // (3)
appMode ? "experimental" : "stable");
}
}
Here, we have to implement an InfoContributor interface (1) with only the contribute(...) (2) method, which provides a builder that can be used to add the required information using the withDetail(...) (3) builder method:
When discussing advanced usage scenarios, an actuator service info endpoint may be leveraged when doing a canary deployment (https://martinfowler.com/bliki/CanaryRelease.html). Here, a load balancer may use the information about the service version to route incoming traffic.
Because a Spring Boot actuator does not provide any reactive or asynchronous APIs for information exposure, a reactive service is not any different than a blocking one.