Source:
public void testSingleFollowsFromRef() { TestTraceReporter reporter = new TestTraceReporter(); APMTracer tracer = new APMTracer(reporter); Span parentSpan = tracer.buildSpan("ParentSpan") .start(); parentSpan.finish(); Span followsFromSpan = tracer.buildSpan("FollowsFromSpan") .addReference(References.FOLLOWS_FROM, parentSpan.context()) .start(); followsFromSpan.finish(); assertEquals(2, reporter.getTraces().size()); Trace parentTrace = reporter.getTraces().get(0); assertEquals(1, parentTrace.getNodes().size()); assertEquals(Component.class, parentTrace.getNodes().get(0).getClass()); Component parentComponent = (Component) parentTrace.getNodes().get(0); assertTrue(parentComponent.getCorrelationIds().isEmpty()); assertEquals(0, parentComponent.getNodes().size()); Trace followsFromTrace = reporter.getTraces().get(1); assertEquals(1, followsFromTrace.getNodes().size()); assertEquals(Consumer.class, followsFromTrace.getNodes().get(0).getClass()); Consumer followsFromConsumer = (Consumer) followsFromTrace.getNodes().get(0); assertEquals(followsFromConsumer.getCorrelationIds().get(0), new CorrelationIdentifier(Scope.CausedBy, parentTrace.getFragmentId() + ":0")); assertEquals(1, followsFromConsumer.getNodes().size()); assertEquals(Component.class, followsFromConsumer.getNodes().get(0).getClass()); Component followsFromComponent = (Component) followsFromConsumer.getNodes().get(0); assertTrue(followsFromComponent.getCorrelationIds().isEmpty()); assertEquals(0, followsFromComponent.getNodes().size()); }

Target:
public void testSingleFollowsFromRef() { TestTraceReporter reporter = new TestTraceReporter(); Tracer tracer = new APMTracer(reporter); Span parentSpan = tracer.buildSpan("ParentSpan") .withTag("http.url", "http://localhost:8080/hello") .start(); parentSpan.finish(); Span followsFromSpan = tracer.buildSpan("FollowsFromSpan") .addReference(References.FOLLOWS_FROM, parentSpan.context()) .start(); followsFromSpan.finish(); assertEquals(2, reporter.getTraces().size()); Trace parentTrace = reporter.getTraces().get(0); assertEquals(1, parentTrace.getNodes().size()); assertEquals(Component.class, parentTrace.getNodes().get(0).getClass()); Component parentComponent = (Component) parentTrace.getNodes().get(0); assertTrue(parentComponent.getCorrelationIds().isEmpty()); assertEquals(0, parentComponent.getNodes().size()); Trace followsFromTrace = reporter.getTraces().get(1); assertEquals(parentTrace.getTraceId(), followsFromTrace.getTraceId()); assertEquals(1, followsFromTrace.getNodes().size()); assertEquals(Consumer.class, followsFromTrace.getNodes().get(0).getClass()); Consumer followsFromConsumer = (Consumer) followsFromTrace.getNodes().get(0); assertEquals("ParentSpan", followsFromConsumer.getOperation()); assertEquals("/hello", followsFromConsumer.getUri()); assertEquals(followsFromConsumer.getCorrelationIds().get(0), new CorrelationIdentifier(Scope.CausedBy, parentTrace.getFragmentId() + ":0")); assertEquals(1, followsFromConsumer.getNodes().size()); assertEquals(Component.class, followsFromConsumer.getNodes().get(0).getClass()); Component followsFromComponent = (Component) followsFromConsumer.getNodes().get(0); assertTrue(followsFromComponent.getCorrelationIds().isEmpty()); assertEquals(0, followsFromComponent.getNodes().size()); }