use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.
the class TracedResponseHandlerTest 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();
}
use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.
the class TracingHandlerTest 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();
}
use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testNotSendingUnsampledSegment.
@Test
public void testNotSendingUnsampledSegment() {
Emitter mockEmitter = Mockito.mock(UDPEmitter.class);
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();
Segment segment = recorder.beginSegment("test");
segment.setSampled(false);
recorder.endSegment();
Mockito.verify(mockEmitter, Mockito.times(0)).sendSegment(Mockito.any());
}
use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testDummySegmentNotEmitted.
@Test
public void testDummySegmentNotEmitted() {
Emitter mockEmitter = Mockito.mock(UDPEmitter.class);
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();
recorder.beginDummySegment();
recorder.beginSubsegment("test");
recorder.endSubsegment();
recorder.endSegment();
Mockito.verify(mockEmitter, Mockito.times(0)).sendSegment(Mockito.any());
}
use of com.amazonaws.xray.emitters.Emitter in project aws-xray-sdk-java by aws.
the class AWSXRayRecorderTest method testSubsegmentWithChildEmittedTogetherInLambdaContext.
@Test
public void testSubsegmentWithChildEmittedTogetherInLambdaContext() {
TraceHeader header = TraceHeader.fromString(TRACE_HEADER);
PowerMockito.stub(PowerMockito.method(LambdaSegmentContext.class, "getTraceHeaderFromEnvironment")).toReturn(header);
PowerMockito.stub(PowerMockito.method(LambdaSegmentContextResolver.class, "getLambdaTaskRoot")).toReturn("/var/task");
Emitter mockEmitter = Mockito.mock(UDPEmitter.class);
AWSXRayRecorder recorder = AWSXRayRecorderBuilder.standard().withEmitter(mockEmitter).build();
recorder.createSubsegment("testTogether", () -> {
recorder.createSubsegment("testTogether2", () -> {
});
});
ArgumentCaptor<Subsegment> emittedSubsegment = ArgumentCaptor.forClass(Subsegment.class);
Mockito.verify(mockEmitter, Mockito.times(1)).sendSubsegment(emittedSubsegment.capture());
Subsegment captured = emittedSubsegment.getValue();
Assert.assertEquals(1, captured.getSubsegments().size());
}
Aggregations