Source:
public void testGetCompletionTimeMultiFragment() throws Exception { long baseTime=TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) - 4000; Trace trace1 = new Trace(); trace1.setId("1"); trace1.setBusinessTransaction(TESTAPP); trace1.setStartTime(baseTime); Consumer c1 = new Consumer(); c1.setUri("originuri2"); c1.setDuration(1000000000); c1.setBaseTime(1); Producer p1 = new Producer(); p1.setUri("testuri2"); p1.setDuration(1000000000); c1.setBaseTime(1); p1.addInteractionCorrelationId("interaction2"); c1.getNodes().add(p1); trace1.getNodes().add(c1); Trace trace2 = new Trace(); trace2.setId("2"); trace2.setBusinessTransaction(TESTAPP); trace2.setStartTime(baseTime + 1000); Consumer c2 = new Consumer(); c2.setUri("testuri2"); c2.setDuration(500000000); c2.setBaseTime(1); c2.addInteractionCorrelationId("interaction2"); Component comp2 = new Component(); comp2.setDuration(1500000000); comp2.setBaseTime(1); c2.getNodes().add(comp2); trace2.getNodes().add(c2); List<Trace> traces = new ArrayList<Trace>(); traces.add(trace1); traces.add(trace2); assertEquals(1000000000, trace1.calculateDuration()); assertEquals(1500000000, trace2.calculateDuration()); tracePublisher.publish(null, traces); Wait.until(() -> traceService.searchFragments(null, new Criteria()).size() == 2); Wait.until(() -> analyticsService.getTraceCompletionTimes(null, new Criteria()).size() == 1); List<Trace> result = traceService.searchFragments(null, new Criteria()); assertEquals(2, result.size()); Criteria criteria = new Criteria(); criteria.setBusinessTransaction(TESTAPP).setStartTime(0).setEndTime(0); Wait.until(() -> analyticsService.getTraceCompletionTimeseriesStatistics(null, criteria, 10000).size() == 1); List<CompletionTimeseriesStatistics> stats = analyticsService .getTraceCompletionTimeseriesStatistics(null, criteria, 10000); assertNotNull(stats); assertEquals(1, stats.size()); assertEquals(1749999999, stats.get(0).getAverage()); assertEquals(1, stats.get(0).getCount()); }

Target:
public void testGetCompletionTimeMultiFragment() throws Exception { long baseTime=TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis()) - FOUR_MS_IN_MICRO_SEC; Trace trace1 = new Trace(); trace1.setId("1"); trace1.setBusinessTransaction(TESTAPP); trace1.setStartTime(baseTime); Consumer c1 = new Consumer(); c1.setUri("originuri2"); c1.setDuration(1000000); c1.setBaseTime(1); Producer p1 = new Producer(); p1.setUri("testuri2"); p1.setDuration(1000000); c1.setBaseTime(1); p1.addInteractionCorrelationId("interaction2"); c1.getNodes().add(p1); trace1.getNodes().add(c1); Trace trace2 = new Trace(); trace2.setId("2"); trace2.setBusinessTransaction(TESTAPP); trace2.setStartTime(baseTime + 1000); Consumer c2 = new Consumer(); c2.setUri("testuri2"); c2.setDuration(500000); c2.setBaseTime(1); c2.addInteractionCorrelationId("interaction2"); Component comp2 = new Component(); comp2.setDuration(1500000); comp2.setBaseTime(1); c2.getNodes().add(comp2); trace2.getNodes().add(c2); List<Trace> traces = new ArrayList<Trace>(); traces.add(trace1); traces.add(trace2); assertEquals(1000000, trace1.calculateDuration()); assertEquals(1500000, trace2.calculateDuration()); tracePublisher.publish(null, traces); Wait.until(() -> traceService.searchFragments(null, new Criteria()).size() == 2); Wait.until(() -> analyticsService.getTraceCompletionTimes(null, new Criteria()).size() == 1); List<Trace> result = traceService.searchFragments(null, new Criteria()); assertEquals(2, result.size()); Criteria criteria = new Criteria(); criteria.setBusinessTransaction(TESTAPP).setStartTime(0).setEndTime(0); Wait.until(() -> analyticsService.getTraceCompletionTimeseriesStatistics(null, criteria, 10000).size() == 1); List<CompletionTimeseriesStatistics> stats = analyticsService .getTraceCompletionTimeseriesStatistics(null, criteria, 10000); assertNotNull(stats); assertEquals(1, stats.size()); assertEquals(1749999, stats.get(0).getAverage()); assertEquals(1, stats.get(0).getCount()); }