diff --git a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfilerTest.java b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfilerTest.java index 6471cb684..1cf5ab466 100644 --- a/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfilerTest.java +++ b/inferred-spans/src/test/java/io/opentelemetry/contrib/inferredspans/internal/SamplingProfilerTest.java @@ -177,7 +177,8 @@ void testProfileTransaction() throws Exception { try (Scope scope = tx.makeCurrent()) { // makes sure that the rest will be captured by another profiling session // this tests that restoring which threads to profile works - Thread.sleep(600); + int currentSession = setup.profiler.getProfilingSessions(); + await().until(() -> setup.profiler.getProfilingSessions() > currentSession); profilingActiveOnThread = setup.profiler.isProfilingActiveOnThread(Thread.currentThread()); aInferred(tracer); } finally {