HttpRequestTracingUtils { public static void propagateTracingHeaders(HttpObjectForPropagation httpObjectForPropagation, Span span) { if (span == null || httpObjectForPropagation == null) return; httpObjectForPropagation.setHeader(TRACE_ID, span.getTraceId()); httpObjectForPropagation.setHeader(SPAN_ID, span.getSpanId()); httpObjectForPropagation.setHeader(TRACE_SAMPLED, (span.isSampleable()) ? "1" : "0"); if (span.getParentSpanId() != null) httpObjectForPropagation.setHeader(PARENT_SPAN_ID, span.getParentSpanId()); } private  HttpRequestTracingUtils(); static Span fromRequestWithHeaders(RequestWithHeaders request, List<String> userIdHeaderKeys); static boolean hasInvalidSpanIdBecauseCallerDidNotSendOne(Span span); static boolean hasInvalidParentIdBecauseCallerDidNotSendSpanId(Span span); static String getUserIdFromRequestWithHeaders(RequestWithHeaders request, List<String> userIdHeaderKeys); static void propagateTracingHeaders(HttpObjectForPropagation httpObjectForPropagation, Span span); static String convertSampleableBooleanToExpectedB3Value(boolean sampleable); @SuppressWarnings("ConstantConditions") static @NotNull String generateSafeSpanName(
        @Nullable REQ request,
        @Nullable RES response,
        @NotNull HttpTagAndSpanNamingAdapter<REQ, RES> adapter
    ); static @NotNull String generateSafeSpanName(
        @Nullable String requestHttpMethod,
        @Nullable String pathTemplate,
        @Nullable Integer responseStatusCode
    ); static @NotNull String getFallbackSpanNameForHttpRequest(
        @Nullable String prefix,
        @Nullable String httpMethod
    ); static final String UNSPECIFIED_SPAN_NAME; static final String SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY; static final String CHILD_OF_SPAN_FROM_HEADERS_WHERE_CALLER_DID_NOT_SEND_SPAN_ID_TAG_KEY; }
@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(); HttpRequestTracingUtils.propagateTracingHeaders(httpObjectForPropagationMock, span); if (parentSpanIdExists) { verify(httpObjectForPropagationMock).setHeader(PARENT_SPAN_ID, parentSpanId); } else { verify(httpObjectForPropagationMock, never()).setHeader(eq(PARENT_SPAN_ID), anyString()); } }