diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java index 4228ec796777..9419d083f8d3 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpClientTest.java @@ -1072,6 +1072,19 @@ protected SpanDataAssert assertClientSpan( .hasKind(SpanKind.CLIENT) .hasAttributesSatisfying( attrs -> { + // Check for peer.service when running with javaagent instrumentation + String distroName = + span.actual() + .getResource() + .getAttribute(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME); + if ("opentelemetry-java-instrumentation".equals(distroName)) { + String expectedPeerService = options.getExpectedPeerServiceName().apply(uri); + if (expectedPeerService != null) { + assertThat(attrs) + .containsEntry(PeerIncubatingAttributes.PEER_SERVICE, expectedPeerService); + } + } + // we're opting out of these attributes in the new semconv assertThat(attrs) .doesNotContainKey(NetworkAttributes.NETWORK_TRANSPORT) @@ -1153,21 +1166,6 @@ protected SpanDataAssert assertClientSpan( } else { assertThat(attrs).doesNotContainKey(HttpAttributes.HTTP_REQUEST_RESEND_COUNT); } - }) - .satisfies( - spanData -> { - // Check for peer.service when running with javaagent instrumentation - String distroName = - spanData - .getResource() - .getAttribute(TelemetryIncubatingAttributes.TELEMETRY_DISTRO_NAME); - if ("opentelemetry-java-instrumentation".equals(distroName)) { - String expectedPeerService = options.getExpectedPeerServiceName().apply(uri); - if (expectedPeerService != null) { - assertThat(spanData.getAttributes()) - .containsEntry(PeerIncubatingAttributes.PEER_SERVICE, expectedPeerService); - } - } }); }