0Pricing
API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) · 강의

Sleuth 및 Zipkin을 사용한 분산 추적

Spring Cloud Sleuth와 Zipkin을 연동하여 분산 추적을 구현하고 마이크로서비스 전반의 요청 흐름을 파악해 보세요.

Sleuth 및 Zipkin을 사용한 분산 추적은(는) CoddyKit의 무료 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What is Distributed Tracing?

In microservices, a single user request often travels through many different services. This makes it hard to follow the request's journey!

Distributed tracing is a technique that helps you track the path of a request as it moves across various services in your system.

Why Trace Microservices?

Without tracing, debugging issues in microservices is like finding a needle in a haystack. You don't know which service failed or where the delay occurred.

  • Debugging: Pinpoint errors faster.
  • Performance: Identify bottlenecks in the request flow.
  • Visibility: Understand how services interact.

Sleuth: The Tracing Enabler

Spring Cloud Sleuth integrates with Spring applications to automatically add tracing information to requests and logs.

It injects unique identifiers into HTTP headers and logging contexts, allowing you to link related operations across services.

Trace & Span IDs Explained

Sleuth uses two main IDs:

  • Trace ID: A unique ID for the entire request, from start to finish, across all services it touches.
  • Span ID: A unique ID for a single operation or unit of work within a service (e.g., an HTTP request or a method call). Spans form a tree structure within a trace.

Add Sleuth Dependency

To enable Sleuth in your Spring Boot application, add the spring-cloud-starter-sleuth dependency to your pom.xml (Maven) or build.gradle (Gradle).

For Maven:

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

For Gradle:

implementation 'org.springframework.cloud:spring-cloud-starter-sleuth'

Zipkin: The Tracing UI

While Sleuth adds tracing info, you need a way to collect and visualize it. That's where Zipkin comes in!

Zipkin is a distributed tracing system that collects and stores trace data, then provides a web UI to search and view these traces.

Run Zipkin Server

The easiest way to get Zipkin running locally is using Docker. This command pulls the Zipkin image and starts it on port 9411.

docker run -d -p 9411:9411 openzipkin/zipkin

You can then access the Zipkin UI at http://localhost:9411 in your browser.

Configure Sleuth for Zipkin

Once Zipkin is running, tell your Sleuth-enabled Spring Boot application where to send its trace data. Add this to your application.properties or application.yml.

application.properties:

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

Now, your application will send trace data to the local Zipkin server.

Tracing a Service Call

Let's see how a simple Spring Boot service logs trace IDs. With Sleuth, your logs will automatically include [appName,traceId,spanId,exportable].

Run this simple app, then make a request to /hello. Check the console logs for the added IDs.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class TracingApp {

  public static void main(String[] args) {
    SpringApplication.run(TracingApp.class, args);
  }

  @GetMapping("/hello")
  public String hello() {
    System.out.println("Hello endpoint called!");
    return "Hello from TracingApp!";
  }
}

Quick Check

Which of the following statements correctly describe the roles of Spring Cloud Sleuth and Zipkin in distributed tracing? (Select all that apply)

Recap & Next Steps

You've learned how distributed tracing helps in microservices, especially with Spring Cloud Sleuth and Zipkin.

  • Sleuth: Integrates with Spring apps to inject traceId and spanId.
  • Zipkin: Collects these traces and provides a UI for visualization and analysis.

These tools are crucial for understanding and debugging complex distributed systems.

자주 묻는 질문

“Sleuth 및 Zipkin을 사용한 분산 추적” 강의는 무료인가요?

네 — “Sleuth 및 Zipkin을 사용한 분산 추적” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의 전체를 잠금 해제할 수 있습니다. API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 총 4개의 강의가 포함되어 있습니다.

“Sleuth 및 Zipkin을 사용한 분산 추적”에서 뭘 배우나요?

Spring Cloud Sleuth와 Zipkin을 연동하여 분산 추적을 구현하고 마이크로서비스 전반의 요청 흐름을 파악해 보세요. 브라우저에서 직접 실행하는 실습 코드로 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.

“Sleuth 및 Zipkin을 사용한 분산 추적” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway) 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. JWT 인증 및 권한 부여
  2. Sleuth 및 Zipkin을 사용한 분산 추적
  3. Config Server를 사용한 중앙 집중식 설정
  4. Actuator 및 Prometheus로 메트릭 노출하기
← API Gateway & Reverse Proxy (Nginx + Spring Cloud Gateway)(으)로 돌아가기