Add documentation on conditions when DefaultWebClientAdvice is not applied

This commit is contained in:
Johan Vandeweerd 2019-06-07 12:45:20 +02:00 committed by Tyler Benson
parent 633db43cb1
commit 0043efa164
1 changed files with 11 additions and 6 deletions

View File

@ -11,13 +11,18 @@ public class DefaultWebClientAdvice {
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit( public static void methodExit(
@Advice.Thrown final Throwable throwable, @Advice.Thrown final Throwable throwable,
@Advice.This final ExchangeFunction exchangeFunction, @Advice.This final ExchangeFunction exchangeFunction,
@Advice.Argument(0) final ClientRequest clientRequest, @Advice.Argument(0) final ClientRequest clientRequest,
@Advice.Return(readOnly = false) Mono<ClientResponse> mono) { @Advice.Return(readOnly = false) Mono<ClientResponse> mono) {
if (throwable == null if (throwable == null
&& mono != null && mono != null
&& !clientRequest.headers().keySet().contains("x-datadog-trace-id")) { // The response of the org.springframework.web.reactive.function.client.ExchangeFunction.exchange method is
// replaced by a decorator that in turn also calls the
// org.springframework.web.reactive.function.client.ExchangeFunction.exchange method. If the original return value
// is already decorated (we detect this if the "x-datadog-trace-id" is added), the result is not decorated again
// to avoid StackOverflowErrors.
&& !clientRequest.headers().keySet().contains("x-datadog-trace-id")) {
mono = new TracingClientResponseMono(clientRequest, exchangeFunction, GlobalTracer.get()); mono = new TracingClientResponseMono(clientRequest, exchangeFunction, GlobalTracer.get());
} }
} }