← Back to Home
πŸ”

Introduction to Distributed Tracing with Zipkin

When a request touches ten services, tracing tells you exactly where the time went.

⏱9 min readπŸ“šDevOps Fundamentals

In a microservices system, a single user request might hop through an API gateway, three services, a cache, and a database. When it’s slow, which hop is to blame? Metrics say β€œthe system is slow”; logs are scattered across services. Distributed tracing stitches the whole journey together β€” and Zipkin is a classic, lightweight tool for doing it.


🎯 Learning Objectives


The Microservices Debugging Problem

In a monolith, a slow request is one process β€” a profiler finds the bottleneck. In microservices, one request fans out across many services and machines:

text
Client β–Ά Gateway β–Ά Orders β–Ά Payments β–Ά Bank API
                   β”‚
                   └─▢ Inventory β–Ά Database

"Checkout is slow." ...but which of these hops caused it?

Metrics tell you that latency is high. Logs from each service are hard to correlate. Tracing answers where the time went, by following one request end-to-end.


Tracing vs. Metrics vs. Logs

Pillar Question it answers Granularity
Metrics How much / how fast, overall? Aggregated numbers
Logs What happened in detail, here? Per-event, per-service
Traces Where did this request’s time go across services? Per-request, cross-service

They complement each other: metrics alert you, traces localize the problem, logs give the detail. This section focuses on traces.

πŸ’‘ Traces are per-request stories

A metric is a number over time; a trace is the story of a single request as it travels through your system, timed at every step.


What is Zipkin?

Zipkin is an open-source distributed tracing system (originally from Twitter). It collects timing data from your services and lets you search and visualize traces to find latency problems.

Its architecture has four parts:

text
Instrumented services ──spans──▢ Collector ──▢ Storage ──▢ UI / API
 (send timing data)                          (in-memory,   (search &
                                              Cassandra,    visualize
                                              Elasticsearch) traces)
Component Role
Reporter (in your app) Records timing and sends it to Zipkin
Collector Receives and validates incoming span data
Storage Stores traces (in-memory for demos; Elasticsearch/Cassandra for real use)
UI / API Search traces and view the waterfall timeline

A Trace, Visually

Zipkin shows a trace as a waterfall β€” each service’s work is a bar, positioned by when it happened and sized by how long it took:

text
Trace: GET /checkout   (total 820ms)
gateway  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ 820ms
orders     β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€     640ms
payments        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€           480ms  β—€ the bottleneck
inventory  β”œβ”€β”€β”€β”€                                  90ms

At a glance you can see payments dominated the request. That’s the power of tracing: the slow hop is obvious.


πŸ§ͺ Hands-on Lab

πŸ“

Read the Waterfall

Given this trace, which service should you investigate first, and why?

gateway   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ 700ms
search      β”œβ”€β”€β”€                        80ms
ranking        β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€     520ms

🧠 Knowledge Check

Knowledge Check

What problem does distributed tracing primarily solve?

Knowledge Check

In Zipkin's architecture, what does the Collector do?


πŸ’Ό Interview Preparation

Interview Q&A

When would tracing help you where metrics and logs fall short?


Summary

You understand why distributed tracing exists, how it complements metrics and logs, and Zipkin’s architecture and waterfall view. Next, we unpack the building blocks of a trace: spans, trace IDs, and how context propagates between services.

Up Next

Spans, Traces & Context Propagation

You've mastered this lesson. Continue your journey to becoming a DevOps Engineer.

Start Next Lesson→