|
26 | 26 | import io.opentelemetry.testing.internal.armeria.common.HttpMethod; |
27 | 27 | import io.opentelemetry.testing.internal.armeria.common.RequestHeaders; |
28 | 28 | import java.util.List; |
29 | | - |
30 | 29 | import org.junit.jupiter.api.AfterAll; |
31 | 30 | import org.junit.jupiter.api.BeforeEach; |
32 | 31 | import org.junit.jupiter.api.Test; |
@@ -101,26 +100,31 @@ void smokeTest() { |
101 | 100 | .aggregate() |
102 | 101 | .join(); |
103 | 102 |
|
104 | | - assertFullTrace(path, response.contentUtf8()); |
| 103 | + assertFullTrace(path, response.contentUtf8(), true); |
105 | 104 | } |
106 | 105 |
|
107 | | - private void assertFullTrace(String path, String responseBody) { |
| 106 | + private void assertFullTrace(String path, String responseBody, boolean captureHeader) { |
108 | 107 | testing() |
109 | 108 | .waitAndAssertTraces( |
110 | 109 | trace -> |
111 | 110 | trace.hasSpansSatisfyingExactly( |
112 | | - span -> assertServerSpan(span, path), |
| 111 | + span -> { |
| 112 | + assertServerSpan(span, path); |
| 113 | + if (captureHeader) { |
| 114 | + span.hasAttribute( |
| 115 | + AttributeKey.stringArrayKey("http.request.header.x-test-request"), |
| 116 | + List.of("test")); |
| 117 | + } |
| 118 | + }, |
113 | 119 | span -> |
114 | 120 | assertSpan(span) |
115 | 121 | .hasName("GET") |
116 | 122 | .hasKind(SpanKind.CLIENT) |
117 | 123 | .hasAttribute( |
118 | | - AttributeKey.stringArrayKey("http.request.header.x-test-request"), |
119 | | - List.of("test")), |
| 124 | + UrlAttributes.URL_FULL, "http://localhost:8080/app/headers"), |
120 | 125 | span -> |
121 | 126 | assertServerSpan(span, "/app/headers") |
122 | | - .hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1") |
123 | | - .hasAttribute(UrlAttributes.URL_FULL, "http://localhost:8080" + path))); |
| 127 | + .hasAttribute(ClientAttributes.CLIENT_ADDRESS, "127.0.0.1"))); |
124 | 128 |
|
125 | 129 | // trace id is present in the HTTP headers as reported by the called endpoint |
126 | 130 | assertThat(responseBody).contains(testing().getSpanTraceIds().iterator().next()); |
@@ -208,7 +212,7 @@ void testRequestOutsideDeployedApplication() { |
208 | 212 | void asyncSmokeTest() { |
209 | 213 | String path = "/app/asyncgreeting"; |
210 | 214 | var response = testing().client().get(path).aggregate().join(); |
211 | | - assertFullTrace(path, response.contentUtf8()); |
| 215 | + assertFullTrace(path, response.contentUtf8(), false); |
212 | 216 | } |
213 | 217 |
|
214 | 218 | @Test |
|
0 commit comments