Browse Source

Merge branch '2.0.x'

pull/12895/merge
Stephane Nicoll 8 years ago
parent
commit
c7645604a6
  1. 22
      spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java

22
spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java

@ -40,6 +40,14 @@ public final class WebMvcTags { @@ -40,6 +40,14 @@ public final class WebMvcTags {
private static final Tag URI_REDIRECTION = Tag.of("uri", "REDIRECTION");
private static final Tag URI_UNKNOWN = Tag.of("uri", "UNKNOWN");
private static final Tag EXCEPTION_NONE = Tag.of("exception", "None");
private static final Tag STATUS_UNKNOWN = Tag.of("status", "UNKNOWN");
private static final Tag METHOD_UNKNOWN = Tag.of("method", "UNKNOWN");
private WebMvcTags() {
}
@ -50,8 +58,7 @@ public final class WebMvcTags { @@ -50,8 +58,7 @@ public final class WebMvcTags {
* @return the method tag whose value is a capitalized method (e.g. GET).
*/
public static Tag method(HttpServletRequest request) {
return (request == null ? Tag.of("method", "UNKNOWN")
: Tag.of("method", request.getMethod()));
return (request == null ? METHOD_UNKNOWN : Tag.of("method", request.getMethod()));
}
/**
@ -60,8 +67,8 @@ public final class WebMvcTags { @@ -60,8 +67,8 @@ public final class WebMvcTags {
* @return the status tag derived from the status of the response
*/
public static Tag status(HttpServletResponse response) {
return (response == null ? Tag.of("status", "UNKNOWN")
: Tag.of("status", ((Integer) response.getStatus()).toString()));
return (response == null ? STATUS_UNKNOWN :
Tag.of("status", Integer.toString(response.getStatus())));
}
/**
@ -91,7 +98,7 @@ public final class WebMvcTags { @@ -91,7 +98,7 @@ public final class WebMvcTags {
String pathInfo = getPathInfo(request);
return Tag.of("uri", pathInfo.isEmpty() ? "root" : pathInfo);
}
return Tag.of("uri", "UNKNOWN");
return URI_UNKNOWN;
}
private static HttpStatus extractStatus(HttpServletResponse response) {
@ -121,8 +128,9 @@ public final class WebMvcTags { @@ -121,8 +128,9 @@ public final class WebMvcTags {
* @return the exception tag derived from the exception
*/
public static Tag exception(Throwable exception) {
return Tag.of("exception",
(exception == null ? "None" : exception.getClass().getSimpleName()));
return (exception != null
? Tag.of("exception", exception.getClass().getSimpleName())
: EXCEPTION_NONE);
}
}

Loading…
Cancel
Save