Merge branch '2.2.x'

Closes gh-20030
This commit is contained in:
Stephane Nicoll
2020-02-04 10:09:11 +01:00
3 changed files with 45 additions and 12 deletions

View File

@@ -48,6 +48,7 @@ import org.springframework.web.util.NestedServletException;
*
* @author Jon Schneider
* @author Phillip Webb
* @author Chanhyeong LEE
* @since 2.0.0
*/
public class WebMvcMetricsFilter extends OncePerRequestFilter {
@@ -123,13 +124,15 @@ public class WebMvcMetricsFilter extends OncePerRequestFilter {
Set<Timed> annotations = getTimedAnnotations(handler);
Timer.Sample timerSample = timingContext.getTimerSample();
if (annotations.isEmpty()) {
Builder builder = this.autoTimer.builder(this.metricName);
timerSample.stop(getTimer(builder, handler, request, response, exception));
return;
}
for (Timed annotation : annotations) {
Builder builder = Timer.builder(annotation, this.metricName);
timerSample.stop(getTimer(builder, handler, request, response, exception));
if (this.autoTimer.isEnabled()) {
Builder builder = this.autoTimer.builder(this.metricName);
timerSample.stop(getTimer(builder, handler, request, response, exception));
}
} else {
for (Timed annotation : annotations) {
Builder builder = Timer.builder(annotation, this.metricName);
timerSample.stop(getTimer(builder, handler, request, response, exception));
}
}
}