|
6 | 6 | package io.opentelemetry.instrumentation.javahttpclient; |
7 | 7 |
|
8 | 8 | import static io.opentelemetry.api.common.AttributeKey.stringKey; |
| 9 | +import static io.opentelemetry.instrumentation.testing.junit.service.SemconvServiceStabilityUtil.maybeStablePeerService; |
9 | 10 | import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; |
10 | 11 | import static io.opentelemetry.semconv.ErrorAttributes.ERROR_TYPE; |
11 | 12 | import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD; |
@@ -55,6 +56,10 @@ void setUp() { |
55 | 56 |
|
56 | 57 | protected abstract HttpClient configureHttpClient(HttpClient httpClient); |
57 | 58 |
|
| 59 | + protected boolean hasServicePeerName() { |
| 60 | + return false; |
| 61 | + } |
| 62 | + |
58 | 63 | @Override |
59 | 64 | public HttpRequest buildRequest(String method, URI uri, Map<String, String> headers) { |
60 | 65 | HttpRequest.Builder requestBuilder = |
@@ -172,12 +177,15 @@ void cancelRequest() throws InterruptedException { |
172 | 177 | .hasKind(SpanKind.CLIENT) |
173 | 178 | .hasParent(trace.getSpan(0)) |
174 | 179 | .hasStatus(StatusData.error()) |
175 | | - .hasAttributesSatisfying( |
| 180 | + .hasAttributesSatisfyingExactly( |
176 | 181 | equalTo(URL_FULL, uri.toString()), |
177 | 182 | equalTo(SERVER_ADDRESS, uri.getHost()), |
178 | 183 | equalTo(SERVER_PORT, uri.getPort()), |
179 | 184 | equalTo(HTTP_REQUEST_METHOD, method), |
180 | | - equalTo(ERROR_TYPE, CancellationException.class.getName())), |
| 185 | + equalTo(ERROR_TYPE, CancellationException.class.getName()), |
| 186 | + equalTo( |
| 187 | + maybeStablePeerService(), |
| 188 | + hasServicePeerName() ? "test-peer-service" : null)), |
181 | 189 | span -> |
182 | 190 | span.hasName("test-http-server") |
183 | 191 | .hasKind(SpanKind.SERVER) |
|
0 commit comments