Chuck Norris for Spring Boot Actuator

Chuck Norris for Spring Boot Actuator

0 Comments

Last Updated on October 21, 2024 by jt

In case you’ve been living under a rock for the last couple years, Spring Boot Actuator is an awesome set of tools for monitoring and managing your Spring Boot applications. Spring Boot Actuator exposes information via ‘endpoints’. One of the Spring Boot Actuator endpoints is an information endpoint, which is available at the ‘/info’ url from the root of your application.

The information URL is intended to give you basic information about your application.

Typical uses of the information end point from Spring Boot Actuator is to provide git check-in information or build information. I go in-depth on setting these up in my on-line course on Spring Boot Actuator.

Spring Boot Information Contributors

Another feature in Spring Boot Actuator is to provide custom information contributors. The implementation of a custom information provider is fairly simple. Just provide a Spring Bean which implements the InformationContributor interface. Once your custom Spring Bean is wired into your Spring Context, Spring Boot will automatically include its output on the info endpoint.

I’m sure the Spring team had visions of the info endpoint being used to emit information about the OS version, build information, or other application information.

You know – serious stuff!

How boring!

As part of my Spring Boot Actuator course, I have my students implement a custom information contributor. In building the course, I wanted to use something fun for my students to implement. The enterprise stuff can get stuffy and boring.

Introducing Chuck Norris for Spring Boot Actuator

Shamelessly inspired by the Chuck Norris plugin for Jenkins, I thought why not write a Chuck Norris information contributor for Spring Boot Actuator?

Chuck Norris Approves Spring Boot

Chuck Norris for Spring Boot Actuator is a simple implementation of a custom information contributor. The initial release has roughly 125 Chuck Norris sayings. Every time the information endpoint is accessed, a Chuck Norris saying is randomly selected from the list.

Installation & Usage

Dependencies

Maven

<dependency>
    <groupId>guru.springframework</groupId>
    <artifactId>chuck-norris-for-actuator</artifactId>
    <version>0.0.2</version>
</dependency>

Gradle

compile group: 'guru.springframework', name: 'chuck-norris-for-actuator', version: '0.0.2'

Spring Configuration

To configure Spring Boot Actuator to use the Chuck Norris Information Contributor, you will need to add the ChuckNorrisInfoContributor to your Spring Context. Below is an example Java configuration bean, you can add to your Spring Boot project.

@Configuration
public class ChuckNorrisConfig {

    @Bean
    public ChuckNorrisInfoContributor chuckNorrisInfoContributor(){
        return new ChuckNorrisInfoContributor();
    }
}

Usage

Once configured, simply start your Spring Boot Application and navigate to the info endpoint (http://localhost:8080/info). You should see a Chuck Norris message.

{
   "Chuck Norris" : "Maslow's theory of higher needs does not apply to Chuck Norris. He only has two needs: killing people and finding people to kill."
 }

Spring Boot Actuator Course

Do you want to learn more about Spring Boot Actuator?

Spring Boot ActuatorSource Code

The source code is open source and available here on Github.

Contribute

Got a favorite Chuck Norris quote you want to add?

Fork my project on Github, add it and send me a pull request!

I’ll periodically make new releases to include more Chuck Norris quotes.

Chuck Norris Doesn't Write Code for Spring Boot Actuator

About jt

    You May Also Like

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.