Assigning a correlation token to each service request
A microservices architecture is distributed in nature and many services interact with each other to complete a business use case. A correlation token is a unique string (preferably, a globally unique ID, or GUID) that is assigned to each request for troubleshooting purposes.
For example, if there is a long-chain operation where many services are involved, passing the correlation token to the service helps to investigate the issue easily if any of the services fail during that transaction. Usually, each service has its own database and keeps the correlation token within the database record as well.
These two things are worth mentioning:
- Have a correlation ID that correlates the end-user request to requests made to various microservices so that we can quickly locate logs in each of the services that were involved in an end-user request.
- The cost to store and make logs searchable can be large and, for that, some...