Commit 2ecd7041 authored by Brian Clozel's avatar Brian Clozel

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

* pr/13447:
  Use a precompiled pattern in WebClientExchangeTags.extractPath()
parents 5bd9a445 c908445b
...@@ -17,6 +17,7 @@ ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment