You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to this: #150. HttpRequestCountMiddleware/HttpRequestDurationMiddleware record response status codes before asp.net's built-in exception handling has kicked in, thus recording a response that's about to turn into a http 500 as http 200. The mentioned issue suggests to use ExceptionHandlerMiddleware, but I'd much rather just let asp's default exception handling kick in and record the actual response afterwards.
One way of doing that would be hooking into HttpContext.Response.OnStarting, and only call HttpRequestCountMiddleware.CreateChild().Inc() and HttpRequestDurationMiddleware.CreateChild().Observe() from there. I'm currently doing that through a bit of reflection (and being sure not to actually insert HttpRequest* middleware into the asp pipeline, just increment their counters) but this is obviously not a preferred solution. It seems to work fine, though.
So my question is, would it be possible to provide alternate versions of HttpRequestCountMiddleware/HttpRequestDurationMiddleware that record metrics "as late as possible"? Or alternatively, expose enough of the internal API to be able to implement that stuff manually without resorting to using reflection?
The text was updated successfully, but these errors were encountered:
Related to this: #150. HttpRequestCountMiddleware/HttpRequestDurationMiddleware record response status codes before asp.net's built-in exception handling has kicked in, thus recording a response that's about to turn into a http 500 as http 200. The mentioned issue suggests to use ExceptionHandlerMiddleware, but I'd much rather just let asp's default exception handling kick in and record the actual response afterwards.
One way of doing that would be hooking into HttpContext.Response.OnStarting, and only call HttpRequestCountMiddleware.CreateChild().Inc() and HttpRequestDurationMiddleware.CreateChild().Observe() from there. I'm currently doing that through a bit of reflection (and being sure not to actually insert HttpRequest* middleware into the asp pipeline, just increment their counters) but this is obviously not a preferred solution. It seems to work fine, though.
So my question is, would it be possible to provide alternate versions of HttpRequestCountMiddleware/HttpRequestDurationMiddleware that record metrics "as late as possible"? Or alternatively, expose enough of the internal API to be able to implement that stuff manually without resorting to using reflection?
The text was updated successfully, but these errors were encountered: