diff --git a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java index f687364936d60..daf16d9cbbb8d 100644 --- a/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java +++ b/integration-tests/opentelemetry/src/test/java/io/quarkus/it/opentelemetry/AbstractEndUserTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.function.Predicate; import jakarta.enterprise.inject.Instance; @@ -42,7 +43,14 @@ public AbstractEndUserTest(Predicate> predicate) @BeforeEach @AfterEach protected void reset() { - inMemorySpanExporter.reset(); + await().atMost(5, TimeUnit.SECONDS).until(() -> { + // make sure spans from previous tests are not included + List finishedSpanItems = inMemorySpanExporter.getFinishedSpanItems(); + if (finishedSpanItems.size() > 0) { + inMemorySpanExporter.reset(); + } + return finishedSpanItems.size() == 0; + }); } protected List getSpans() {