Requesting tracing with Zipkin

Spring Cloud also provides integration to the Zipkin library. We will discuss how to add Zipkin to our microservices-based application. Zipkin provides a mechanism for log-message tracing into your application, such as sending, receiving, storing, and visualizing traces. Zipkin also allows us to trace log activity across servers and gives a much clearer picture of your application and what is happening in our microservices.

As we have discussed in the previous section about Spring Cloud Sleuth, by using it, you can easily trace the log messages in your distributed application. Any library could provide the additional information in your log messages, which would be great for your application. So, we have used ELK, which helps to collect and analyze log messages for your microservices, and it can be helpful for your application monitoring. We can use the trace ID to search all log message across all microservices and provide a picture of how the request passed from one microservice to the next. But sometimes we want more information in our log messages, such as timing information to calculate how long a request took to get from one microservice to the next microservice. To solve this problem, Spring Cloud supports the Zipkin library and provides the Spring Cloud Sleuth Zipkin module. You can add this module by adding the Spring-cloud-sleuth-Zipkin Maven dependency in your project.

Spring Cloud Sleuth will send tracing information to the Zipkin server where you point it. By default, Zipkin is running at http://localhost:9411. You can customize it by setting the spring.zipkin.baseUrl property in your application's properties. Let's enable our application to use Spring Cloud Sleuth Zipkin and send tracing information to the Zipkin server. Let's see the following Maven dependency:

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

By default, if you add spring-cloud-starter-zipkin as a dependency to your project when the span is closed, it is sent to Zipkin over HTTP. The communication is asynchronous. You can configure the URL by setting the spring.zipkin.baseUrl property, as follows:

spring.zipkin.baseUrl: http://localhost:9411/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.167.183