Skip to content

Commit 5bf51f5

Browse files
committed
Fix WebFlux instrumentation after SPR-17395
SPR-17395 ensures that WebFlux.fn is adding a request attribute of type `PathPattern` on the `HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE`. A specific tag provider for WebFlux.fn is no longer necessary. See gh-14876
1 parent 64c9dfe commit 5bf51f5

File tree

2 files changed

+1
-19
lines changed
  • spring-boot-project/spring-boot-actuator/src

2 files changed

+1
-19
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.springframework.http.HttpStatus;
2222
import org.springframework.util.StringUtils;
2323
import org.springframework.web.reactive.HandlerMapping;
24-
import org.springframework.web.reactive.function.server.RouterFunctions;
2524
import org.springframework.web.server.ServerWebExchange;
2625
import org.springframework.web.util.pattern.PathPattern;
2726

@@ -87,9 +86,7 @@ public static Tag status(ServerWebExchange exchange) {
8786

8887
/**
8988
* Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the
90-
* {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern from
91-
* WebFlux annotation or {@link RouterFunctions#MATCHING_PATTERN_ATTRIBUTE} from
92-
* WebFlux Fn.
89+
* {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern.
9390
* @param exchange the exchange
9491
* @return the uri tag derived from the exchange
9592
*/
@@ -99,11 +96,6 @@ public static Tag uri(ServerWebExchange exchange) {
9996
if (pathPattern != null) {
10097
return Tag.of("uri", pathPattern.getPatternString());
10198
}
102-
String matchingPattern = exchange
103-
.getAttribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE);
104-
if (matchingPattern != null) {
105-
return Tag.of("uri", matchingPattern);
106-
}
10799
HttpStatus status = exchange.getResponse().getStatusCode();
108100
if (status != null) {
109101
if (status.is3xxRedirection()) {

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
2626
import org.springframework.mock.web.server.MockServerWebExchange;
2727
import org.springframework.web.reactive.HandlerMapping;
28-
import org.springframework.web.reactive.function.server.RouterFunctions;
2928
import org.springframework.web.server.ServerWebExchange;
3029
import org.springframework.web.util.pattern.PathPatternParser;
3130

@@ -59,15 +58,6 @@ public void uriTagValueIsBestMatchingPatternWhenAvailable() {
5958
assertThat(tag.getValue()).isEqualTo("/spring");
6059
}
6160

62-
@Test
63-
public void uriTagValueIsFnMatchingPatternWhenAvailable() {
64-
this.exchange.getAttributes().put(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE,
65-
"/spring");
66-
this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY);
67-
Tag tag = WebFluxTags.uri(this.exchange);
68-
assertThat(tag.getValue()).isEqualTo("/spring");
69-
}
70-
7161
@Test
7262
public void uriTagValueIsRedirectionWhenResponseStatusIs3xx() {
7363
this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY);

0 commit comments

Comments
 (0)