WingtipsSpringUtil { public static void propagateTracingHeaders(HttpMessage httpMessage, Span span) { HttpHeadersForPropagation headersForPropagation = (httpMessage == null) ? null : new HttpHeadersForPropagation(httpMessage); HttpRequestTracingUtils.propagateTracingHeaders(headersForPropagation, span); } protected  WingtipsSpringUtil(); static RestTemplate createTracingEnabledRestTemplate(); static RestTemplate createTracingEnabledRestTemplate(boolean surroundCallsWithSubspan); static RestTemplate createTracingEnabledRestTemplate(
        boolean surroundCallsWithSubspan,
        HttpTagAndSpanNamingStrategy<HttpRequest, ClientHttpResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpRequest, ClientHttpResponse> tagAndNamingAdapter
    ); static AsyncRestTemplate createTracingEnabledAsyncRestTemplate(); static AsyncRestTemplate createTracingEnabledAsyncRestTemplate(boolean surroundCallsWithSubspan); static AsyncRestTemplate createTracingEnabledAsyncRestTemplate(
        boolean surroundCallsWithSubspan,
        HttpTagAndSpanNamingStrategy<HttpRequest, ClientHttpResponse> tagAndNamingStrategy,
        HttpTagAndSpanNamingAdapter<HttpRequest, ClientHttpResponse> tagAndNamingAdapter
    ); static void propagateTracingHeaders(HttpMessage httpMessage, Span span); static String getRequestMethodAsString(HttpMethod method); static SuccessCallback<T> successCallbackWithTracing(SuccessCallback<T> successCallback); static SuccessCallback<T> successCallbackWithTracing(
        SuccessCallback<T> successCallback,
        Pair<Deque<Span>, Map<String, String>> threadInfoToLink
    ); static SuccessCallback<T> successCallbackWithTracing(
        SuccessCallback<T> successCallback,
        Deque<Span> spanStackToLink,
        Map<String, String> mdcContextMapToLink
    ); static FailureCallback failureCallbackWithTracing(FailureCallback failureCallback); static FailureCallback failureCallbackWithTracing(FailureCallback failureCallback,
                                                             Pair<Deque<Span>, Map<String, String>> threadInfoToLink); static FailureCallback failureCallbackWithTracing(FailureCallback failureCallback,
                                                             Deque<Span> spanStackToLink,
                                                             Map<String, String> mdcContextMapToLink); static ListenableFutureCallback<T> listenableFutureCallbackWithTracing(
        ListenableFutureCallback<T> listenableFutureCallback
    ); static ListenableFutureCallback<T> listenableFutureCallbackWithTracing(
        ListenableFutureCallback<T> listenableFutureCallback,
        Pair<Deque<Span>, Map<String, String>> threadInfoToLink
    ); static ListenableFutureCallback<T> listenableFutureCallbackWithTracing(
        ListenableFutureCallback<T> listenableFutureCallback,
        Deque<Span> spanStackToLink,
        Map<String, String> mdcContextMapToLink
    );  }
@DataProvider(value = { "true | true", "true | false", "false | true", "false | false" }, splitBy = "\\|") @Test public void propagateTracingHeaders_works_as_expected( boolean httpMessageIsNull, boolean spanIsNull ) { if (httpMessageIsNull) httpMessageMock = null; Span span = (spanIsNull) ? null : Span.newBuilder(UUID.randomUUID().toString(), SpanPurpose.CLIENT) .withParentSpanId(UUID.randomUUID().toString()) .build(); WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span); if (httpMessageIsNull || spanIsNull) { verifyZeroInteractions(headersMock); } else { verify(headersMock).set(TRACE_ID, span.getTraceId()); verify(headersMock).set(SPAN_ID, span.getSpanId()); verify(headersMock).set(TRACE_SAMPLED, convertSampleableBooleanToExpectedB3Value(span.isSampleable())); verify(headersMock).set(PARENT_SPAN_ID, span.getParentSpanId()); } }
@DataProvider(value = { "true", "false" }) @Test public void propagateTracingHeaders_uses_B3_spec_for_sampleable_header_value( boolean sampleable ) { Span span = Span.newBuilder("foo", SpanPurpose.CLIENT) .withSampleable(sampleable) .build(); WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span); verify(headersMock).set(TRACE_SAMPLED, convertSampleableBooleanToExpectedB3Value(span.isSampleable())); }
@DataProvider(value = { "true", "false" }) @Test public void propagateTracingHeaders_only_sends_parent_span_id_header_if_parent_span_id_exists( boolean parentSpanIdExists ) { String parentSpanId = (parentSpanIdExists) ? UUID.randomUUID().toString() : null; Span span = Span.newBuilder("foo", SpanPurpose.CLIENT) .withParentSpanId(parentSpanId) .build(); WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span); if (parentSpanIdExists) { verify(headersMock).set(PARENT_SPAN_ID, parentSpanId); } else { verify(headersMock, never()).set(eq(PARENT_SPAN_ID), anyString()); } }