Spring Cloud and Spring Boot. Part 2: Using Zipkin Server for Distributed Tracing


From the last article ( translated into Habré , original in English ), you learned how to use the Eureka Server to discover and register services. In this article, we will introduce you to Distributed Tracing.





. . , .





, .





Zipkin Server . pom.xml



.





<dependency>
  <groupId>io.zipkin.java</groupId>
  <artifactId>zipkin-server</artifactId>
  <version>2.11.7</version>
</dependency>
<dependency>
  <groupId>io.zipkin.java</groupId>
  <artifactId>zipkin-autoconfigure-ui</artifactId>
  <version>2.11.7</version>
</dependency>
      
      



Zipkin Server 

maven- - (, zipkin-server). Spring- https://start.spring.io.





pom.xml



:





<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example.zikin.server</groupId>
  <artifactId>zipkin-server</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>zipkin-server</name>
  <description>Demo project for Spring Boot</description>

  <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <version>2.0.7.RELEASE</version>
     <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <java.version>1.8</java.version>
  </properties>

  <dependencies>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
     </dependency>
     <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
        <version>2.11.7</version>
     </dependency>
     <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <version>2.11.7</version>
     </dependency>
  </dependencies>
  <build>
     <plugins>
        <plugin>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
     </plugins>
  </build>
</project>

      
      



ZipkinServerApplication.java



@EnableZipkinServer



, .





package com.example.zikin.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import zipkin2.server.internal.EnableZipkinServer;

@SpringBootApplication
@EnableZipkinServer
public class ZipkinServerApplication {
  public static void main(String[] args) {
     SpringApplication.run(ZipkinServerApplication.class, args);
  }
}
      
      



application.properties



, src/main/resources



, .





spring.application.name=zipkin-server
server.port=9411
      
      



Java- http://localhost:9411/zipkin.





, .





Zipkin Server

Eureka Server Zipkin Server

( , .) , Eureka Server. Zipkin Server, application.properties



.





spring.zipkin.base-url=http://localhost:9411/
      
      



spring.zipkin.base-url



, Zipkin Server.





pom.xml



Eureka Server.





<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
      
      



Eureka Server , Zipkin Server , Zipkin Server UI Service Name eureka-server.





Spring Boot- Zipkin Server

, Spring Boot, application.properties



.





spring.zipkin.base-url=http://localhost:9411/
      
      



pom.xml .





<dependency>
   <groupId>org.springframework.cloud</groupId>
   <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
      
      



Zipkin.





Zipkin Server

, , .





, Zipkin Server .






« Spring Framework». - « , Mongo DB Atlas».









Mongo DB .












All Articles