spring,

Learn Spring Boot 3 with Micrometer

Cui Cui Follow Jul 23, 2023 · 1 min read
Learn Spring Boot 3 with Micrometer
Share this

“Whatever”. -referenced from here

Tracing

GitHub Copilot: I apologize for the confusion. Spring Boot 3 is not yet released, so there is no official documentation or support for it at this time. However, you can still use Micrometer with Spring Boot 2 to achieve similar functionality.

To set up Micrometer with Spring Boot 2, you can follow these steps:

  1. Add the Micrometer dependency to your project’s pom.xml file:
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-tracing-bridge-brave</artifactId>
</dependency>
<dependency>
    <groupId>io.zipkin.reporter2</groupId>
    <artifactId>zipkin-reporter-brave</artifactId>
</dependency>
  1. Add the Spring Boot Actuator dependency to your project’s pom.xml file:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-aop</artifactId>
</dependency>
  1. Configure Micrometer in your application.properties file:
management.metrics.export.tracing.enabled=true
  1. Configure your tracing system. For example, if you’re using Jaeger, you can add the following properties to your application.properties file:
opentracing.jaeger.enabled=true
opentracing.jaeger.udp-sender.host=localhost
opentracing.jaeger.udp-sender.port=6831
  1. Add the @EnableTracing annotation to your Spring Boot application class:
@SpringBootApplication
@EnableTracing
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

With these steps, you should be able to set up Micrometer with Spring Boot 2.

References

Migrating Spring Boot 2 Sleuth to Spring 3 Micrometer

Join Newsletter
Get the latest news right in your inbox. We never spam!
Cui
Written by Cui Follow
Hi, I am Z, the coder for cuizhanming.com!