Service info endpoint

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.

To expose the information collected during the build of the application, we may add the following configuration to the Gradle build file in the springBoot section: buildInfo(). Of course, the same functionality is available for Maven builds. The following article provides more details about this: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-build.

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:

Diagram 10.1. An example of the Canary Deployment pattern. The load balancer routes traffic to service instances, according to their versions

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. 

To learn all details related to Spring Boot Actuator /info endpoint, follow this link: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-application-info.

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.66.185