Search in sources :

Example 1 with DefaultRiposteServerSpanNamingAndTaggingStrategy

use of com.nike.riposte.server.config.distributedtracing.DefaultRiposteServerSpanNamingAndTaggingStrategy in project riposte by Nike-Inc.

the class DTraceStartHandlerTest method beforeMethod.

@Before
public void beforeMethod() {
    channelMock = mock(Channel.class);
    ctxMock = mock(ChannelHandlerContext.class);
    stateAttributeMock = mock(Attribute.class);
    state = new HttpProcessingState();
    httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/some/uri");
    requestInfoMock = mock(RequestInfo.class);
    doReturn(channelMock).when(ctxMock).channel();
    doReturn(stateAttributeMock).when(channelMock).attr(ChannelAttributes.HTTP_PROCESSING_STATE_ATTRIBUTE_KEY);
    doReturn(state).when(stateAttributeMock).get();
    state.setRequestInfo(requestInfoMock);
    initialSpanNameFromStrategy = new AtomicReference<>("span-name-from-strategy-" + UUID.randomUUID().toString());
    strategyInitialSpanNameMethodCalled = new AtomicBoolean(false);
    strategyRequestTaggingMethodCalled = new AtomicBoolean(false);
    strategyResponseTaggingAndFinalSpanNameMethodCalled = new AtomicBoolean(false);
    strategyInitialSpanNameArgs = new AtomicReference<>(null);
    strategyRequestTaggingArgs = new AtomicReference<>(null);
    strategyResponseTaggingArgs = new AtomicReference<>(null);
    tagAndNamingStrategy = new ArgCapturingHttpTagAndSpanNamingStrategy<>(initialSpanNameFromStrategy, strategyInitialSpanNameMethodCalled, strategyRequestTaggingMethodCalled, strategyResponseTaggingAndFinalSpanNameMethodCalled, strategyInitialSpanNameArgs, strategyRequestTaggingArgs, strategyResponseTaggingArgs);
    tagAndNamingAdapterMock = mock(HttpTagAndSpanNamingAdapter.class);
    distributedTracingConfig = new DistributedTracingConfigImpl<>(new DefaultRiposteServerSpanNamingAndTaggingStrategy(tagAndNamingStrategy, tagAndNamingAdapterMock) {

        @Override
        public boolean shouldAddWireReceiveStartAnnotation() {
            return shouldAddWireReceiveStartAnnotation;
        }

        @Override
        public boolean shouldAddWireReceiveFinishAnnotation() {
            return shouldAddWireReceiveFinishAnnotation;
        }
    }, DefaultRiposteProxyRouterSpanNamingAndTaggingStrategy.getDefaultInstance(), Span.class);
    handler = new DTraceStartHandler(userIdHeaderKeys, distributedTracingConfig);
    resetTracingAndMdc();
}
Also used : Attribute(io.netty.util.Attribute) Channel(io.netty.channel.Channel) HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HttpTagAndSpanNamingAdapter(com.nike.wingtips.tags.HttpTagAndSpanNamingAdapter) RequestInfo(com.nike.riposte.server.http.RequestInfo) Span(com.nike.wingtips.Span) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) DefaultRiposteServerSpanNamingAndTaggingStrategy(com.nike.riposte.server.config.distributedtracing.DefaultRiposteServerSpanNamingAndTaggingStrategy) Before(org.junit.Before)

Example 2 with DefaultRiposteServerSpanNamingAndTaggingStrategy

use of com.nike.riposte.server.config.distributedtracing.DefaultRiposteServerSpanNamingAndTaggingStrategy in project riposte by Nike-Inc.

the class HttpProcessingStateTest method beforeMethod.

@Before
public void beforeMethod() {
    stateSpy = spy(new HttpProcessingState());
    initialSpanNameFromStrategy = new AtomicReference<>("span-name-from-strategy-" + UUID.randomUUID().toString());
    strategyInitialSpanNameMethodCalled = new AtomicBoolean(false);
    strategyRequestTaggingMethodCalled = new AtomicBoolean(false);
    strategyResponseTaggingAndFinalSpanNameMethodCalled = new AtomicBoolean(false);
    strategyInitialSpanNameArgs = new AtomicReference<>(null);
    strategyRequestTaggingArgs = new AtomicReference<>(null);
    strategyResponseTaggingArgs = new AtomicReference<>(null);
    wingtipsStrategy = new ArgCapturingHttpTagAndSpanNamingStrategy<>(initialSpanNameFromStrategy, strategyInitialSpanNameMethodCalled, strategyRequestTaggingMethodCalled, strategyResponseTaggingAndFinalSpanNameMethodCalled, strategyInitialSpanNameArgs, strategyRequestTaggingArgs, strategyResponseTaggingArgs);
    wingtipsAdapterMock = mock(HttpTagAndSpanNamingAdapter.class);
    serverTaggingStrategy = new DefaultRiposteServerSpanNamingAndTaggingStrategy(wingtipsStrategy, wingtipsAdapterMock);
    requestMock = mock(RequestInfo.class);
    responseMock = mock(ResponseInfo.class);
    errorMock = mock(Throwable.class);
    spanMock = mock(Span.class);
    distributedTracingConfigMock = mock(DistributedTracingConfig.class);
    doReturn(serverTaggingStrategy).when(distributedTracingConfigMock).getServerSpanNamingAndTaggingStrategy();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DistributedTracingConfig(com.nike.riposte.server.config.distributedtracing.DistributedTracingConfig) DefaultRiposteServerSpanNamingAndTaggingStrategy(com.nike.riposte.server.config.distributedtracing.DefaultRiposteServerSpanNamingAndTaggingStrategy) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) HttpTagAndSpanNamingAdapter(com.nike.wingtips.tags.HttpTagAndSpanNamingAdapter) Span(com.nike.wingtips.Span) Before(org.junit.Before)

Aggregations

DefaultRiposteServerSpanNamingAndTaggingStrategy (com.nike.riposte.server.config.distributedtracing.DefaultRiposteServerSpanNamingAndTaggingStrategy)2 Span (com.nike.wingtips.Span)2 HttpTagAndSpanNamingAdapter (com.nike.wingtips.tags.HttpTagAndSpanNamingAdapter)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Before (org.junit.Before)2 DistributedTracingConfig (com.nike.riposte.server.config.distributedtracing.DistributedTracingConfig)1 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)1 RequestInfo (com.nike.riposte.server.http.RequestInfo)1 Channel (io.netty.channel.Channel)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)1 Attribute (io.netty.util.Attribute)1 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)1