Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)

When we build a microservice architecture and the number of services keeps growing, we face the problem of debugging and tracing requests through our entire system. What happened when a user got a 500 error on his request? What service incorrectly processed his request? All these questions can be solved by the Distributed Tracing System. Let's take Spring Cloud Sleuth as an example.

How Spring Cloud Sleuth Works

To trace a request through a distributed system, the concepts TraceID and SpanID are introduced. TraceID is generated when a request enters our system and remains unchanged throughout its path. SpanID changes as the request passes from one service to another. If necessary, it is possible to generate new spans within one service to distinguish business processes.

How to Create Microservices Using Spring

In this article, we will understand how to create Spring-based Microservices using a Use Case.

Use Case

Let’s consider the use case of BookMyHotel Web Application, developed by a company known as MyInternetSolutions.

Service Integration With Netflix Feign and Ribbon

The guys at Netflix have developed and open sourced (among many other things) Feign and Ribbon. These libraries can help you as a developer to build robust, fault-tolerant service integrations. Best of all, they've been tested in the wild by Netflix, who use both libraries extensively in their own microservices architecture. In this post, we'll look at Feign and Ribbon to see how they can be used in the context of a Spring Boot application.

What Is Feign?

Feign is a library that helps developers create declarative HTTP clients by simply defining an interface and annotating it. At runtime, Feign creates the HTTP client implementation for the interface. We'll look at this in detail with some sample code later.