Introduction
In a microservices architecture, besides the advantages like scalability, faster time to market, and improving maintainability, 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 the article, you need to prepare the following prerequisites:
- Prepare an Ubuntu cloud server, preferably version 20.04 or above with 4 vCPUs and 16 GB Memory
- Install 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 run the Docker services in the article. Docker Compose V2 is included in the latest version of Docker Desktop.
- Install
pm2
globally in the virtual machine to manage multiple backend services