How to apply distributed tracing for a Node.js app

Donald Le
28 min readApr 4, 2024
Photo by Christopher Burns on Unsplash

Introduction

In a microservices architecture, besides the advantages like scalability, faster time to market, and improving maintability, it also comes with disadvantages. One of the hardest problems with microservices is how to debug errors when they happen. With dozens to hundreds of microservices communicating with each other in an application, you can easily get lost in the ocean of logs where you don't know the root cause of the problem.

To quickly debug and find out the root cause of the problem, you need to apply distributed tracing for your application. By the end of the article, you will understand how to apply distributed tracing for Node.js services using Jaeger.

Prerequisites

To follow along with the step-by-step, terminal-based instructions in article, you need to prepare the following prerequisites:

1. Prepare an [Ubuntu](https://www.vultr.com/servers/ubuntu/) cloud server, preferably version 20.04 or above with 4 vCPUs and 16 GB Memory

2. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) latest version to deploy MongoDB for storing the data of the backend services and Jaeger to store traces of the API requests. Please note that you need Docker Compose with version 2 or above to…

--

--

Donald Le

A passionate automation engineer who strongly believes in “A man can do anything he wants if he puts in the work”.