From a6ccdbe19fb27cef6fd08490959849c6fd0bcb53 Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Fri, 22 Feb 2019 10:09:39 +0900 Subject: [PATCH] Handle missing exceptions in WebMvcMetricsFilter Prior to this commit, exceptions nested in `NestedServletExceptions` would not be recorded by the `WebMvcMetricsFilter`. This commit ensures that exceptions happening downstream (e.g. happening while writing the response body itself) are properly recorded. See https://github.com/micrometer-metrics/micrometer/issues/1190 See gh-16014 --- .../boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java index b99125c0ae..3f51d8c177 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilter.java @@ -130,6 +130,10 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter { record(timingContext, response, request, ex.getCause()); throw ex; } + catch (ServletException | IOException | RuntimeException ex) { + record(timingContext, response, request, ex); + throw ex; + } } private TimingContext startAndAttachTimingContext(HttpServletRequest request) {