Last active
August 31, 2017 08:19
-
-
Save jpkrohling/f782ab90d05bfac65908b666074606eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void concurrentParents() { | |
| IntStream.rangeClosed(1, 150).parallel().forEach(i -> { | |
| // each iteration is like a request | |
| try (ActiveSpan parent = tracer.buildSpan("parent_" + i).startActive()) { | |
| jdbcTemplate.execute("select 1"); | |
| } | |
| }); | |
| // for each request, we have one extra span, the jdbc one | |
| assertEquals(300, tracer.finishedSpans().size()); | |
| tracer.finishedSpans() | |
| .stream() | |
| .filter((s) -> s.operationName().startsWith("parent_")) | |
| .forEach(parent -> { | |
| // each parent span should have one and only one child | |
| assertEquals(1, | |
| tracer.finishedSpans() | |
| .stream() | |
| .filter(child -> child.parentId() == parent.context().spanId()) | |
| .count() | |
| ); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment