Using Micrometer to trace your Spring Boot app
If there’s one thing that eventually sneaks up on you after building and releasing an application, it’s that something breaks. Yup, applications break and not long after, our manager is asking, “What happened?”
That’s not the only thing we encounter in the Land of Production. We also sometimes see performance degrade. Certain parts of our system seem bogged down. And once again, the question arises, “What’s going on?”
This is what tracing affords us. A means to trace an operation through our application combined with metrics showing us what’s eating up all the time. And for this we turn to Micrometer.
Micrometer, launched in 2017 by the Spring team, it a metrics facade. It supports a whole host of tools, but for today we’ll use the open source distributed tracing system Zipkin.
Setting up a Spring Boot 3 application
Do you already have a Spring Boot 3 app you’d like to instrument? Great! You can skip on to the next section. In case you don’t, you’ll want to file some very simple steps.
- Visit https://start.spring.io
- Pick your favorite build tool. (I’ll be using Maven).
- Pick the latest version of Spring Boot 3. (I’ll be using 3.0.0-SNAPSHOT).
- Just leave the project metadata as is.
- From the dependencies panel on the right, pick Spring Web and Actuator