Micrometer Tracing with Spring Boot 3 in a Monolithic Application

Swathi Prasad
5 min readApr 12

Instrument your application code with a vendor-neutral interface.

Photo by Luke Chesser on Unsplash

Micrometer provides a simple tracing facade which allows to instrument JVM-based applications for monitoring performance and debugging errors. This tracing information can be sent to the popular monitoring systems for visualization.

For Spring Boot versions below 3.x, we need to use Spring Cloud Sleuth module for tracing applications. This provides a layer over Tracer library called Brave. Starting from version 3.x, the API code from Sleuth has been migrated to Micrometer Tracing.

Micrometer tracing comes with two bridges: Brave and OpenTelemetry. We need to choose a tracer bridge to handle the lifecycle of a span. Span is nothing but a logical operation within a trace. Trace is a user request or a transaction in an application. More details on Span lifecycle can be found here.

Let’s create a sample application and explore these capabilities.

Adding Maven dependencies

Create a Spring Boot application with version 3.x and add the following dependencies.

Let’s add Micrometer dependency under dependency management tag.

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bom</artifactId>
<version>1.0.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

We are going to choose the bridge Brave for this example. Let’s add the dependency.

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>

We need to add Spring Boot Actuator dependency to use Micrometer with our application. Spring Boot Actuator provides a set of monitoring and management features such as the ability to expose health and other metrics of the application.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Log pattern

Swathi Prasad

Software architect and developer living in Germany. Sharing my opinion and what I learn.