@Test public void fromHttpServletRequest_generates_new_spanId_if_missing_from_headers() { String traceId = UUID.randomUUID().toString(); given(request.getHeader(TraceHeaders.TRACE_ID)).willReturn(traceId); Span firstSpan = HttpSpanFactory.fromHttpServletRequest(request, USER_ID_HEADER_KEYS); Span secondSpan = HttpSpanFactory.fromHttpServletRequest(request, USER_ID_HEADER_KEYS); assertThat(firstSpan.getTraceId()).isEqualTo(traceId); assertThat(secondSpan.getTraceId()).isEqualTo(traceId); assertThat(firstSpan.getSpanId()).isNotEmpty(); assertThat(secondSpan.getSpanId()).isNotEmpty(); assertThat(firstSpan.getSpanId()).isNotEqualTo(secondSpan.getSpanId()); }
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);  }