Source:
public void testGetTraceFragmentClientRoot() throws StoreException, InterruptedException { Span rootClientSpan = new Span(); rootClientSpan.setId("root"); rootClientSpan.setTraceId("root"); rootClientSpan.setName("rootClientSpan"); rootClientSpan.setAnnotations(clientAnnotations()); Span serverSpan = new Span(); serverSpan.setId("root"); serverSpan.setParentId("root"); serverSpan.setTraceId("root"); serverSpan.setAnnotations(serverAnnotations()); Span serverSpanDescendantRoot = new Span(); serverSpan.setId("root2"); serverSpan.setParentId("root"); serverSpan.setTraceId("root"); serverSpan.setAnnotations(serverAnnotations()); Span clientSpanOfServerSpanRoot = new Span(); clientSpanOfServerSpanRoot.setId("descendant"); clientSpanOfServerSpanRoot.setParentId("root2"); clientSpanOfServerSpanRoot.setTraceId("root"); clientSpanOfServerSpanRoot.setAnnotations(clientAnnotations()); storeAndWait(null, Arrays.asList( rootClientSpan, serverSpan, serverSpanDescendantRoot, clientSpanOfServerSpanRoot), SpanUniqueIdGenerator::toUnique); Trace trace = spanService.getTraceFragment(null, SpanUniqueIdGenerator.getClientId("root")); Assert.assertEquals("root", trace.getId()); Assert.assertEquals(1, trace.getNodes().size()); InteractionNode rootProducerNode = (InteractionNode) trace.getNodes().get(0); Assert.assertThat(rootProducerNode, instanceOf(Producer.class)); Assert.assertEquals(1, rootProducerNode.getCorrelationIds().size()); Assert.assertEquals("root", rootProducerNode.getCorrelationIds().get(0).getValue()); Assert.assertEquals(1, rootProducerNode.getNodes().size()); Assert.assertEquals(new HashSet<>(Arrays.asList("root2")), extractCorrelationIds(rootProducerNode.getNodes())); InteractionNode descendantConsumerNode = (InteractionNode) rootProducerNode.getNodes().get(0); Assert.assertThat(descendantConsumerNode, instanceOf(Consumer.class)); Assert.assertEquals(1, descendantConsumerNode.getCorrelationIds().size()); Assert.assertEquals("root2", descendantConsumerNode.getCorrelationIds().get(0).getValue()); Assert.assertEquals(0, descendantConsumerNode.getNodes().size()); }

Target:
public void testGetTraceFragmentClientRoot() throws StoreException, InterruptedException { Span rootClientSpan = new Span(); rootClientSpan.setId("root"); rootClientSpan.setTraceId("root"); rootClientSpan.setName("rootClientSpan"); rootClientSpan.setAnnotations(clientAnnotations()); Span serverSpan = new Span(); serverSpan.setId("root"); serverSpan.setTraceId("root"); serverSpan.setAnnotations(serverAnnotations()); Span clientSpanDescendantRoot = new Span(); serverSpan.setId("root2"); serverSpan.setParentId("root"); serverSpan.setTraceId("root"); serverSpan.setAnnotations(clientAnnotations()); Span serverSpanOfClientDescendantRoot = new Span(); serverSpanOfClientDescendantRoot.setId("root2"); serverSpanOfClientDescendantRoot.setParentId("root"); serverSpanOfClientDescendantRoot.setTraceId("root"); serverSpanOfClientDescendantRoot.setAnnotations(serverAnnotations()); storeAndWait(null, Arrays.asList( rootClientSpan, serverSpan, clientSpanDescendantRoot, serverSpanOfClientDescendantRoot), SpanUniqueIdGenerator::toUnique); Trace trace = spanService.getTraceFragment(null, SpanUniqueIdGenerator.getClientId("root")); Assert.assertEquals("root", trace.getId()); Assert.assertEquals(1, trace.getNodes().size()); InteractionNode rootProducerNode = (InteractionNode) trace.getNodes().get(0); Assert.assertThat(rootProducerNode, instanceOf(Producer.class)); Assert.assertEquals(1, rootProducerNode.getCorrelationIds().size()); Assert.assertEquals("root", rootProducerNode.getCorrelationIds().get(0).getValue()); Assert.assertEquals(0, rootProducerNode.getNodes().size()); }