From 9e12723ab53bd2a028987575ceb3778caf2df32c Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Sep 2023 08:09:38 -0700 Subject: [PATCH] Remove peer service fallback to server.socket.* (#9369) --- .../api/instrumenter/net/PeerServiceAttributesExtractor.java | 3 ++- .../instrumenter/net/PeerServiceAttributesExtractorTest.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java index 8744b5f1845e..6b9853afbf49 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractor.java @@ -9,6 +9,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.Map; import javax.annotation.Nullable; @@ -60,7 +61,7 @@ public void onEnd( String serverAddress = attributesGetter.getServerAddress(request); String peerService = mapToPeerService(serverAddress); - if (peerService == null) { + if (peerService == null && SemconvStability.emitOldHttpSemconv()) { String serverSocketDomain = attributesGetter.getServerSocketDomain(request, response); peerService = mapToPeerService(serverSocketDomain); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractorTest.java index 9ed76b89b598..add7ce0ad049 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/PeerServiceAttributesExtractorTest.java @@ -18,9 +18,11 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import java.util.HashMap; import java.util.Map; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; @@ -101,6 +103,9 @@ void shouldSetPeerNameIfItMatches() { @Test void shouldSetSockPeerNameIfItMatchesAndNoPeerNameProvided() { + + Assumptions.assumeTrue(SemconvStability.emitOldHttpSemconv()); + // given Map peerServiceMapping = new HashMap<>(); peerServiceMapping.put("example.com", "myService");