Exception caught by @ExceptionHandler is not recorded by MetricsWebFilter

840 views Asked by At

Trying to migrate from web-mvc to webflux+coroutines. Faced a problem with http.server.requests metric recording.

With web-mvc, when using @RestController, @RestControllerAdvice with multiple @ExceptionHandler, I got exception classes recorded in exception tag of metric http.server.requests. Like so http_server_requests_seconds_count{exception="CustomException",method="POST",outcome="CLIENT_ERROR",status="400",uri="/v1/users",} 1.0

However, this refuses to work as expected with webflux (spring boot 2.3.4). I used same annotated components.
http_server_requests_seconds_count{exception="None",method="POST",outcome="CLIENT_ERROR",status="400",uri="/v1/users",} 1.0
In this case there is a call to MetricsWebFilter.onSuccess(...), which does not have exception parameter.
Desired exception tag is filled only on exceptions uncaught by @RestControllerAdvice. This may seem like a reasonable thing to do, but it is unexpected and complicates service monitoring for me.

Maybe there is a way to achieve old behaviour?

0

There are 0 answers