Package com.github.kristofa.brave

Examples of com.github.kristofa.brave.SpanId


     *            will be derived from the URI of the request. It is important the used service name should be same on client
     *            as on server side.
     */
    public void handle(final ClientRequestAdapter clientRequestAdapter, final Optional<String> serviceNameOverride) {
        final String spanName = getSpanName(clientRequestAdapter, serviceNameOverride);
        final SpanId newSpanId = clientTracer.startNewSpan(spanName);
        ClientRequestHeaders.addTracingHeaders(clientRequestAdapter, newSpanId, spanName);
        final Optional<String> serviceName = getServiceName(clientRequestAdapter, serviceNameOverride);
        if (serviceName.isPresent()) {
            clientTracer.setCurrentClientServiceName(serviceName.get());
        }
View Full Code Here


        verifyNoMoreInteractions(mockClientTracer);
    }

    @Test
    public void testProcessTracing() throws HttpException, IOException {
        final SpanId spanId = mock(SpanId.class);
        when(spanId.getSpanId()).thenReturn(SPAN_ID);
        when(spanId.getParentSpanId()).thenReturn(PARENT_SPAN_ID);
        when(spanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockClientTracer.startNewSpan(PATH)).thenReturn(spanId);

        interceptor.handle(clientRequestAdapter, Optional.<String>absent());

        final InOrder inOrder = inOrder(mockClientTracer, clientRequestAdapter);
View Full Code Here

        verifyNoMoreInteractions(mockClientTracer, mockSpanNameFilter);
    }

    @Test
    public void testProcessTracingNoParentId() throws HttpException, IOException {
        final SpanId spanId = mock(SpanId.class);
        when(spanId.getSpanId()).thenReturn(SPAN_ID);
        when(spanId.getParentSpanId()).thenReturn(null);
        when(spanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockClientTracer.startNewSpan(PATH)).thenReturn(spanId);

        interceptor.handle(clientRequestAdapter, Optional.<String>absent());

        final InOrder inOrder = inOrder(mockClientTracer, clientRequestAdapter);
View Full Code Here

        verifyNoMoreInteractions(mockClientTracer, mockSpanNameFilter);
    }

    @Test
    public void testHandleTracingWithServiceNameOverride() throws HTTPException, IOException {
        final SpanId spanId = mock(SpanId.class);
        when(spanId.getSpanId()).thenReturn(SPAN_ID);
        when(spanId.getParentSpanId()).thenReturn(PARENT_SPAN_ID);
        when(spanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockClientTracer.startNewSpan(FULL_PATH)).thenReturn(spanId);

        interceptor.handle(clientRequestAdapter, Optional.of(SERVICE_NAME));

        final InOrder inOrder = inOrder(mockClientTracer, clientRequestAdapter);
View Full Code Here

        verifyNoMoreInteractions(mockClientTracer, mockSpanNameFilter);
    }

    @Test
    public void testHandleServiceWithSpanNameFilter() {
        final SpanId spanId = mock(SpanId.class);
        when(spanId.getSpanId()).thenReturn(SPAN_ID);
        when(spanId.getParentSpanId()).thenReturn(PARENT_SPAN_ID);
        when(spanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockClientTracer.startNewSpan(FILTERED_PATH)).thenReturn(spanId);
        when(mockSpanNameFilter.filterSpanName(PATH)).thenReturn(FILTERED_PATH);

        interceptor = new ClientRequestInterceptor(mockClientTracer, Optional.of(mockSpanNameFilter));
        interceptor.handle(clientRequestAdapter, Optional.<String>absent());
View Full Code Here

        verify(clientRequest).addHeader(BraveHttpHeaders.Sampled.getName(), "false");
        verifyNoMoreInteractions(clientRequest);
    }

    private SpanId mockSpan(final long traceId, final long spanId, final Long parentSpanId) {
        final SpanId mockedSpan = mock(SpanId.class);
        when(mockedSpan.getTraceId()).thenReturn(traceId);
        when(mockedSpan.getSpanId()).thenReturn(spanId);
        when(mockedSpan.getParentSpanId()).thenReturn(parentSpanId);
        return mockedSpan;
    }
View Full Code Here

                                 final Boolean sampled) {
        final HttpHeaders mockHttpHeaders = mock(HttpHeaders.class);

        ClientRequest clientRequest = new ClientRequest("test");
        RestEasyClientRequestAdapter request = new RestEasyClientRequestAdapter(clientRequest);
        SpanId span;
        if (sampled) {
            span = mock(SpanId.class);
            when(span.getTraceId()).thenReturn(traceid);
            when(span.getSpanId()).thenReturn(spanId);
            when(span.getParentSpanId()).thenReturn(parentSpanId);
        } else {
            span = null;
        }
        ClientRequestHeaders.addTracingHeaders(request, span, spanName);
View Full Code Here

    }

    @Test
    public void testExecuteTracingNoParentSpan() throws Exception {

        final SpanId mockSpanId = mock(SpanId.class);
        when(mockSpanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockSpanId.getSpanId()).thenReturn(SPAN_ID);
        when(mockSpanId.getParentSpanId()).thenReturn(null);

        when(mockClientTracer.startNewSpan(PATH)).thenReturn(mockSpanId);
        assertSame(mockClientResponse, interceptor.execute(mockExecutionContext));

        final InOrder inOrder = inOrder(mockClientTracer, mockClientRequest, mockExecutionContext);
View Full Code Here

    }

    @Test
    public void testExecuteTracingWithParentSpan() throws Exception {

        final SpanId mockSpanId = mock(SpanId.class);
        when(mockSpanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockSpanId.getSpanId()).thenReturn(SPAN_ID);
        when(mockSpanId.getParentSpanId()).thenReturn(PARENT_SPAN_ID);

        when(mockClientTracer.startNewSpan(PATH)).thenReturn(mockSpanId);
        assertSame(mockClientResponse, interceptor.execute(mockExecutionContext));

        final InOrder inOrder = inOrder(mockClientTracer, mockClientRequest, mockExecutionContext);
View Full Code Here

    }

    @Test
    public void testExecuteHttpCodeNoSuccess() throws Exception {

        final SpanId mockSpanId = mock(SpanId.class);
        when(mockSpanId.getTraceId()).thenReturn(TRACE_ID);
        when(mockSpanId.getSpanId()).thenReturn(SPAN_ID);
        when(mockSpanId.getParentSpanId()).thenReturn(PARENT_SPAN_ID);

        when(mockClientTracer.startNewSpan(PATH)).thenReturn(mockSpanId);
        when(mockClientResponse.getStatus()).thenReturn(SERVER_ERROR_STATUS);

        assertSame(mockClientResponse, interceptor.execute(mockExecutionContext));
View Full Code Here

TOP

Related Classes of com.github.kristofa.brave.SpanId

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.