Trying to send response status codes metrics per API using spring HandlerInterceptorAdapter postHandle:
@Override
public void postHandle(
HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView
)
Works very well with success responses, however exceptions are all handled by a different controller so from what i can see - spring seems to redirect to a different servlet with the route /error
so the original request is lost.
Is there a way to get the original request object at that point from within the postHandle
method?
The only direction i have at this point is getting the original request from the response but could not figure out how to do it as HttpServletResponse does not expose getRequest
.
EDIT: I need the original request object and not just the url so that i'll be able to get the path variables and remove them from the metric name.