use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.
the class EntityTest method testSegmentWithSubsegment.
@Test
public void testSegmentWithSubsegment() throws JSONException {
TraceID traceId = new TraceID();
Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", traceId);
Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
segment.addSubsegment(subsegment);
segment.setStartTime(1.0);
subsegment.setStartTime(1.0);
subsegment.end();
segment.end();
String expected = expectedCompletedSegmentWithSubsegment(traceId, segment.getId(), subsegment.getId(), 1.0, subsegment.getEndTime(), segment.getEndTime()).toString();
JSONAssert.assertEquals(expected, segment.serialize(), JSONCompareMode.NON_EXTENSIBLE);
}
use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.
the class EntityTest method testEndingSubsegmentImplAfterStreamingThrowsAlreadyEmittedException.
@Test(expected = AlreadyEmittedException.class)
public void testEndingSubsegmentImplAfterStreamingThrowsAlreadyEmittedException() {
SegmentImpl segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test");
SubsegmentImpl firstSubsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
firstSubsegment.end();
for (int i = 0; i < 100; i++) {
// add enough subsegments to trigger the DefaultStreamingStrategy and stream subsegments
SubsegmentImpl current = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment);
current.end();
}
segment.end();
firstSubsegment.end();
}
use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.
the class EntityTest method testEndingSegmentImplTwiceThrowsAlreadyEmittedException.
@Test(expected = AlreadyEmittedException.class)
public void testEndingSegmentImplTwiceThrowsAlreadyEmittedException() {
SegmentImpl segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test");
segment.getName();
segment.end();
segment.end();
}
use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.
the class DefaultStreamingStrategyTest method testDefaultStreamingStrategyRequiresStreaming.
@Test
public void testDefaultStreamingStrategyRequiresStreaming() {
DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1);
Segment smallSegment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "small");
Assert.assertFalse(defaultStreamingStrategy.requiresStreaming(smallSegment));
Segment bigSegment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "big");
bigSegment.addSubsegment(new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "big_child", bigSegment));
bigSegment.addSubsegment(new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "big_child", bigSegment));
Assert.assertTrue(defaultStreamingStrategy.requiresStreaming(bigSegment));
}
use of com.amazonaws.xray.entities.SegmentImpl in project aws-xray-sdk-java by aws.
the class EntityTest method testAllSegmentImplMutationMethodsThrowAlreadyEmittedExceptions.
@Test
public void testAllSegmentImplMutationMethodsThrowAlreadyEmittedExceptions() {
SegmentImpl segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test");
MutatingMethodCount mutationResults = numberOfMutatingMethodsThatThrewException(segment, SegmentImpl.class);
Assert.assertEquals(0, mutationResults.getMutatingMethodsThrowingExceptions());
segment.end();
mutationResults = numberOfMutatingMethodsThatThrewException(segment, SegmentImpl.class);
Assert.assertEquals(mutationResults.getMutatingMethods(), mutationResults.getMutatingMethodsThrowingExceptions());
}
Aggregations