Use a precompiled pattern in WebClientExchangeTags.extractPath()

This commit is contained in:
Johnny Lim 2018-06-12 14:56:02 +09:00
parent 5bd9a445ae
commit c908445bff
1 changed files with 5 additions and 1 deletions

View File

@ -17,6 +17,7 @@
package org.springframework.boot.actuate.metrics.web.reactive.client;
import java.io.IOException;
import java.util.regex.Pattern;
import io.micrometer.core.instrument.Tag;
@ -41,6 +42,9 @@ public final class WebClientExchangeTags {
private static final Tag CLIENT_ERROR = Tag.of("status", "CLIENT_ERROR");
private static final Pattern PATTERN_BEFORE_PATH = Pattern
.compile("^https?://[^/]+/");
private WebClientExchangeTags() {
}
@ -66,7 +70,7 @@ public final class WebClientExchangeTags {
}
private static String extractPath(String url) {
String path = url.replaceFirst("^https?://[^/]+/", "");
String path = PATTERN_BEFORE_PATH.matcher(url).replaceFirst("");
return (path.startsWith("/") ? path : "/" + path);
}