Skip to content
Merged
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 @@ -39,6 +39,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,9 +58,7 @@ private WebMvcTags() {
* @return the method tag whose value is a capitalized method (e.g. GET).
*/
public static Tag method(@Nullable 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 @@ -62,7 +68,7 @@ public static Tag method(@Nullable HttpServletRequest request) {
* @return the status tag derived from the status of the response
*/
public static Tag status(@Nullable 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 @@ -92,7 +98,7 @@ public static Tag uri(@Nullable HttpServletRequest request, @Nullable HttpServle
String pathInfo = getPathInfo(request);
return Tag.of("uri", pathInfo.isEmpty() ? "root" : pathInfo);
}
return Tag.of("uri", "UNKNOWN");
return URI_UNKNOWN;
}

@Nullable
Expand Down Expand Up @@ -125,8 +131,6 @@ private static String getPathInfo(HttpServletRequest request) {
* @return the exception tag derived from the exception
*/
public static Tag exception(@Nullable Throwable exception) {
return exception == null ?
Tag.of("exception", "None") :
Tag.of("exception", exception.getClass().getSimpleName());
return exception == null ? EXCEPTION_NONE : Tag.of("exception", exception.getClass().getSimpleName());
}
}