Reputation: 1230
We have a requirement to log the route called /api/whatever along with the total time in milliseconds for the response.
I thought this would be an awesome thing to include as a middleware in all of our microservices. When I created this I noticed that the milliseconds I was reporting and what .NET Core embedded messages were reporting was very different. I was saying 15ms and they were saying 40ms. So the pipeline itself naturally consumes some CPU time...
Is there any way for me to get true response time along with the request path?
Looking for an approach here that would allow us to "hook in" and modify asp.net core custom message OR a way to get true response time...
Upvotes: 3
Views: 11248
Reputation: 1230
I found an awesome answer from another SO post:
How to get actual request execution time
In this the author talks about one particular way of doing things through a DiagnosticListener and an "Activity". They also outline that they seen problems with this.
I'm testing now and do not see any problems yet, but will report back if there are.
Upvotes: 2