Java Code Examples for com.amazonaws.xray.AWSXRay#clearTraceEntity()

The following examples show how to use com.amazonaws.xray.AWSXRay#clearTraceEntity() . 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: CustomSegmentContextTest.java    From aws-xray-sdk-java with Apache License 2.0 6 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());

    LocalizedSamplingStrategy defaultSamplingStrategy = new LocalizedSamplingStrategy();
    SegmentContextResolverChain chain = new SegmentContextResolverChain();
    chain.addResolver(new GlobalMapSegmentContextResolver());

    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard()
                                                    .withEmitter(blankEmitter)
                                                    .withSegmentContextResolverChain(chain)
                                                    .withSamplingStrategy(defaultSamplingStrategy)
                                                    .build());
    AWSXRay.clearTraceEntity();
}
 
Example 2
Source File: HttpClientBuilderTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    // Prevent accidental publish to Daemon
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());
    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build());
    AWSXRay.clearTraceEntity();
}
 
Example 3
Source File: TracedResponseHandlerTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());
    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build());
    AWSXRay.clearTraceEntity();
}
 
Example 4
Source File: TracingInterceptorTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());

    AWSXRay.setGlobalRecorder(
            AWSXRayRecorderBuilder.standard()
                    .withEmitter(blankEmitter)
                    .build()
    );
    AWSXRay.clearTraceEntity();
    AWSXRay.beginSegment("test");
}
 
Example 5
Source File: Log4JSegmentListenerTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any());
    Log4JSegmentListener segmentListener = new Log4JSegmentListener();

    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard()
                                                    .withEmitter(blankEmitter)
                                                    .withSegmentListener(segmentListener)
                                                    .build());
    AWSXRay.clearTraceEntity();
    ThreadContext.clearAll();
}
 
Example 6
Source File: SLF4JSegmentListenerTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any());
    SLF4JSegmentListener segmentListener = new SLF4JSegmentListener();

    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).withSegmentListener(segmentListener).build());
    AWSXRay.clearTraceEntity();
    MDC.clear();
}
 
Example 7
Source File: DefaultStreamingStrategyTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    LocalizedSamplingStrategy defaultSamplingStrategy = new LocalizedSamplingStrategy();
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());
    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard()
                                                    .withEmitter(blankEmitter)
                                                    .withSamplingStrategy(defaultSamplingStrategy)
                                                    .build());
    AWSXRay.clearTraceEntity();
}
 
Example 8
Source File: SegmentListenerTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.any());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.any());
    CustomSegmentListener segmentListener = new CustomSegmentListener();

    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard()
                                                    .withEmitter(blankEmitter)
                                                    .withSegmentListener(segmentListener)
                                                    .build());
    AWSXRay.clearTraceEntity();
}
 
Example 9
Source File: LambdaSegmentContextTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());
    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard()
                                                    .withEmitter(blankEmitter)
                                                    .withSamplingStrategy(new LocalizedSamplingStrategy())
                                                    .build());
    AWSXRay.clearTraceEntity();
}
 
Example 10
Source File: TracingHandlerTest.java    From aws-xray-sdk-java with Apache License 2.0 5 votes vote down vote up
@Before
public void setupAWSXRay() {
    Emitter blankEmitter = Mockito.mock(Emitter.class);
    Mockito.doReturn(true).when(blankEmitter).sendSegment(Mockito.anyObject());
    Mockito.doReturn(true).when(blankEmitter).sendSubsegment(Mockito.anyObject());
    AWSXRay.setGlobalRecorder(AWSXRayRecorderBuilder.standard().withEmitter(blankEmitter).build());
    AWSXRay.clearTraceEntity();
}
 
Example 11
Source File: TracingStatementTest.java    From aws-xray-sdk-java with Apache License 2.0 4 votes vote down vote up
@After
public void cleanUp() {
    AWSXRay.clearTraceEntity();
}
 
Example 12
Source File: AWSXRayServletFilterTest.java    From aws-xray-sdk-java with Apache License 2.0 4 votes vote down vote up
@Before
public void setupAWSXRay() {
    AWSXRay.setGlobalRecorder(getMockRecorder());
    AWSXRay.clearTraceEntity();
}