A beginner’s guide to Jaeger

Jaeger — Deep Dive

Magsther
FAUN — Developer Community 🐾

--

Getting Started

A good way to get into the world of Distributed Tracing is to begin with Jaeger.

It is easy to setup as it comes with an All-in-One image, that also includes a Jaeger UI, where we can see the traces.

To kick this off, we need to have an application to send traces.

Luckily, Jaeger provides a demo application called HotROD (Rides on Demand). This application consists of several microservices, which makes it a very good example for what we want to do.

In this part we will take a look at what Jaeger is and how we can deploy it in a local environment using Docker.

In the diagram below, you can see how the various components are connected with each other and how the request flow looks like.

For full detail, please Take OpenTracing for a HotROD ride

Distributed Tracing — Monitoring for Microservices

Distributed tracing is a method of tracking (monitor) application requests built on a microservices architecture. It helps developers to find performance issues in their applications.

You can think of it as Monitoring for Microservices

I recommend reading Distributed Tracing in Practice, which explains this in detail.

What is Jaeger?

Jaeger inspired by Dapper and OpenZipkin, is a distributed tracing platform created by Uber Technologies and can be used for monitoring microservices based distributed systems.

By doing this, we can view traces and analyse the application’s behaviour.

Why do we need it?

Using a tracing platform (like Jaeger) is especially important in microservices environments, since they are considered lot more difficult to debug than a single monolithic application.

Problems that Jaeger addresses?

  • Distributed tracing monitoring
  • Performance and latency optimization
  • Root cause analysis
  • Service dependency analysis

Jaeger All-in-One

Jaeger provides quick way to get started in form of an All-in-One image. This image can deployed with for example Docker and Kubernetes. The All-in-One image is usually a good starting point and is designed for local testing.

The image is an executable that launches:

  • Agent
  • Collector
  • Query
  • Ingester
  • Jaeger UI

The image uses by default in-memory storage, meaning it will lose all data upon restart. However, it’s a good way for testing and to get started with Jaeger.

Jaeger Components

Let’s quickly go through the various Jaeger components.

Jaeger Agent

  • Network daemon that listens for spans sent over UDP, which it batches and sends to the collector.
  • Usually placed on the same host as the instrumented application.
  • In Kubernetes this is typically done by having a sidecar

Jaeger Collector

  • Receives traces from the application or Jaeger agent.
  • Runs the traces through a processing pipeline for validation and clean-up/enrichment.
  • The traces are stored in a storage backend.

Query

  • Service that retrieves traces from storage.

Ingester

  • Service that reads from an event streaming platform and writes to another storage backend.

Storage

  • Collectors requires a storage backend.
  • Cassandra and Elasticsearch are the primary supported distributed storage backends.
  • The in-memory storage is not intended for production workloads, it is intended as a simple solution to get started quickly and data will be lost once the process is gone.

Jaeger UI

  • Jaeger provides a user interface that lets you visualise the distributed tracing data
  • On the search page, you can find traces and explore details of the spans that make up an individual trace.
  • Usually accessible on http://localhost:16686/ (if you run it on localhost)

You can read more about the Jaeger components here.

To see traces in the UI, we need to have an application to send tracing data to Jaeger.

HotROD (Rides on Demand)

A good application to use for testing tracing is the now infamous HotROD application created by the Jaeger team. The creator of Jaeger Yuri Shkuro wrote an excellent post about this called Take Jaeger for a HotROD ride.

HotROD is a demo ride-booking application that consists of several microservices (and a accompanying storage such as MySQL and Redis)

  • driver-service
  • customer-service
  • route-service

A tutorial / walkthrough of this demo application is available here.

In short, when the application starts, it generates a web page with buttons representing customers.

Hot R.O.D UI

When you click on a button, it will send a request to the backend , which generates a trace. The application responds to this requests with information about the car license number and estimated time of arrival. Jaeger then captures this request as it flows through the various services.

The request flow

Deploying Jaeger (and HotROD) with Docker

Sometimes you want to try out things really quick, in those cases (and many more) Docker can really help.

Let’s deploy the Jaeger All-in-One image using Docker.

We will use the official documentation to see how this works.

Copy and paste this into your terminal:

docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-e COLLECTOR_OTLP_ENABLED=true \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 9411:9411 \
jaegertracing/all-in-one:1.36

If you now type docker images, you will see that the container all-in-one image is running.

jaegertracing/all-in-one 1.36 5a4f502479b7 2 weeks ago 60.4MB

Once the container starts, navigate to http://localhost:16686 to access the Jaeger UI.

Currently , there are no services in the UI (except for the default jaeger-query service). That’s because the container that is running the backend (with an in-memory storage) is empty.

To simulate some traces we will use the Hot R.O.D (Rides on Demand) demo application to see send tracing data to Jaeger.

Run HotROD from docker

Copy and paste this into your terminal:

docker run --rm -it \
--link jaeger \
-p8080-8083:8080-8083 \
-e JAEGER_AGENT_HOST="jaeger" \
jaegertracing/example-hotrod:1.36 \
all

Once the container starts, navigate to http://localhost:8080 to access the applications UI.

Click on a customer name to send a request to the backend. The application responds to this requests. As you can see from the screenshot, Hot R.O.D generates links, and if you click find trace , it will redirect you to the Jaeger UI (by default it uses the standard Jaeger UI address http://localhost:16686) to find traces corresponding to each request.

In the Services dropdown list, you will now see additional services from the HotROD demo application.

From this view we can see how the application handles a request.

You can read more about the architecture, the data flow and logging here

What’s next

This is a good first step into the world of Distributed Tracing. By now, you should understand the concepts of Jaeger (and Hot ROD).

In the next post, we will continue on the topic and see how we can deploy Jaeger & HotROD using Docker Compose.

If you found this useful, please hit that clap button and follow me to get more articles on your feed.

Resources

Take OpenTracing for a HotROD ride

Jaeger: open source, end-to-end distributed tracing (jaegertracing.io)

Sending demo traces with the HotROD application

jaeger/README.md at main · jaegertracing/jaeger (github.com)

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇

🚀Developers: Learn and grow by keeping up with what matters, JOIN FAUN.

--

--