'Cost estimation of a web request based on incoming headers

I am looking for a solution using which can estimate a web request in terms of cpu time spend in the entire microservice ecosystem. Latency of the calls to different microservices is based on the incoming request which is distinguished based on the header.

For eg:

Requests can have header "type: A" , "type: B" etc and cpu costing will be different for different types.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source