We've created a custom health check and also added custom info about our app. Another useful strategy will be to create some custom metrics. In previous chapters, we saw how Spring Boot's Actuator comes with some out-of-the-box counters and gauges for web activity. For this section, let's count the flow of messages through the system.
Earlier in this chapter, we coded a simulator that would generate events periodically. The following fragment shows an updated version of that constructor to support metrics:
final private JmsTemplate jmsTemplate; final private String destination; final private CounterService counterService; public NetworkEventSimulator(JmsTemplate jmsTemplate, String destination, CounterService counterService) { this.jmsTemplate = jmsTemplate; this.destination = destination; this.counterService = counterService; }
This constructor adds Spring Boot's org.springframework.boot.actuate.metrics...