/** * Calls {@link WingtipsSpringUtil#propagateTracingHeaders(HttpMessage, Span)} to propagate the current span's * tracing state on the given request's headers, then returns * {@link AsyncClientHttpRequestExecution#executeAsync(HttpRequest, byte[])} to execute the request. * * @return The result of calling {@link AsyncClientHttpRequestExecution#executeAsync(HttpRequest, byte[])}. */ protected ListenableFuture<ClientHttpResponse> propagateTracingHeadersAndExecute( HttpRequestWrapperWithModifiableHeaders wrapperRequest, byte[] body, AsyncClientHttpRequestExecution execution ) throws IOException { propagateTracingHeaders(wrapperRequest, Tracer.getInstance().getCurrentSpan()); // Execute the request/interceptor chain. return execution.executeAsync(wrapperRequest, body); }
/** * Calls {@link WingtipsSpringUtil#propagateTracingHeaders(HttpMessage, Span)} to propagate the current span's * tracing state on the given request's headers, then returns * {@link AsyncClientHttpRequestExecution#executeAsync(HttpRequest, byte[])} to execute the request. * * @return The result of calling {@link AsyncClientHttpRequestExecution#executeAsync(HttpRequest, byte[])}. */ protected ListenableFuture<ClientHttpResponse> propagateTracingHeadersAndExecute( HttpRequestWrapperWithModifiableHeaders wrapperRequest, byte[] body, AsyncClientHttpRequestExecution execution ) throws IOException { propagateTracingHeaders(wrapperRequest, Tracer.getInstance().getCurrentSpan()); // Execute the request/interceptor chain. return execution.executeAsync(wrapperRequest, body); }
/** * Calls {@link WingtipsSpringUtil#propagateTracingHeaders(HttpMessage, Span)} to propagate the current span's * tracing state on the given request's headers, then returns * {@link ClientHttpRequestExecution#execute(HttpRequest, byte[])} to execute the request. * * @return The result of calling {@link ClientHttpRequestExecution#execute(HttpRequest, byte[])}. */ protected ClientHttpResponse propagateTracingHeadersAndExecuteRequest( HttpRequestWrapperWithModifiableHeaders wrapperRequest, byte[] body, ClientHttpRequestExecution execution ) throws IOException { propagateTracingHeaders(wrapperRequest, Tracer.getInstance().getCurrentSpan()); // Execute the request/interceptor chain. return execution.execute(wrapperRequest, body); }
/** * Calls {@link WingtipsSpringUtil#propagateTracingHeaders(HttpMessage, Span)} to propagate the current span's * tracing state on the given request's headers, then returns * {@link ClientHttpRequestExecution#execute(HttpRequest, byte[])} to execute the request. * * @return The result of calling {@link ClientHttpRequestExecution#execute(HttpRequest, byte[])}. */ protected ClientHttpResponse propagateTracingHeadersAndExecuteRequest( HttpRequestWrapperWithModifiableHeaders wrapperRequest, byte[] body, ClientHttpRequestExecution execution ) throws IOException { propagateTracingHeaders(wrapperRequest, Tracer.getInstance().getCurrentSpan()); // Execute the request/interceptor chain. return execution.execute(wrapperRequest, body); }
@DataProvider(value = { "true", "false" }) @Test public void propagateTracingHeaders_only_sends_parent_span_id_header_if_parent_span_id_exists( boolean parentSpanIdExists ) { // given String parentSpanId = (parentSpanIdExists) ? UUID.randomUUID().toString() : null; Span span = Span.newBuilder("foo", SpanPurpose.CLIENT) .withParentSpanId(parentSpanId) .build(); // when WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span); // then if (parentSpanIdExists) { verify(headersMock).set(PARENT_SPAN_ID, parentSpanId); } else { verify(headersMock, never()).set(eq(PARENT_SPAN_ID), anyString()); } }
WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span);
@DataProvider(value = { "true", "false" }) @Test public void propagateTracingHeaders_uses_B3_spec_for_sampleable_header_value( boolean sampleable ) { // given Span span = Span.newBuilder("foo", SpanPurpose.CLIENT) .withSampleable(sampleable) .build(); // when WingtipsSpringUtil.propagateTracingHeaders(httpMessageMock, span); // then verify(headersMock).set(TRACE_SAMPLED, convertSampleableBooleanToExpectedB3Value(span.isSampleable())); }