paint-brush
Trace/Monitor Chain of Microservice Logs in the Same Transactionby@mustafaturan
1,119 reads
1,119 reads

Trace/Monitor Chain of Microservice Logs in the Same Transaction

by Mustafa TuranAugust 18th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

In microservice architecture, it is possible to get lost with logs, errors, monitors, etc... Having a common logging place is good practice to make the service logs query-able sequentially. In the microservice world each service is responsible for its own exceptions and logs.
featured image - Trace/Monitor Chain of Microservice Logs in the Same Transaction
Mustafa Turan HackerNoon profile picture

In microservice architecture, it is possible to get lost with logs, errors, monitors, etc... Having a common logging place is good practice to make the service logs query-able sequentially. In the microservice world each service is responsible for its own exceptions and logs.

Consider pipelined microservices which make calls to other microservices inside/outside the universe. If one call in the chain fails, we can expect that previous calls in the chain might raise errors as well, but how you can trace which request caused this error in the chain?

Demonstration

The quick solution is; if the request does not have a ‘request ID’ information, then put a ‘request ID’ or ‘transaction ID’ information from the beginning of the request and pass the same ‘request ID’ through services. If you are using HTTP to make connection between microservices, you can put the ‘request ID’ as a HTTP header.

When you start logging the chain of requests, you will have the same ‘request ID’ which will be easy to query and analyse which one caused the error.

Lastly, if you are interested in completely traceable systems, also checkout opentracing specs.

Happy monitoring!