Search in sources :

Example 1 with Emitter

use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.

the class AWSXRayServletFilterTest method setupAWSXRay.

@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();
}
Also used : Emitter(com.amazonaws.xray.emitters.Emitter) Before(org.junit.Before)

Example 2 with Emitter

use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.

the class EntityTest method setupAWSXRay.

@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();
}
Also used : Emitter(com.amazonaws.xray.emitters.Emitter) LocalizedSamplingStrategy(com.amazonaws.xray.strategy.sampling.LocalizedSamplingStrategy) Before(org.junit.Before)

Example 3 with Emitter

use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderTest method testSegmentEmitted.

@Test
public void testSegmentEmitted() {
    Emitter mockEmitter = Mockito.mock(Emitter.class);
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();
    recorder.beginSegment("test");
    recorder.beginSubsegment("test");
    recorder.endSubsegment();
    recorder.endSegment();
    Mockito.verify(mockEmitter, Mockito.times(1)).sendSegment(any());
}
Also used : Emitter(com.amazonaws.xray.emitters.Emitter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with Emitter

use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.

the class AWSXRayRecorderTest method testSubsegmentNotEmittedWithoutExceptionInLambdaInitContext.

@Test
public void testSubsegmentNotEmittedWithoutExceptionInLambdaInitContext() {
    PowerMockito.stub(PowerMockito.method(LambdaSegmentContext.class, "getTraceHeaderFromEnvironment")).toReturn(TraceHeader.fromString(null));
    PowerMockito.stub(PowerMockito.method(LambdaSegmentContextResolver.class, "getLambdaTaskRoot")).toReturn("/var/task");
    Emitter mockEmitter = Mockito.mock(Emitter.class);
    AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();
    recorder.createSubsegment("test", () -> {
    });
    Mockito.verify(mockEmitter, Mockito.times(0)).sendSubsegment(any());
}
Also used : Emitter(com.amazonaws.xray.emitters.Emitter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with Emitter

use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.

the class ConcurrencyTest method setupAWSXRay.

@BeforeEach
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();
}
Also used : Emitter(com.amazonaws.xray.emitters.Emitter) LocalizedSamplingStrategy(com.amazonaws.xray.strategy.sampling.LocalizedSamplingStrategy) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Emitter (com.amazonaws.xray.emitters.Emitter)24 Test (org.junit.Test)8 BeforeEach (org.junit.jupiter.api.BeforeEach)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 LocalizedSamplingStrategy (com.amazonaws.xray.strategy.sampling.LocalizedSamplingStrategy)7 Before (org.junit.Before)6 Subsegment (com.amazonaws.xray.entities.Subsegment)4 TraceHeader (com.amazonaws.xray.entities.TraceHeader)3 SegmentContextResolverChain (com.amazonaws.xray.contexts.SegmentContextResolverChain)1 AWSLogReference (com.amazonaws.xray.entities.AWSLogReference)1 Segment (com.amazonaws.xray.entities.Segment)1 StringValidator (com.amazonaws.xray.entities.StringValidator)1 SegmentListener (com.amazonaws.xray.listeners.SegmentListener)1 EC2Plugin (com.amazonaws.xray.plugins.EC2Plugin)1 ECSPlugin (com.amazonaws.xray.plugins.ECSPlugin)1 EKSPlugin (com.amazonaws.xray.plugins.EKSPlugin)1 ElasticBeanstalkPlugin (com.amazonaws.xray.plugins.ElasticBeanstalkPlugin)1 Plugin (com.amazonaws.xray.plugins.Plugin)1 ContextMissingStrategy (com.amazonaws.xray.strategy.ContextMissingStrategy)1 IgnoreErrorContextMissingStrategy (com.amazonaws.xray.strategy.IgnoreErrorContextMissingStrategy)1