From 5bf51f52b979937c65ed2557907d3121f83aceb0 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Thu, 18 Oct 2018 14:53:14 +0200 Subject: [PATCH] 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 --- .../metrics/web/reactive/server/WebFluxTags.java | 10 +--------- .../metrics/web/reactive/server/WebFluxTagsTests.java | 10 ---------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java index 0229f32298..993676c5bc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTags.java @@ -21,7 +21,6 @@ import io.micrometer.core.instrument.Tag; import org.springframework.http.HttpStatus; import org.springframework.util.StringUtils; import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.util.pattern.PathPattern; @@ -87,9 +86,7 @@ public final class WebFluxTags { /** * Creates a {@code uri} tag based on the URI of the given {@code exchange}. Uses the - * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern from - * WebFlux annotation or {@link RouterFunctions#MATCHING_PATTERN_ATTRIBUTE} from - * WebFlux Fn. + * {@link HandlerMapping#BEST_MATCHING_PATTERN_ATTRIBUTE} best matching pattern. * @param exchange the exchange * @return the uri tag derived from the exchange */ @@ -99,11 +96,6 @@ public final class WebFluxTags { if (pathPattern != null) { return Tag.of("uri", pathPattern.getPatternString()); } - String matchingPattern = exchange - .getAttribute(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE); - if (matchingPattern != null) { - return Tag.of("uri", matchingPattern); - } HttpStatus status = exchange.getResponse().getStatusCode(); if (status != null) { if (status.is3xxRedirection()) { diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java index 989dc7e3bc..83d042239c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/reactive/server/WebFluxTagsTests.java @@ -25,7 +25,6 @@ import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.mock.http.server.reactive.MockServerHttpRequest; import org.springframework.mock.web.server.MockServerWebExchange; import org.springframework.web.reactive.HandlerMapping; -import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.util.pattern.PathPatternParser; @@ -59,15 +58,6 @@ public class WebFluxTagsTests { assertThat(tag.getValue()).isEqualTo("/spring"); } - @Test - public void uriTagValueIsFnMatchingPatternWhenAvailable() { - this.exchange.getAttributes().put(RouterFunctions.MATCHING_PATTERN_ATTRIBUTE, - "/spring"); - this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY); - Tag tag = WebFluxTags.uri(this.exchange); - assertThat(tag.getValue()).isEqualTo("/spring"); - } - @Test public void uriTagValueIsRedirectionWhenResponseStatusIs3xx() { this.exchange.getResponse().setStatusCode(HttpStatus.MOVED_PERMANENTLY);