public class HttpSpanFactory
extends java.lang.Object
Span objects extracted from a HttpServletRequest. NOTE: If a span exists in the request but is not explicitly defined with
TraceHeaders.TRACE_SAMPLED set to false, then fromHttpServletRequest(HttpServletRequest, List) will default it to be sampleable.| Modifier and Type | Method and Description |
|---|---|
static com.nike.wingtips.Span |
fromHttpServletRequest(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys) |
static com.nike.wingtips.Span |
fromHttpServletRequestOrCreateRootSpan(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys) |
static java.lang.String |
getSpanName(javax.servlet.http.HttpServletRequest request) |
static java.lang.String |
getUserIdFromHttpServletRequest(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys)
Attempts to pull a valid ID for the user making the request.
|
public static com.nike.wingtips.Span fromHttpServletRequest(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys)
servletRequest - The incoming request that may have Span information embedded in the headers. If this argument is null then this method will return null.userIdHeaderKeys - This list of header keys will be used to search the request headers for a user ID to set on the returned span. The user ID header keys
will be searched in list order, and the first non-empty user ID header value found will be used as the Span.getUserId().
You can safely pass in null or an empty list for this argument if there is no user ID to extract; if you pass in null then the returned
span's Span.getUserId() will be null.Span stored in the given request's trace headers (e.g. TraceHeaders.TRACE_ID, TraceHeaders.TRACE_SAMPLED,
TraceHeaders.PARENT_SPAN_ID, etc), or null if the request is null or doesn't contain the necessary headers.
TraceHeaders.TRACE_ID is the minimum header needed to return a non-null Span. If TraceHeaders.SPAN_ID
is missing then a new span ID will be generated using TraceAndSpanIdGenerator.generateId().
If TraceHeaders.TRACE_SAMPLED is missing then the returned span will be sampleable. If TraceHeaders.SPAN_NAME
is missing then HttpRequestTracingUtils.UNSPECIFIED_SPAN_NAME will be used as the span name.public static com.nike.wingtips.Span fromHttpServletRequestOrCreateRootSpan(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys)
Span object created from the headers if they exist (see fromHttpServletRequest(HttpServletRequest, List) for details), or if the headers don't
have enough information then this will return a new root span with a span name based on the results of getSpanName(HttpServletRequest) and user ID based
on the result of getUserIdFromHttpServletRequest(HttpServletRequest, List). Since this method is for a server receiving a request
the returned span's Span.getSpanPurpose() will be Span.SpanPurpose.SERVER.public static java.lang.String getUserIdFromHttpServletRequest(javax.servlet.http.HttpServletRequest servletRequest,
java.util.List<java.lang.String> userIdHeaderKeys)
public static java.lang.String getSpanName(javax.servlet.http.HttpServletRequest request)