Merge pull request #13447 from izeye:pattern-before-path

* pr/13447:
  Use a precompiled pattern in WebClientExchangeTags.extractPath()
pull/13453/head
Brian Clozel 7 years ago
commit 2ecd70416c

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

Loading…
Cancel
Save