Link Tracking for the Spring Cloud distributed integrated Zipkin

Source: Internet
Author: User

Why use Zipkin?

The previous article mainly wrote: Spring Cloud distributed log link Tracking

From the previous article can be seen in the call between services, assuming that there are now more than 10 services, then in the search for the log is cumbersome, complex, and in the view of the call will be like a spider web, the amount is too large.

At this time Zipkin can call the entire process to upgrade the link, only need to go to a place to find, you can know which step error.

Zipkin is also divided into servers and clients, the server is Zipkin, micro-service is the client.

First, set up the server Zipkin

In this service build.gradle plus Zipkin dependencies:

    Compile ' io.zipkin.java:zipkin-server    ' Io.zipkin.java:zipkin-autoconfigure-ui '

Here you can see that it's not part of spring.

In the APPLICATION.YML configuration:

Server:   9999Spring:  application:    name:zipkin-server #注册到注册中心的名字, can map IP

Configuration file is very simple

Startup class:

// indicates that Zipkin is a server @SpringBootApplication  Public class Zipkinserverprodiver {    publicstaticvoid  main (string[] args) {        Springapplication.run (zipkinserverprodiver). class , args);}    }

Next, add dependencies to the client Build.gradle for the Zipkin server:

// represents the Zipkin client    Compile group: ' Org.springframework.cloud ', Name: ' Spring-cloud-sleuth-zipkin '

Here's a couple of Zipkin's clients that join the dependency

Of course, in the client configuration file Application.yml, you also add the Zipkin configuration:

Spring:  zipkin:    base-url:http://localhost:9999 #代表字zipkin服务器地址   Sleuth:    Sampler:      1.0 #0.1-1.0 is the probability of uploading data that represents the link tracking

Start Zipkin server: http://localhost:9999

See, that proves the success of the launch.

Start the project below, perform a call between microservices, and flush the Zipkin server:

Here you can see that I performed 4 times, there were 4 links, I looked up based on time, or I could find it based on the link encoding in the Console or log:

I'll take one at the console. Search:

You can see that you have found

Zipkin also has link analysis:

it can also be searched by time and link code, so we want to find out which period or precise to which is very convenient.

If you do not understand the small partners please refer to my previous blog for browsing, perhaps enlightened!

Link Tracking for the Spring Cloud distributed integrated Zipkin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.