Skip to content

Commit dc6312a

Browse files
committed
fix
1 parent 4d73e33 commit dc6312a

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

smoke-tests-otel-starter/spring-boot-3.2/src/test/java/io/opentelemetry/spring/smoketest/OtelSpringStarterSmokeTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
package io.opentelemetry.spring.smoketest;
77

88
import static org.assertj.core.api.Assertions.assertThat;
9+
import static org.awaitility.Awaitility.await;
910

1011
import io.opentelemetry.api.trace.SpanKind;
11-
import io.opentelemetry.sdk.testing.assertj.TraceAssert;
1212
import io.opentelemetry.semconv.HttpAttributes;
1313
import org.junit.jupiter.api.Test;
1414
import org.springframework.beans.factory.annotation.Autowired;
@@ -41,18 +41,19 @@ void restClient() {
4141
.body(String.class))
4242
.isEqualTo("pong");
4343

44-
if (System.getProperty("org.graalvm.nativeimage.imagecode") != null) {
45-
// ignore the trace for creating the db table
46-
testing.waitAndAssertTraces(trace -> {}, OtelSpringStarterSmokeTest::assertClient);
47-
} else {
48-
testing.waitAndAssertTraces(OtelSpringStarterSmokeTest::assertClient);
49-
}
50-
}
51-
52-
private static void assertClient(TraceAssert traceAssert) {
53-
traceAssert.hasSpansSatisfyingExactly(
54-
span -> HttpSpanDataAssert.create(span).assertClientGetRequest("/ping"),
55-
span -> span.hasKind(SpanKind.SERVER).hasAttribute(HttpAttributes.HTTP_ROUTE, "/ping"),
56-
span -> withSpanAssert(span));
44+
// ignore the trace for creating the db table
45+
await()
46+
.until(
47+
() ->
48+
testing.getExportedSpans().stream()
49+
.anyMatch(span -> span.getKind() == SpanKind.SERVER));
50+
51+
testing.waitAndAssertTraces(
52+
traceAssert ->
53+
traceAssert.hasSpansSatisfyingExactly(
54+
span -> HttpSpanDataAssert.create(span).assertClientGetRequest("/ping"),
55+
span ->
56+
span.hasKind(SpanKind.SERVER).hasAttribute(HttpAttributes.HTTP_ROUTE, "/ping"),
57+
span -> withSpanAssert(span)));
5758
}
5859
}

0 commit comments

Comments
 (0)