From bd2053aa17c92ecdd785221911dfb8102605fdad Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Tue, 29 May 2018 13:38:09 +0900 Subject: [PATCH] Use more Tag constants Closes gh-13286 --- .../metrics/web/reactive/server/WebFluxTags.java | 15 ++++++++++++--- .../actuate/metrics/web/servlet/WebMvcTags.java | 7 ++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java index 5590da26f3..5d1fdcd069 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java @@ -37,6 +37,12 @@ public final class WebFluxTags { private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION"); + private static final Tag URI_ROOT = Tag.of("uri", "root"); + + private static final Tag URI_UNKNOWN = Tag.of("uri", "UNKNOWN"); + + private static final Tag EXCEPTION_NONE = Tag.of("exception", "None"); + private WebFluxTags() { } @@ -87,9 +93,12 @@ public final class WebFluxTags { return URI_NOT_FOUND; } String path = exchange.getRequest().getPath().value(); - return Tag.of("uri", path.isEmpty() ? "root" : path); + if (path.isEmpty()) { + return URI_ROOT; + } + return Tag.of("uri", path); } - return Tag.of("uri", "UNKNOWN"); + return URI_UNKNOWN; } /** @@ -102,7 +111,7 @@ public final class WebFluxTags { if (exception != null) { return Tag.of("exception", exception.getClass().getSimpleName()); } - return Tag.of("exception", "none"); + return EXCEPTION_NONE; } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java index c6f96ba8c7..b3218fd31e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java @@ -40,6 +40,8 @@ public final class WebMvcTags { private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION"); + private static final Tag URI_ROOT = Tag.of("uri", "root"); + private static final Tag URI_UNKNOWN = Tag.of("uri", "UNKNOWN"); private static final Tag EXCEPTION_NONE = Tag.of("exception", "None"); @@ -97,7 +99,10 @@ public final class WebMvcTags { } } String pathInfo = getPathInfo(request); - return Tag.of("uri", pathInfo.isEmpty() ? "root" : pathInfo); + if (pathInfo.isEmpty()) { + return URI_ROOT; + } + return Tag.of("uri", pathInfo); } return URI_UNKNOWN; }