Java Code Examples for com.amazonaws.xray.entities.Subsegment#setStartTime()
The following examples show how to use
com.amazonaws.xray.entities.Subsegment#setStartTime() .
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: EntityTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@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); }
Example 2
Source File: EntityTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testManuallySetEntityEndTime() { Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", new TraceID()); Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment); segment.addSubsegment(subsegment); double endTime = 20.0d; segment.setStartTime(1.0); subsegment.setStartTime(1.0); segment.setEndTime(endTime); subsegment.setEndTime(endTime); subsegment.end(); segment.end(); Assert.assertEquals(endTime, segment.getEndTime(), 0); Assert.assertEquals(endTime, subsegment.getEndTime(), 0); }
Example 3
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testingBasicStreamingFunctionality() { DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1); TraceID traceId = new TraceID(); Segment segment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "test", traceId); Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment); Subsegment subsegment1 = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "test", segment); segment.addSubsegment(subsegment); segment.addSubsegment(subsegment1); segment.setStartTime(1.0); subsegment.setStartTime(1.0); subsegment1.setStartTime(1.0); subsegment.end(); defaultStreamingStrategy.streamSome(segment, AWSXRay.getGlobalRecorder().getEmitter()); Assert.assertTrue(segment.getTotalSize().intValue() == 1); }
Example 4
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testStreamSomeChildrenRemovedFromParent() { TraceID traceId = new TraceID(); DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1); Segment bigSegment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "big", traceId); bigSegment.setStartTime(1.0); for (int i = 0; i < 5; i++) { Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "child" + i, bigSegment); subsegment.setStartTime(1.0); bigSegment.addSubsegment(subsegment); subsegment.end(); } Assert.assertTrue(defaultStreamingStrategy.requiresStreaming(bigSegment)); defaultStreamingStrategy.streamSome(bigSegment, AWSXRay.getGlobalRecorder().getEmitter()); Assert.assertTrue(bigSegment.getTotalSize().intValue() == 0); }
Example 5
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 6 votes |
@Test public void testStreamSomeChildrenNotRemovedFromParent() { TraceID traceId = new TraceID(); DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1); Segment bigSegment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "big", traceId); bigSegment.setStartTime(1.0); for (int i = 0; i < 5; i++) { Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "child" + i, bigSegment); subsegment.setStartTime(1.0); bigSegment.addSubsegment(subsegment); } Assert.assertTrue(defaultStreamingStrategy.requiresStreaming(bigSegment)); defaultStreamingStrategy.streamSome(bigSegment, AWSXRay.getGlobalRecorder().getEmitter()); Assert.assertTrue(bigSegment.getTotalSize().intValue() == 5); }
Example 6
Source File: EntityTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testInProgressSubsegment() throws JSONException { Segment parent = AWSXRay.beginSegment("test"); Subsegment subsegment = AWSXRay.beginSubsegment("test"); subsegment.setStartTime(1.0); String expected = expectedInProgressSubsegment(parent.getTraceId(), parent.getId(), subsegment.getId(), subsegment.getStartTime()).toString(); JSONAssert.assertEquals(expected, subsegment.streamSerialize(), JSONCompareMode.NON_EXTENSIBLE); }
Example 7
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 5 votes |
@Test public void testBushyandSpindlySegmentTreeStreaming() { TraceID traceId = new TraceID(); Segment bigSegment = new SegmentImpl(AWSXRay.getGlobalRecorder(), "big", traceId); bigSegment.setStartTime(1.0); for (int i = 0; i < 5; i++) { Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "child" + i, bigSegment); subsegment.setStartTime(1.0); bigSegment.addSubsegment(subsegment); subsegment.end(); } SubsegmentImpl holder = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "big_child0", bigSegment); holder.setStartTime(1.0); bigSegment.addSubsegment(holder); holder.end(); SubsegmentImpl holder1 = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "big_child1", bigSegment); holder1.setStartTime(1.0); bigSegment.addSubsegment(holder1); holder1.end(); SubsegmentImpl holder2 = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "big_child2", bigSegment); holder2.setStartTime(1.0); bigSegment.addSubsegment(holder2); holder2.end(); DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1); Assert.assertTrue(defaultStreamingStrategy.requiresStreaming(bigSegment)); defaultStreamingStrategy.streamSome(bigSegment, AWSXRay.getGlobalRecorder().getEmitter()); Assert.assertTrue(bigSegment.getReferenceCount() == 0); }
Example 8
Source File: DefaultStreamingStrategyTest.java From aws-xray-sdk-java with Apache License 2.0 | 4 votes |
@Test public void testMultithreadedStreamSome() { DefaultStreamingStrategy defaultStreamingStrategy = new DefaultStreamingStrategy(1); Segment segment = AWSXRay.beginSegment("big"); Subsegment subsegment = new SubsegmentImpl(AWSXRay.getGlobalRecorder(), "subsegment1", segment); subsegment.setStartTime(1.0); segment.addSubsegment(subsegment); subsegment.end(); Thread thread1 = new Thread(() -> { AWSXRay.setTraceEntity(segment); AWSXRay.beginSubsegment("thread1"); AWSXRay.endSubsegment(); }); Thread thread2 = new Thread(() -> { AWSXRay.setTraceEntity(segment); AWSXRay.beginSubsegment("thread2"); AWSXRay.endSubsegment(); }); thread1.start(); thread2.start(); for (Thread thread : new Thread[]{thread1, thread2}) { try { thread.join(); } catch (InterruptedException e) { return; } } Assert.assertTrue(AWSXRay.getTraceEntity().getName().equals("big")); //asserts that all subsegments are added correctly. Assert.assertTrue(AWSXRay.getTraceEntity().getTotalSize().intValue() == 3); defaultStreamingStrategy.streamSome(segment, AWSXRay.getGlobalRecorder().getEmitter()); Assert.assertTrue(segment.getTotalSize().intValue() == 0); }