Skip to content

Commit

Permalink
Fix WebFlux instrumentation after SPR-17395
Browse files Browse the repository at this point in the history
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 spring-projectsgh-14876
  • Loading branch information
bclozel committed Oct 18, 2018
1 parent 64c9dfe commit 5bf51f5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;

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

/**
* 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
*/
Expand All @@ -99,11 +96,6 @@ public static Tag uri(ServerWebExchange exchange) {
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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
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;

Expand Down Expand Up @@ -59,15 +58,6 @@ public void uriTagValueIsBestMatchingPatternWhenAvailable() {
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);
Expand Down

0 comments on commit 5bf51f5

Please sign in to comment.