|
6 | 6 | package io.opentelemetry.spring.smoketest; |
7 | 7 |
|
8 | 8 | import static org.assertj.core.api.Assertions.assertThat; |
| 9 | +import static org.awaitility.Awaitility.await; |
9 | 10 |
|
10 | 11 | import io.opentelemetry.api.trace.SpanKind; |
11 | | -import io.opentelemetry.sdk.testing.assertj.TraceAssert; |
12 | 12 | import io.opentelemetry.semconv.HttpAttributes; |
13 | 13 | import org.junit.jupiter.api.Test; |
14 | 14 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -41,18 +41,19 @@ void restClient() { |
41 | 41 | .body(String.class)) |
42 | 42 | .isEqualTo("pong"); |
43 | 43 |
|
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))); |
57 | 58 | } |
58 | 59 | } |
0 commit comments