Skip to content

Instantly share code, notes, and snippets.

@jpkrohling
Last active August 31, 2017 08:19
Show Gist options
  • Select an option

  • Save jpkrohling/f782ab90d05bfac65908b666074606eb to your computer and use it in GitHub Desktop.

Select an option

Save jpkrohling/f782ab90d05bfac65908b666074606eb to your computer and use it in GitHub Desktop.
@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