Microservices — part 2: Distributed tracing
How to understand the behavior of an application and troubleshoot problems?
When microservice architecture grows, each event might be an igniter for many calls to different services. Development teams should be able to quickly find all actions connected to one request, especially in case of any critical errors. I will introduce your very useful pattern called distributed tracing.
How to handle it?
You can start by assigning a unique request identity to each external request, it might be done as part of the header in UUID format. As soon as it will be there generated request-id should be passed into all services which are involved in a particular request. To increase readability good practise is to extend all logs messages for information about that unique ID. Each log message might contain more detail information like start time or end time which might help in ordering actions in a centralised tool.
In practice, such a solution should be available out of the box for all services, so there will not need to implement it in many places. It might be part of the common library which is responsible for making REST requests. Such a library might be just a wrapper for the existing rest client library, but including your specific error logging and passing generated request-id.
Cross fingers that it might work in your case!