下载zipkin.jar包
运行zipkin服务
java -jar zipkin-server-2.23.4-exec.jar
访问
http://127.0.0.1:9411
集成springboot
springboot_demo_1
pom.xml
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-zipkin-web-starter</artifactId>
<version>0.1.4</version>
</dependency>
</dependencies>
application.yml
server:
port: 8081
opentracing:
zipkin:
enabled: true
http-sender:
base-url: http://localhost:9411/
spring:
application:
name: springboot_demo1
接口
@RestController
@SpringBootApplication
public class SpringbootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
}
@Resource
RestTemplate restTemplate;
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
@GetMapping("/hii")
public String helloDocker() {
return restTemplate.getForObject("http://127.0.0.1:8082/hi", String.class);
}
}
springboot_demo_2
pom.xml
application.yml
server:
port: 8082
opentracing:
zipkin:
enabled: true
http-sender:
base-url: http://localhost:9411/
spring:
application:
name: springboot_demo2
接口
@RestController
@SpringBootApplication
public class SpringbootDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootDemoApplication.class, args);
}
@GetMapping("/hi")
public String helloDocker() {
return "hello docker";
}
}
启动服务
springboot_demo_1
springboot_demo_2