Java Code Examples for com.nike.wingtips.Span#getUserId()

The following examples show how to use com.nike.wingtips.Span#getUserId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleController.java    From wingtips with Apache License 2.0 6 votes vote down vote up
public EndpointSpanInfoDto(HttpServletRequest request, Span endpoint_execution_span, List<String> userIdHeaderKeys) {
    this.parent_span_info = new SpanInfoDto(
        request.getHeader(TraceHeaders.TRACE_ID),
        request.getHeader(TraceHeaders.SPAN_ID),
        request.getHeader(TraceHeaders.PARENT_SPAN_ID),
        request.getHeader(TraceHeaders.TRACE_SAMPLED),
        HttpSpanFactory.getUserIdFromHttpServletRequest(request, userIdHeaderKeys)
    );
    this.endpoint_execution_span_info = new SpanInfoDto(
        endpoint_execution_span.getTraceId(),
        endpoint_execution_span.getSpanId(),
        endpoint_execution_span.getParentSpanId(),
        String.valueOf(endpoint_execution_span.isSampleable()),
        endpoint_execution_span.getUserId()
    );
}
 
Example 2
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 6 votes vote down vote up
private Pair<Span, Map<String, String>> generateUpstreamSpanHeaders(boolean includeUserId) {
    Span.Builder spanBuilder = Span.newBuilder("upstreamSpan", Span.SpanPurpose.CLIENT);
    if (includeUserId) {
        spanBuilder.withUserId("user-" + UUID.randomUUID().toString());
    }

    Span span = spanBuilder.build();

    MapBuilder<String, String> headersBuilder = MapBuilder
        .builder(TraceHeaders.TRACE_ID, span.getTraceId())
        .put(TraceHeaders.SPAN_ID, span.getSpanId())
        .put(TraceHeaders.SPAN_NAME, span.getSpanName())
        .put(TraceHeaders.TRACE_SAMPLED, String.valueOf(span.isSampleable()));

    if (span.getUserId() != null) {
        headersBuilder.put(USER_ID_HEADER_KEY, span.getUserId());
    }

    return Pair.of(span, headersBuilder.build());
}
 
Example 3
Source File: SampleController.java    From wingtips with Apache License 2.0 6 votes vote down vote up
public EndpointSpanInfoDto(ServerWebExchange exchange, Span endpoint_execution_span, List<String> userIdHeaderKeys) {
    HttpHeaders headers = exchange.getRequest().getHeaders();
    this.parent_span_info = new SpanInfoDto(
        headers.getFirst(TraceHeaders.TRACE_ID),
        headers.getFirst(TraceHeaders.SPAN_ID),
        headers.getFirst(TraceHeaders.PARENT_SPAN_ID),
        headers.getFirst(TraceHeaders.TRACE_SAMPLED),
        HttpRequestTracingUtils.getUserIdFromRequestWithHeaders(
            new RequestWithHeadersServerWebExchangeAdapter(exchange),
            userIdHeaderKeys
        )
    );
    this.endpoint_execution_span_info = new SpanInfoDto(
        endpoint_execution_span.getTraceId(),
        endpoint_execution_span.getSpanId(),
        endpoint_execution_span.getParentSpanId(),
        String.valueOf(endpoint_execution_span.isSampleable()),
        endpoint_execution_span.getUserId()
    );
}
 
Example 4
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 6 votes vote down vote up
private Pair<Span, Map<String, String>> generateUpstreamSpanHeaders(boolean includeUserId) {
    Span.Builder spanBuilder = Span.newBuilder("upstreamSpan", Span.SpanPurpose.CLIENT);
    if (includeUserId) {
        spanBuilder.withUserId("user-" + UUID.randomUUID().toString());
    }

    Span span = spanBuilder.build();

    MapBuilder<String, String> headersBuilder = MapBuilder
        .builder(TraceHeaders.TRACE_ID, span.getTraceId())
        .put(TraceHeaders.SPAN_ID, span.getSpanId())
        .put(TraceHeaders.SPAN_NAME, span.getSpanName())
        .put(TraceHeaders.TRACE_SAMPLED, String.valueOf(span.isSampleable()));

    if (span.getUserId() != null) {
        headersBuilder.put(USER_ID_HEADER_KEY, span.getUserId());
    }

    return Pair.of(span, headersBuilder.build());
}
 
Example 5
Source File: SampleController.java    From wingtips with Apache License 2.0 6 votes vote down vote up
public EndpointSpanInfoDto(HttpServletRequest request, Span endpoint_execution_span, List<String> userIdHeaderKeys) {
    this.parent_span_info = new SpanInfoDto(
        request.getHeader(TraceHeaders.TRACE_ID),
        request.getHeader(TraceHeaders.SPAN_ID),
        request.getHeader(TraceHeaders.PARENT_SPAN_ID),
        request.getHeader(TraceHeaders.TRACE_SAMPLED),
        HttpSpanFactory.getUserIdFromHttpServletRequest(request, userIdHeaderKeys)
    );
    this.endpoint_execution_span_info = new SpanInfoDto(
        endpoint_execution_span.getTraceId(),
        endpoint_execution_span.getSpanId(),
        endpoint_execution_span.getParentSpanId(),
        String.valueOf(endpoint_execution_span.isSampleable()),
        endpoint_execution_span.getUserId()
    );
}
 
Example 6
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 6 votes vote down vote up
private Pair<Span, Map<String, String>> generateUpstreamSpanHeaders(boolean includeUserId) {
    Span.Builder spanBuilder = Span.newBuilder("upstreamSpan", Span.SpanPurpose.CLIENT);
    if (includeUserId) {
        spanBuilder.withUserId("user-" + UUID.randomUUID().toString());
    }

    Span span = spanBuilder.build();

    MapBuilder<String, String> headersBuilder = MapBuilder
        .builder(TraceHeaders.TRACE_ID, span.getTraceId())
        .put(TraceHeaders.SPAN_ID, span.getSpanId())
        .put(TraceHeaders.SPAN_NAME, span.getSpanName())
        .put(TraceHeaders.TRACE_SAMPLED, String.valueOf(span.isSampleable()));

    if (span.getUserId() != null) {
        headersBuilder.put(USER_ID_HEADER_KEY, span.getUserId());
    }

    return Pair.of(span, headersBuilder.build());
}
 
Example 7
Source File: SampleController.java    From wingtips with Apache License 2.0 5 votes vote down vote up
private void addUserIdHeader(HttpHeaders headers, Span overallRequestSpan) {
    String userId = overallRequestSpan.getUserId();

    if (userIdHeaderKeys == null || userIdHeaderKeys.isEmpty() || userId == null) {
        return;
    }

    headers.set(userIdHeaderKeys.get(0), userId);
}
 
Example 8
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 4 votes vote down vote up
private SpanInfoDto spanInfoDtoFromSpan(Span span) {
    return new SpanInfoDto(
        span.getTraceId(), span.getSpanId(), span.getParentSpanId(), String.valueOf(span.isSampleable()),
        span.getUserId()
    );
}
 
Example 9
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 4 votes vote down vote up
private SpanInfoDto spanInfoDtoFromSpan(Span span) {
    return new SpanInfoDto(
        span.getTraceId(), span.getSpanId(), span.getParentSpanId(), String.valueOf(span.isSampleable()),
        span.getUserId()
    );
}
 
Example 10
Source File: VerifySampleEndpointsComponentTest.java    From wingtips with Apache License 2.0 4 votes vote down vote up
private SpanInfoDto spanInfoDtoFromSpan(Span span) {
    return new SpanInfoDto(
        span.getTraceId(), span.getSpanId(), span.getParentSpanId(), String.valueOf(span.isSampleable()),
        span.getUserId()
    );
}