​ Zipkin is a distributed tracing system. It helps gather timing data needed to troubleshoot latency problems in service architectures. Features include both the collection and lookup of this data.

ZipKin is a distributed link-tracking system that helps collect time data for latency issues in the service architecture. It helps collect and query data for us.

Quick start

It has a server that collects data, so you can download a link from the direct website

Or build one yourself,

Build a Spring-boot project. Only add these to the dependencies. It is ok

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <! -->
    <version>2.0.4. RELEASE</version>
    <relativePath/> 
</parent>
<dependencies>
    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-server</artifactId>
        <version>2.12.2</version>
    </dependency>

    <dependency>
        <groupId>io.zipkin.java</groupId>
        <artifactId>zipkin-autoconfigure-ui</artifactId>
        <version>2.12.2</version>
    </dependency>
</dependencies>
Copy the code

Start the app, you can refer to zipkin. Server. ZipkinServer implementation.

@EnableZipkinServer
@SpringBootApplication
public class SpringTraceApplication {
    static {
        // Make sure java.util.logging goes to log4j2
        // https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging
        System.setProperty("java.util.logging.manager"."org.apache.logging.log4j.jul.LogManager");
    }

    public static void main(String[] args) {
        new SpringApplicationBuilder(SpringTraceApplication.class)
                .listeners(new RegisterZipkinHealthIndicators())
                .properties("spring.config.name=zipkin-server").run(args); }}Copy the code

MVN clean install -dmaven.test. skip=true Then run the jar package. This is the fastest (can be over the wall, I did not say, official do not recommend their own server). The default port is 9441.

Then start java-jar directly

Visit http://localhost:9411/zipkin/ with respect to OK

2. Use

Microservices, so this is for microservices, basically springCloud. Spring Cloud Sleuth is actually.

Join the rely on

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

Then add the configuration, there are a lot of can go to a website to find, links: www.springcloud.cc/spring-clou… , here explains all the contents of Sleuth.

spring.zipkin.base-url=http://localhost:9411
spring.zipkin.service.name=user-service
spring.zipkin.enabled=true
spring.zipkin.discovery-client-enabled=true
Copy the code

And then build the service

In fact, it is almost complete and can be used directly like writing microservices, eureka registry wow, service call wow. Zuul gateway, you can do it.

If you want to see all the details of how it’s used,

Github.com/openzipkin/…

Github.com/openzipkin/…

www.springcloud.cc/spring-clou…