@Test public void fromHttpServletRequest_creates_span_with_all_values_if_all_values_available_from_request_headers() { given(request.getHeader(TraceHeaders.TRACE_ID)).willReturn(sampleTraceID); given(request.getHeader(TraceHeaders.TRACE_SAMPLED)).willReturn(Boolean.FALSE.toString()); given(request.getHeader(TraceHeaders.SPAN_ID)).willReturn(sampleSpanID); given(request.getHeader(TraceHeaders.PARENT_SPAN_ID)).willReturn(sampleParentSpanID); given(request.getHeader(USER_ID_HEADER_KEY)).willReturn(userId); long beforeCallNanos = System.nanoTime(); Span goodSpan = HttpSpanFactory.fromHttpServletRequest(request, USER_ID_HEADER_KEYS); long afterCallNanos = System.nanoTime(); assertThat(goodSpan.getTraceId()).isEqualTo(sampleTraceID); assertThat(goodSpan.isSampleable()).isFalse(); assertThat(goodSpan.getSpanId()).isEqualTo(sampleSpanID); assertThat(goodSpan.getParentSpanId()).isEqualTo(sampleParentSpanID); assertThat(goodSpan.getUserId()).isEqualTo(userId); assertThat(goodSpan.getSpanStartTimeNanos()).isBetween(beforeCallNanos, afterCallNanos); assertThat(goodSpan.isCompleted()).isFalse(); assertThat(goodSpan.getSpanPurpose()).isEqualTo(SpanPurpose.CLIENT); }
public static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys) { if (servletRequest == null) return null; return HttpRequestTracingUtils.fromRequestWithHeaders(new RequestWithHeadersServletAdapter(servletRequest), userIdHeaderKeys); }
HttpSpanFactory { public static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys) { if (servletRequest == null) return null; return HttpRequestTracingUtils.fromRequestWithHeaders(new RequestWithHeadersServletAdapter(servletRequest), userIdHeaderKeys); } }
HttpSpanFactory { public static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys) { if (servletRequest == null) return null; return HttpRequestTracingUtils.fromRequestWithHeaders(new RequestWithHeadersServletAdapter(servletRequest), userIdHeaderKeys); } private  HttpSpanFactory(); }
HttpSpanFactory { public static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys) { if (servletRequest == null) return null; return HttpRequestTracingUtils.fromRequestWithHeaders(new RequestWithHeadersServletAdapter(servletRequest), userIdHeaderKeys); } private  HttpSpanFactory(); static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys); static String getUserIdFromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys); static @Nullable String determineUriPathTemplate(@Nullable HttpServletRequest request); static @NotNull String getSpanName(@Nullable HttpServletRequest request); }
HttpSpanFactory { public static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys) { if (servletRequest == null) return null; return HttpRequestTracingUtils.fromRequestWithHeaders(new RequestWithHeadersServletAdapter(servletRequest), userIdHeaderKeys); } private  HttpSpanFactory(); static Span fromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys); static String getUserIdFromHttpServletRequest(HttpServletRequest servletRequest, List<String> userIdHeaderKeys); static @Nullable String determineUriPathTemplate(@Nullable HttpServletRequest request); static @NotNull String getSpanName(@Nullable HttpServletRequest request);  }