For a single request, we can monitor its response time by using consol.log(start) at the beginning of request and console.log(end) at the point where the response is sent. I want in the event that any request to API hangs for a long period (greater than 5-10s), I should be able to terminate the request, return an error, and log both the request and the stack trace. How can I be able to do it at the app-level rather than for adding this console.log for each request?
On the server, I do have Nginx.