Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}

Expand All @@ -50,8 +58,7 @@ private 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());
}

/**
Expand All @@ -60,8 +67,8 @@ public static Tag method(HttpServletRequest request) {
* @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()));
}

/**
Expand Down Expand Up @@ -91,7 +98,7 @@ else if (response != null) {
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) {
Expand Down Expand Up @@ -121,8 +128,8 @@ private static String getPathInfo(HttpServletRequest request) {
* @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 ? EXCEPTION_NONE :
Tag.of("exception", exception.getClass().getSimpleName());
}

}