|
11 | 11 | import io.opentelemetry.sdk.testing.assertj.TraceAssert;
|
12 | 12 | import io.opentelemetry.semconv.HttpAttributes;
|
13 | 13 | import io.opentelemetry.semconv.UrlAttributes;
|
14 |
| -import java.util.function.Consumer; |
15 | 14 | import org.junit.jupiter.api.Test;
|
16 | 15 | import org.springframework.beans.factory.annotation.Autowired;
|
17 | 16 | import org.springframework.boot.test.context.SpringBootTest;
|
@@ -45,23 +44,22 @@ void restClient() {
|
45 | 44 |
|
46 | 45 | if (System.getProperty("org.graalvm.nativeimage.imagecode") != null) {
|
47 | 46 | // ignore the trace for creating the db table
|
48 |
| - testing.waitAndAssertTraces(trace -> {}, assertClient()); |
| 47 | + testing.waitAndAssertTraces(trace -> {}, OtelSpringStarterSmokeTest::assertClient); |
49 | 48 | } else {
|
50 |
| - testing.waitAndAssertTraces(assertClient()); |
| 49 | + testing.waitAndAssertTraces(OtelSpringStarterSmokeTest::assertClient); |
51 | 50 | }
|
52 | 51 | }
|
53 | 52 |
|
54 |
| - private static Consumer<TraceAssert> assertClient() { |
55 |
| - return traceAssert -> |
56 |
| - traceAssert.hasSpansSatisfyingExactly( |
57 |
| - nestedClientSpan -> |
58 |
| - nestedClientSpan |
59 |
| - .hasKind(SpanKind.CLIENT) |
60 |
| - .hasAttributesSatisfying( |
61 |
| - a -> assertThat(a.get(UrlAttributes.URL_FULL)).endsWith("/ping")), |
62 |
| - nestedServerSpan -> |
63 |
| - nestedServerSpan |
64 |
| - .hasKind(SpanKind.SERVER) |
65 |
| - .hasAttribute(HttpAttributes.HTTP_ROUTE, "/ping")); |
| 53 | + private static void assertClient(TraceAssert traceAssert) { |
| 54 | + traceAssert.hasSpansSatisfyingExactly( |
| 55 | + nestedClientSpan -> |
| 56 | + nestedClientSpan |
| 57 | + .hasKind(SpanKind.CLIENT) |
| 58 | + .hasAttributesSatisfying( |
| 59 | + a -> assertThat(a.get(UrlAttributes.URL_FULL)).endsWith("/ping")), |
| 60 | + nestedServerSpan -> |
| 61 | + nestedServerSpan |
| 62 | + .hasKind(SpanKind.SERVER) |
| 63 | + .hasAttribute(HttpAttributes.HTTP_ROUTE, "/ping")); |
66 | 64 | }
|
67 | 65 | }
|
0 commit comments