WingtipsSpringWebfluxExchangeFilterFunction implements ExchangeFilterFunction { @SuppressWarnings("SameParameterValue") protected void completeSubspan( @Nullable TracingState spanAroundCallTracingState, @NotNull ClientRequest request, @Nullable ClientResponse response, @Nullable Throwable error ) { if (spanAroundCallTracingState != null) { runnableWithTracing( () -> completeSubspanAttachedToCurrentThread( request, response, error, tagAndNamingStrategy, tagAndNamingAdapter ), spanAroundCallTracingState ).run(); } } WingtipsSpringWebfluxExchangeFilterFunction();  WingtipsSpringWebfluxExchangeFilterFunction(boolean surroundCallsWithSubspan); @SuppressWarnings("ConstantConditions")  WingtipsSpringWebfluxExchangeFilterFunction(
        boolean surroundCallsWithSubspan,
        @NotNull HttpTagAndSpanNamingStrategy<ClientRequest, ClientResponse> tagAndNamingStrategy,
        @NotNull HttpTagAndSpanNamingAdapter<ClientRequest, ClientResponse> tagAndNamingAdapter
    ); @Override @NotNull Mono<ClientResponse> filter(
        @NotNull ClientRequest request, @NotNull ExchangeFunction next
    ); static final @NotNull WingtipsSpringWebfluxExchangeFilterFunction DEFAULT_IMPL; }
@Test public void completeSubspan_does_nothing_if_passed_null_TracingState() { Tracer.getInstance().startRequestWithRootSpan("fooRootSpan"); Span currentSpan = Tracer.getInstance().startSubSpan("fooSubspan", SpanPurpose.LOCAL_ONLY); Throwable error = mock(Throwable.class); filterSpy.completeSubspan(null, request, responseMock, error); assertThat(strategyResponseTaggingAndFinalSpanNameMethodCalled.get()).isFalse(); assertThat(currentSpan.isCompleted()).isFalse(); assertThat(spanRecorder.completedSpans).isEmpty(); }
@Test public void completeSubspan_works_as_expected() { Tracer.getInstance().startRequestWithRootSpan("fooRootSpan"); Span currentSpanForCompletion = Tracer.getInstance().startSubSpan("fooSubspan", SpanPurpose.LOCAL_ONLY); TracingState expectedTracingStateForCompletion = TracingState.getCurrentThreadTracingState(); Tracer.getInstance().unregisterFromThread(); Tracer.getInstance().startRequestWithRootSpan("someCompletelyDifferentRootSpan"); TracingState baseTracingState = TracingState.getCurrentThreadTracingState(); Throwable error = mock(Throwable.class); filterSpy.completeSubspan(expectedTracingStateForCompletion, request, responseMock, error); assertThat(strategyResponseTaggingAndFinalSpanNameMethodCalled.get()).isTrue(); strategyResponseTaggingArgs.get().verifyArgs( currentSpanForCompletion, request, responseMock, error, tagAndNamingAdapterMock ); assertThat(currentSpanForCompletion.isCompleted()).isTrue(); assertThat(spanRecorder.completedSpans).isEqualTo(singletonList(currentSpanForCompletion)); assertThat(TracingState.getCurrentThreadTracingState()).isEqualTo(baseTracingState); }