From 061dcde38fd24bf87beffb24f814abc8ee26cde7 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 5 Jul 2022 18:30:37 -0700 Subject: [PATCH 01/12] New net conventions: option a --- ...ocketAddressNetClientAttributesGetter.java | 12 ++++++++- .../net/NetClientAttributesExtractor.java | 26 +++++++++++++------ .../net/NetClientAttributesGetter.java | 19 +++++++++++++- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java index 019df5343b14..c53150f8a7a3 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java @@ -44,7 +44,7 @@ public final Integer peerPort(REQUEST request, @Nullable RESPONSE response) { @Override @Nullable - public final String peerIp(REQUEST request, @Nullable RESPONSE response) { + public final String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) { InetSocketAddress address = getAddress(request, response); if (address == null) { return null; @@ -55,4 +55,14 @@ public final String peerIp(REQUEST request, @Nullable RESPONSE response) { } return null; } + + @Nullable + @Override + public Integer sockPeerPort(REQUEST request, @Nullable RESPONSE response) { + InetSocketAddress address = getAddress(request, response); + if (address == null) { + return null; + } + return address.getPort(); + } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java index d28c7d436fba..d0b877a0af5f 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java @@ -7,6 +7,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; @@ -49,17 +50,26 @@ public void onEnd( internalSet(attributes, SemanticAttributes.NET_TRANSPORT, getter.transport(request, response)); - String peerIp = getter.peerIp(request, response); String peerName = getter.peerName(request, response); - - if (peerName != null && !peerName.equals(peerIp)) { - internalSet(attributes, SemanticAttributes.NET_PEER_NAME, peerName); - } - internalSet(attributes, SemanticAttributes.NET_PEER_IP, peerIp); + String sockPeerAddr = getter.sockPeerAddr(request, response); Integer peerPort = getter.peerPort(request, response); - if (peerPort != null && peerPort > 0) { - internalSet(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); + Integer sockPeerPort = getter.sockPeerPort(request, response); + + if (peerName != null && !peerName.equals(sockPeerAddr)) { + internalSet(attributes, SemanticAttributes.NET_PEER_NAME, peerName); + if (peerPort != null && peerPort > 0) { + internalSet(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); + } + internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); + if (sockPeerPort != null && sockPeerPort > 0 && !sockPeerPort.equals(peerPort)) { + internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); + } + } else { + internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); + if (sockPeerPort != null && sockPeerPort > 0) { + internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); + } } } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java index 18d05950c165..9adc30a80f0d 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java @@ -27,5 +27,22 @@ public interface NetClientAttributesGetter { Integer peerPort(REQUEST request, @Nullable RESPONSE response); @Nullable - String peerIp(REQUEST request, @Nullable RESPONSE response); + default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) { + return null; + } + + @Nullable + default Integer sockPeerPort(REQUEST request, @Nullable RESPONSE response) { + return null; + } + + @Nullable + default String sockFamily(REQUEST request, @Nullable RESPONSE response) { + return null; + } + + @Nullable + default String sockPeerName(REQUEST request, @Nullable RESPONSE response) { + return null; + } } From 97f784eaa8849bf863a4a2990bdc422b5518777a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Jul 2022 15:53:34 -0700 Subject: [PATCH 02/12] Feedback + sock.family + sock.peer.name --- ...ocketAddressNetClientAttributesGetter.java | 19 +++++++++++++ .../net/NetClientAttributesExtractor.java | 27 ++++++++++++------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java index c53150f8a7a3..2b5c89ca2347 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java @@ -5,6 +5,8 @@ package io.opentelemetry.instrumentation.api.instrumenter.net; +import java.net.Inet4Address; +import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; import javax.annotation.Nullable; @@ -65,4 +67,21 @@ public Integer sockPeerPort(REQUEST request, @Nullable RESPONSE response) { } return address.getPort(); } + + @Nullable + @Override + public String sockFamily(REQUEST request, @Nullable RESPONSE response) { + InetSocketAddress address = getAddress(request, response); + if (address == null) { + return null; + } + InetAddress remoteAddress = address.getAddress(); + if (remoteAddress instanceof Inet4Address) { + return "inet"; + } + if (remoteAddress instanceof Inet6Address) { + return "inet6"; + } + return null; + } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java index d0b877a0af5f..8555df09fadd 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java @@ -51,24 +51,31 @@ public void onEnd( internalSet(attributes, SemanticAttributes.NET_TRANSPORT, getter.transport(request, response)); String peerName = getter.peerName(request, response); - String sockPeerAddr = getter.sockPeerAddr(request, response); - Integer peerPort = getter.peerPort(request, response); - Integer sockPeerPort = getter.sockPeerPort(request, response); - - if (peerName != null && !peerName.equals(sockPeerAddr)) { + if (peerName != null) { internalSet(attributes, SemanticAttributes.NET_PEER_NAME, peerName); if (peerPort != null && peerPort > 0) { internalSet(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); } + } + + String sockPeerAddr = getter.sockPeerAddr(request, response); + if (sockPeerAddr != null && !sockPeerAddr.equals(peerName)) { internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); - if (sockPeerPort != null && sockPeerPort > 0 && !sockPeerPort.equals(peerPort)) { + + Integer sockPeerPort = getter.sockPeerPort(request, response); + if (sockPeerPort != null && !sockPeerPort.equals(peerPort)) { internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); } - } else { - internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); - if (sockPeerPort != null && sockPeerPort > 0) { - internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); + + internalSet( + attributes, + AttributeKey.stringKey("net.sock.family"), + getter.sockFamily(request, response)); + + String sockPeerName = getter.sockPeerName(request, response); + if (sockPeerName != null && !sockPeerName.equals(peerName)) { + internalSet(attributes, AttributeKey.stringKey("net.sock.peer.name"), sockPeerName); } } } From 1dbe3735dd41521db00b60eafe6061d9fb740b2f Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Jul 2022 16:16:11 -0700 Subject: [PATCH 03/12] peer.service + tests --- .../PeerServiceAttributesExtractor.java | 4 -- .../PeerServiceAttributesExtractorTest.java | 50 ------------------- ...tAddressNetClientAttributesGetterTest.java | 9 +++- .../net/NetClientAttributesExtractorTest.java | 18 ++++--- 4 files changed, 18 insertions(+), 63 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java index 0735bfc02ea7..0de5e562db36 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractor.java @@ -76,10 +76,6 @@ public void onEnd( String peerName = attributesGetter.peerName(request, response); String peerService = mapToPeerService(peerName); - if (peerService == null) { - String peerIp = attributesGetter.peerIp(request, response); - peerService = mapToPeerService(peerIp); - } if (peerService != null) { attributes.put(SemanticAttributes.PEER_SERVICE, peerService); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java index d869c5393859..ac1d5a95d637 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/PeerServiceAttributesExtractorTest.java @@ -70,29 +70,6 @@ void shouldNotSetAnyValueIfPeerNameDoesNotMatch() { assertTrue(endAttributes.build().isEmpty()); } - @Test - void shouldNotSetAnyValueIfPeerIpDoesNotMatch() { - // given - Map peerServiceMapping = singletonMap("1.2.3.4", "myService"); - - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping); - - given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.5"); - - Context context = Context.root(); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, context, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, context, "request", "response", null); - - // then - assertTrue(startAttributes.build().isEmpty()); - assertTrue(endAttributes.build().isEmpty()); - } - @Test void shouldSetPeerNameIfItMatches() { // given @@ -118,31 +95,4 @@ void shouldSetPeerNameIfItMatches() { assertThat(endAttributes.build()) .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "myService")); } - - @Test - void shouldSetPeerIpIfItMatchesAndNameDoesNot() { - // given - Map peerServiceMapping = new HashMap<>(); - peerServiceMapping.put("example.com", "myService"); - peerServiceMapping.put("1.2.3.4", "someOtherService"); - - PeerServiceAttributesExtractor underTest = - new PeerServiceAttributesExtractor<>(netAttributesExtractor, peerServiceMapping); - - given(netAttributesExtractor.peerName(any(), any())).willReturn("test.com"); - given(netAttributesExtractor.peerIp(any(), any())).willReturn("1.2.3.4"); - - Context context = Context.root(); - - // when - AttributesBuilder startAttributes = Attributes.builder(); - underTest.onStart(startAttributes, context, "request"); - AttributesBuilder endAttributes = Attributes.builder(); - underTest.onEnd(endAttributes, context, "request", "response", null); - - // then - assertThat(startAttributes.build()).isEmpty(); - assertThat(endAttributes.build()) - .containsOnly(entry(SemanticAttributes.PEER_SERVICE, "someOtherService")); - } } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java index ad95b8da761f..f67284736fb7 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java @@ -8,10 +8,12 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.net.Inet4Address; import java.net.InetSocketAddress; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -56,6 +58,8 @@ void fullAddress() { InetSocketAddress response = new InetSocketAddress("api.github.com", 456); assertThat(request.getAddress().getHostAddress()).isNotNull(); + boolean ipv4 = response.getAddress() instanceof Inet4Address; + Context context = Context.root(); // when @@ -71,7 +75,10 @@ void fullAddress() { assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_IP, response.getAddress().getHostAddress()), + entry( + AttributeKey.stringKey("net.sock.peer.addr"), + response.getAddress().getHostAddress()), + entry(AttributeKey.stringKey("net.sock.family"), ipv4 ? "inet" : "inet6"), entry(SemanticAttributes.NET_PEER_NAME, "api.github.com"), entry(SemanticAttributes.NET_PEER_PORT, 456L)); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java index ecc25f9d15af..4d7794edb83b 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractorTest.java @@ -8,6 +8,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; @@ -16,6 +17,7 @@ import java.util.Map; import org.junit.jupiter.api.Test; +// TODO (trask) add more test coverage for #6268 class NetClientAttributesExtractorTest { static class TestNetClientAttributesGetter @@ -43,9 +45,9 @@ public Integer peerPort(Map request, Map respons } @Override - public String peerIp(Map request, Map response) { + public String sockPeerAddr(Map request, Map response) { if (response != null) { - return response.get("peerIp"); + return response.get("sockPeerAddr"); } return null; } @@ -58,12 +60,12 @@ void normal() { request.put("transport", "TCP"); request.put("peerName", "github.com"); request.put("peerPort", "123"); - request.put("peerIp", "1.2.3.4"); + request.put("sockPeerAddr", "1.2.3.4"); Map response = new HashMap<>(); response.put("peerName", "opentelemetry.io"); response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); + response.put("sockPeerAddr", "4.3.2.1"); TestNetClientAttributesGetter getter = new TestNetClientAttributesGetter(); NetClientAttributesExtractor, Map> extractor = @@ -85,7 +87,7 @@ void normal() { .containsOnly( entry(SemanticAttributes.NET_PEER_NAME, "opentelemetry.io"), entry(SemanticAttributes.NET_PEER_PORT, 42L), - entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); + entry(AttributeKey.stringKey("net.sock.peer.addr"), "4.3.2.1")); } @Test @@ -94,13 +96,13 @@ public void doesNotSetDuplicateAttributes() { Map request = new HashMap<>(); request.put("transport", "TCP"); request.put("peerName", "1.2.3.4"); - request.put("peerIp", "1.2.3.4"); + request.put("sockPeerAddr", "1.2.3.4"); request.put("peerPort", "123"); Map response = new HashMap<>(); response.put("peerName", "4.3.2.1"); response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); + response.put("sockPeerAddr", "4.3.2.1"); TestNetClientAttributesGetter getter = new TestNetClientAttributesGetter(); NetClientAttributesExtractor, Map> extractor = @@ -121,7 +123,7 @@ public void doesNotSetDuplicateAttributes() { assertThat(endAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_PEER_PORT, 42L), - entry(SemanticAttributes.NET_PEER_IP, "4.3.2.1")); + entry(SemanticAttributes.NET_PEER_NAME, "4.3.2.1")); } @Test From 0f70b6397e9f926b4dbc647df4881588cf166fea Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Jul 2022 16:37:19 -0700 Subject: [PATCH 04/12] server net attributes attempt 1 --- ...etSocketAddressNetServerAttributesGetter.java | 2 +- .../net/NetServerAttributesExtractor.java | 4 ++-- .../net/NetServerAttributesGetter.java | 6 +++--- ...cketAddressNetServerAttributesGetterTest.java | 2 +- .../net/NetServerAttributesExtractorTest.java | 16 ++++++++-------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java index eb0d22a4b19b..4f72613bf284 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java @@ -34,7 +34,7 @@ public final Integer peerPort(REQUEST request) { @Override @Nullable - public final String peerIp(REQUEST request) { + public final String peerName(REQUEST request) { InetSocketAddress address = getAddress(request); if (address == null) { return null; diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java index 9980a1e22511..509eea1fe4f2 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java @@ -37,9 +37,9 @@ private NetServerAttributesExtractor(NetServerAttributesGetter getter) public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { internalSet(attributes, SemanticAttributes.NET_TRANSPORT, getter.transport(request)); - String peerIp = getter.peerIp(request); + String peerName = getter.peerName(request); - internalSet(attributes, SemanticAttributes.NET_PEER_IP, peerIp); + internalSet(attributes, SemanticAttributes.NET_PEER_NAME, peerName); Integer peerPort = getter.peerPort(request); if (peerPort != null && peerPort > 0) { diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index 31d1edea002b..4026d2db7634 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -8,8 +8,8 @@ import javax.annotation.Nullable; /** - * An interface for getting server-based network attributes. It adapts a vendor-specific request - * type into the 3 common attributes (transport, peerPort, peerIp). + * An interface for getting server-based network attributes. It adapts an instrumentation-specific + * request type into the 3 common attributes (transport, peerPort, peerName). * *

Instrumentation authors will create implementations of this interface for their specific * server library/framework. It will be used by the {@link NetServerAttributesExtractor} to obtain @@ -24,5 +24,5 @@ public interface NetServerAttributesGetter { Integer peerPort(REQUEST request); @Nullable - String peerIp(REQUEST request); + String peerName(REQUEST request); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java index b292012b6b3f..ef6e2bcd58d0 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java @@ -65,7 +65,7 @@ void fullAddress() { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_IP, request.getAddress().getHostAddress()), + entry(SemanticAttributes.NET_PEER_NAME, request.getAddress().getHostAddress()), entry(SemanticAttributes.NET_PEER_PORT, 123L)); assertThat(endAttributes.build()).isEmpty(); diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java index 79504e93dac8..be7661dfe0ec 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java @@ -32,8 +32,8 @@ public Integer peerPort(Map request) { } @Override - public String peerIp(Map request) { - return request.get("peerIp"); + public String peerName(Map request) { + return request.get("peerName"); } } @@ -44,12 +44,12 @@ void normal() { request.put("transport", "TCP"); request.put("peerName", "github.com"); request.put("peerPort", "123"); - request.put("peerIp", "1.2.3.4"); + request.put("peerName", "1.2.3.4"); Map response = new HashMap<>(); response.put("peerName", "opentelemetry.io"); response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); + response.put("peerName", "4.3.2.1"); NetServerAttributesExtractor, Map> extractor = createTestExtractor(); @@ -68,7 +68,7 @@ void normal() { .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, "TCP"), entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + entry(SemanticAttributes.NET_PEER_NAME, "1.2.3.4")); assertThat(endAttributes.build()).isEmpty(); } @@ -79,13 +79,13 @@ public void doesNotSetDuplicateAttributes() { Map request = new HashMap<>(); request.put("transport", "TCP"); request.put("peerName", "1.2.3.4"); - request.put("peerIp", "1.2.3.4"); + request.put("peerName", "1.2.3.4"); request.put("peerPort", "123"); Map response = new HashMap<>(); response.put("peerName", "4.3.2.1"); response.put("peerPort", "42"); - response.put("peerIp", "4.3.2.1"); + response.put("peerName", "4.3.2.1"); NetServerAttributesExtractor, Map> extractor = createTestExtractor(); @@ -104,7 +104,7 @@ public void doesNotSetDuplicateAttributes() { .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, "TCP"), entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_IP, "1.2.3.4")); + entry(SemanticAttributes.NET_PEER_NAME, "1.2.3.4")); assertThat(endAttributes.build()).isEmpty(); } From 76198ee768bee1c9dbc0af7503a80402015d4f27 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Jul 2022 19:23:33 -0700 Subject: [PATCH 05/12] server net attributes attempt 2 --- ...ocketAddressNetServerAttributesGetter.java | 4 +- .../net/NetServerAttributesExtractor.java | 11 ++--- .../net/NetServerAttributesGetter.java | 4 +- ...tAddressNetServerAttributesGetterTest.java | 9 ++-- .../net/NetServerAttributesExtractorTest.java | 41 +++++++++---------- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java index 4f72613bf284..bc42a0b21540 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetter.java @@ -24,7 +24,7 @@ public abstract class InetSocketAddressNetServerAttributesGetter @Override @Nullable - public final Integer peerPort(REQUEST request) { + public final Integer sockPeerPort(REQUEST request) { InetSocketAddress address = getAddress(request); if (address == null) { return null; @@ -34,7 +34,7 @@ public final Integer peerPort(REQUEST request) { @Override @Nullable - public final String peerName(REQUEST request) { + public final String sockPeerAddr(REQUEST request) { InetSocketAddress address = getAddress(request); if (address == null) { return null; diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java index 509eea1fe4f2..e7e2aa8da97d 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java @@ -7,6 +7,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; @@ -37,13 +38,13 @@ private NetServerAttributesExtractor(NetServerAttributesGetter getter) public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { internalSet(attributes, SemanticAttributes.NET_TRANSPORT, getter.transport(request)); - String peerName = getter.peerName(request); + String sockPeerAddr = getter.sockPeerAddr(request); - internalSet(attributes, SemanticAttributes.NET_PEER_NAME, peerName); + internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); - Integer peerPort = getter.peerPort(request); - if (peerPort != null && peerPort > 0) { - internalSet(attributes, SemanticAttributes.NET_PEER_PORT, (long) peerPort); + Integer sockPeerPort = getter.sockPeerPort(request); + if (sockPeerPort != null && sockPeerPort > 0) { + internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index 4026d2db7634..2215c09dc753 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -21,8 +21,8 @@ public interface NetServerAttributesGetter { String transport(REQUEST request); @Nullable - Integer peerPort(REQUEST request); + Integer sockPeerPort(REQUEST request); @Nullable - String peerName(REQUEST request); + String sockPeerAddr(REQUEST request); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java index ef6e2bcd58d0..54c35bcae4b0 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetServerAttributesGetterTest.java @@ -8,6 +8,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; @@ -65,8 +66,10 @@ void fullAddress() { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_NAME, request.getAddress().getHostAddress()), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); + entry( + AttributeKey.stringKey("net.sock.peer.addr"), + request.getAddress().getHostAddress()), + entry(AttributeKey.longKey("net.sock.peer.port"), 123L)); assertThat(endAttributes.build()).isEmpty(); } @@ -93,7 +96,7 @@ void unresolved() { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry(SemanticAttributes.NET_PEER_PORT, 123L)); + entry(AttributeKey.longKey("net.sock.peer.port"), 123L)); assertThat(endAttributes.build()).isEmpty(); } diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java index be7661dfe0ec..15a7a708e9d9 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractorTest.java @@ -8,6 +8,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; @@ -27,13 +28,13 @@ public String transport(Map request) { } @Override - public Integer peerPort(Map request) { - return Integer.valueOf(request.get("peerPort")); + public Integer sockPeerPort(Map request) { + return Integer.valueOf(request.get("sockPeerPort")); } @Override - public String peerName(Map request) { - return request.get("peerName"); + public String sockPeerAddr(Map request) { + return request.get("sockPeerAddr"); } } @@ -42,14 +43,12 @@ void normal() { // given Map request = new HashMap<>(); request.put("transport", "TCP"); - request.put("peerName", "github.com"); - request.put("peerPort", "123"); - request.put("peerName", "1.2.3.4"); + request.put("sockPeerPort", "123"); + request.put("sockPeerAddr", "1.2.3.4"); Map response = new HashMap<>(); - response.put("peerName", "opentelemetry.io"); - response.put("peerPort", "42"); - response.put("peerName", "4.3.2.1"); + response.put("sockPeerPort", "42"); + response.put("sockPeerAddr", "4.3.2.1"); NetServerAttributesExtractor, Map> extractor = createTestExtractor(); @@ -67,8 +66,8 @@ void normal() { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, "TCP"), - entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_NAME, "1.2.3.4")); + entry(AttributeKey.longKey("net.sock.peer.port"), 123L), + entry(AttributeKey.stringKey("net.sock.peer.addr"), "1.2.3.4")); assertThat(endAttributes.build()).isEmpty(); } @@ -78,14 +77,12 @@ public void doesNotSetDuplicateAttributes() { // given Map request = new HashMap<>(); request.put("transport", "TCP"); - request.put("peerName", "1.2.3.4"); - request.put("peerName", "1.2.3.4"); - request.put("peerPort", "123"); + request.put("sockPeerAddr", "1.2.3.4"); + request.put("sockPeerPort", "123"); Map response = new HashMap<>(); - response.put("peerName", "4.3.2.1"); - response.put("peerPort", "42"); - response.put("peerName", "4.3.2.1"); + response.put("sockPeerPort", "42"); + response.put("sockPeerAddr", "4.3.2.1"); NetServerAttributesExtractor, Map> extractor = createTestExtractor(); @@ -103,8 +100,8 @@ public void doesNotSetDuplicateAttributes() { assertThat(startAttributes.build()) .containsOnly( entry(SemanticAttributes.NET_TRANSPORT, "TCP"), - entry(SemanticAttributes.NET_PEER_PORT, 123L), - entry(SemanticAttributes.NET_PEER_NAME, "1.2.3.4")); + entry(AttributeKey.longKey("net.sock.peer.port"), 123L), + entry(AttributeKey.stringKey("net.sock.peer.addr"), "1.2.3.4")); assertThat(endAttributes.build()).isEmpty(); } @@ -113,10 +110,10 @@ public void doesNotSetDuplicateAttributes() { public void doesNotSetNegativePort() { // given Map request = new HashMap<>(); - request.put("peerPort", "-42"); + request.put("sockPeerPort", "-42"); Map response = new HashMap<>(); - response.put("peerPort", "-1"); + response.put("sockPeerPort", "-1"); NetServerAttributesExtractor, Map> extractor = createTestExtractor(); From 53be6bbff991fb5051add048e5f2bfe7e6117a3e Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 6 Jul 2022 19:28:38 -0700 Subject: [PATCH 06/12] Javadoc --- .../api/instrumenter/net/NetServerAttributesGetter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index 2215c09dc753..24ddd10feda6 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -9,7 +9,7 @@ /** * An interface for getting server-based network attributes. It adapts an instrumentation-specific - * request type into the 3 common attributes (transport, peerPort, peerName). + * request type into the 3 common attributes (transport, sockPeerPort, sockPeerAddr). * *

Instrumentation authors will create implementations of this interface for their specific * server library/framework. It will be used by the {@link NetServerAttributesExtractor} to obtain From 48bb76f7fa4a1ded05443906c2b3deb5a209d045 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 7 Jul 2022 13:52:11 -0700 Subject: [PATCH 07/12] Revisions --- ...ocketAddressNetClientAttributesGetter.java | 4 ---- .../api/instrumenter/rpc/MetricsView.java | 17 +--------------- .../http/HttpClientMetricsTest.java | 1 - .../http/TemporaryMetricsViewTest.java | 2 -- ...tAddressNetClientAttributesGetterTest.java | 20 ++++++++++--------- .../rpc/RpcClientMetricsTest.java | 3 --- 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java index 2b5c89ca2347..1e4b3f44588e 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetter.java @@ -5,7 +5,6 @@ package io.opentelemetry.instrumentation.api.instrumenter.net; -import java.net.Inet4Address; import java.net.Inet6Address; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -76,9 +75,6 @@ public String sockFamily(REQUEST request, @Nullable RESPONSE response) { return null; } InetAddress remoteAddress = address.getAddress(); - if (remoteAddress instanceof Inet4Address) { - return "inet"; - } if (remoteAddress instanceof Inet6Address) { return "inet6"; } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java index dbf5bd7b5aed..b397c3597538 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/MetricsView.java @@ -20,7 +20,6 @@ final class MetricsView { private static final Set alwaysInclude = buildAlwaysInclude(); private static final Set clientView = buildClientView(); - private static final Set clientFallbackView = buildClientFallbackView(); private static final Set serverView = buildServerView(); private static final Set serverFallbackView = buildServerFallbackView(); @@ -44,16 +43,6 @@ private static Set buildClientView() { return view; } - private static Set buildClientFallbackView() { - // the list of rpc client metrics attributes is from - // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes - Set view = new HashSet<>(alwaysInclude); - view.add(SemanticAttributes.NET_PEER_IP); - view.add(SemanticAttributes.NET_PEER_PORT); - view.add(SemanticAttributes.NET_TRANSPORT); - return view; - } - private static Set buildServerView() { // the list of rpc server metrics attributes is from // https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/semantic_conventions/rpc.md#attributes @@ -78,11 +67,7 @@ private static boolean containsAttribute( } static Attributes applyClientView(Attributes startAttributes, Attributes endAttributes) { - Set fullSet = clientView; - if (!containsAttribute(SemanticAttributes.NET_PEER_NAME, startAttributes, endAttributes)) { - fullSet = clientFallbackView; - } - return applyView(fullSet, startAttributes, endAttributes); + return applyView(clientView, startAttributes, endAttributes); } static Attributes applyServerView(Attributes startAttributes, Attributes endAttributes) { diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsTest.java index fd5491a02fb4..58c2a6ef97b0 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/HttpClientMetricsTest.java @@ -39,7 +39,6 @@ void collectsMetrics() { .put("http.target", "/") .put("http.scheme", "https") .put("net.peer.name", "localhost") - .put("net.peer.ip", "0.0.0.0") .put("net.peer.port", 1234) .put("http.request_content_length", 100) .build(); diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/TemporaryMetricsViewTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/TemporaryMetricsViewTest.java index 7f8383fe2e7d..dcfff6df9f7e 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/TemporaryMetricsViewTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/http/TemporaryMetricsViewTest.java @@ -34,7 +34,6 @@ void shouldApplyClientDurationAndSizeView() { Attributes.builder() .put(SemanticAttributes.HTTP_STATUS_CODE, 500) .put(SemanticAttributes.NET_PEER_NAME, "somehost2") - .put(SemanticAttributes.NET_PEER_IP, "127.0.0.1") .put(SemanticAttributes.NET_PEER_PORT, 443) .build(); @@ -70,7 +69,6 @@ void shouldApplyServerDurationAndSizeView() { Attributes.builder() .put(SemanticAttributes.HTTP_STATUS_CODE, 500) .put(SemanticAttributes.NET_PEER_NAME, "somehost2") - .put(SemanticAttributes.NET_PEER_IP, "127.0.0.1") .put(SemanticAttributes.NET_PEER_PORT, 443) .build(); diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java index f67284736fb7..6cca61591a65 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/net/InetSocketAddressNetClientAttributesGetterTest.java @@ -72,15 +72,17 @@ void fullAddress() { // then assertThat(startAttributes.build()).isEmpty(); - assertThat(endAttributes.build()) - .containsOnly( - entry(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP), - entry( - AttributeKey.stringKey("net.sock.peer.addr"), - response.getAddress().getHostAddress()), - entry(AttributeKey.stringKey("net.sock.family"), ipv4 ? "inet" : "inet6"), - entry(SemanticAttributes.NET_PEER_NAME, "api.github.com"), - entry(SemanticAttributes.NET_PEER_PORT, 456L)); + AttributesBuilder builder = Attributes.builder(); + builder.put(SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP); + builder.put( + AttributeKey.stringKey("net.sock.peer.addr"), response.getAddress().getHostAddress()); + if (!ipv4) { + builder.put(AttributeKey.stringKey("net.sock.family"), "inet6"); + } + builder.put(SemanticAttributes.NET_PEER_NAME, "api.github.com"); + builder.put(SemanticAttributes.NET_PEER_PORT, 456L); + + assertThat(endAttributes.build()).isEqualTo(builder.build()); } @Test diff --git a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcClientMetricsTest.java b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcClientMetricsTest.java index 2189c051d994..295851545797 100644 --- a/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcClientMetricsTest.java +++ b/instrumentation-api-semconv/src/test/java/io/opentelemetry/instrumentation/api/instrumenter/rpc/RpcClientMetricsTest.java @@ -41,14 +41,12 @@ void collectsMetrics() { Attributes responseAttributes1 = Attributes.builder() .put(SemanticAttributes.NET_PEER_NAME, "example.com") - .put(SemanticAttributes.NET_PEER_IP, "127.0.0.1") .put(SemanticAttributes.NET_PEER_PORT, 8080) .put(SemanticAttributes.NET_TRANSPORT, "ip_tcp") .build(); Attributes responseAttributes2 = Attributes.builder() - .put(SemanticAttributes.NET_PEER_IP, "127.0.0.1") .put(SemanticAttributes.NET_PEER_PORT, 8080) .put(SemanticAttributes.NET_TRANSPORT, "ip_tcp") .build(); @@ -121,7 +119,6 @@ void collectsMetrics() { SemanticAttributes.RPC_SERVICE, "myservice.EchoService"), equalTo(SemanticAttributes.RPC_METHOD, "exampleMethod"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), equalTo(SemanticAttributes.NET_PEER_PORT, 8080), equalTo(SemanticAttributes.NET_TRANSPORT, "ip_tcp"))))); } From 74a3f26ce79c52f06d809a78c5bc008efd1bc1e9 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 7 Jul 2022 13:52:28 -0700 Subject: [PATCH 08/12] Apply to instrumentations --- .../client/AkkaHttpNetAttributesGetter.java | 6 - .../apachecamel/RestCamelTest.groovy | 4 +- ...woServicesWithDirectClientCamelTest.groovy | 4 +- .../apachedubbo/v2_7/AbstractDubboTest.groovy | 12 +- ...cheHttpAsyncClientNetAttributesGetter.java | 6 - .../ApacheHttpClientNetAttributesGetter.java | 6 - .../ApacheHttpClientNetAttributesGetter.java | 6 - .../ApacheHttpClientNetAttributesGetter.java | 6 - .../ApacheHttpClientNetAttributesGetter.java | 6 - .../AsyncHttpClientNetAttributesGetter.java | 6 - .../v1_11/AwsSdkNetAttributesGetter.java | 6 - .../v2_2/AwsSdkNetAttributesGetter.java | 6 - .../test/groovy/CassandraClientTest.groovy | 4 +- .../test/groovy/CassandraClientTest.groovy | 4 +- .../v2_0/CouchbaseNetAttributesGetter.java | 6 - ...searchRestNetResponseAttributesGetter.java | 13 ++- .../Elasticsearch5TransportClientTest.groovy | 25 ++-- .../Elasticsearch53TransportClientTest.groovy | 25 ++-- .../Elasticsearch6TransportClientTest.groovy | 10 +- ...cTransportNetResponseAttributesGetter.java | 4 +- .../GoogleHttpClientNetAttributesGetter.java | 6 - .../grizzly/GrizzlyNetAttributesGetter.java | 4 +- .../grpc/v1_6/AbstractGrpcStreamingTest.java | 13 +-- .../grpc/v1_6/AbstractGrpcTest.java | 109 +++--------------- .../HttpUrlNetAttributesGetter.java | 6 - .../JdkHttpNetAttributesGetter.java | 6 - .../v1_1/JaxRsClientNetAttributesGetter.java | 6 - .../src/test/groovy/JaxRsClientTest.groovy | 2 +- .../groovy/AbstractJaxRsHttpServerTest.groovy | 7 +- .../internal/JdbcNetAttributesGetter.java | 6 - .../jedis/v1_4/JedisNetAttributesGetter.java | 6 - .../src/test/groovy/Jedis30ClientTest.groovy | 10 +- .../src/test/groovy/Jedis40ClientTest.groovy | 10 +- .../JettyHttpClientNetAttributesGetter.java | 8 -- .../src/main/groovy/BaseJsfTest.groovy | 4 +- .../JspInstrumentationBasicTests.groovy | 32 ++--- .../JspInstrumentationForwardTests.groovy | 24 ++-- .../v1_0/KtorNetServerAttributesGetter.kt | 4 +- .../v2_0/KtorNetServerAttributesGetter.kt | 4 +- .../KubernetesNetAttributesGetter.java | 6 - .../LettuceConnectNetAttributesGetter.java | 6 - .../LettuceConnectNetAttributesGetter.java | 6 - .../v5_1/LettuceReactiveClientTest.groovy | 4 +- .../v5_1/LettuceNetAttributesGetter.java | 21 +--- .../lettuce/v5_1/OpenTelemetryTracing.java | 15 +-- .../AbstractLettuceAsyncClientTest.groovy | 15 ++- .../AbstractLettuceReactiveClientTest.groovy | 21 ++-- .../AbstractLettuceSyncClientAuthTest.groovy | 5 +- .../v5_1/AbstractLettuceSyncClientTest.groovy | 27 +++-- .../LibertyDispatcherNetAttributesGetter.java | 4 +- .../testing/AbstractMongoClientTest.groovy | 2 +- .../test/groovy/Netty40ClientSslTest.groovy | 8 +- .../groovy/Netty40ConnectionSpanTest.groovy | 4 +- .../test/groovy/Netty41ClientSslTest.groovy | 8 +- .../groovy/Netty41ConnectionSpanTest.groovy | 4 +- .../v2_2/OkHttp2NetAttributesGetter.java | 6 - .../internal/OkHttpNetAttributesGetter.java | 6 - .../RabbitChannelNetAttributesGetter.java | 14 ++- .../RabbitReceiveNetAttributesGetter.java | 14 ++- .../src/test/groovy/RabbitMqTest.groovy | 41 ++++--- .../test/groovy/ReactorRabbitMqTest.groovy | 10 +- .../server/AbstractRatpackRoutesTest.groovy | 6 +- .../RatpackHttpNetAttributesGetter.java | 6 - .../internal/RatpackNetAttributesGetter.java | 4 +- .../ReactorNettyConnectionSpanTest.groovy | 4 +- .../v1_0/ReactorNettyClientSslTest.groovy | 10 +- .../ReactorNettyConnectionSpanTest.groovy | 6 +- .../AbstractRedissonAsyncClientTest.groovy | 11 +- .../groovy/AbstractRedissonClientTest.groovy | 22 ++-- .../v1_0/RestletNetAttributesGetter.java | 4 +- .../internal/RestletNetAttributesGetter.java | 4 +- .../servlet/ServletNetAttributesGetter.java | 4 +- .../src/test/groovy/SparkJavaBasedTest.groovy | 4 +- instrumentation/spring/README.md | 31 ++--- .../spring-boot-autoconfigure/README.md | 5 +- .../SpringIntegrationAndRabbitTest.groovy | 23 ++-- .../test/groovy/ContextPropagationTest.groovy | 13 +-- .../web/SpringWebNetAttributesGetter.java | 6 - .../src/test/groovy/SpringWebfluxTest.groovy | 45 +++----- .../SpringWebfluxNetAttributesGetter.java | 6 - .../SpringWebMvcNetAttributesGetter.java | 4 +- .../common/TomcatNetAttributesGetter.java | 4 +- .../src/test/groovy/UndertowServerTest.groovy | 12 +- .../client/Vertx4NetAttributesGetter.java | 6 - .../VertxReactivePropagationTest.groovy | 10 +- .../VertxReactivePropagationTest.groovy | 10 +- .../test/base/HttpServerTest.groovy | 14 +-- .../junit/http/AbstractHttpClientTest.java | 8 +- .../junit/http/AbstractHttpServerTest.java | 10 +- .../junit/http/HttpServerTestOptions.java | 6 +- 90 files changed, 380 insertions(+), 597 deletions(-) diff --git a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java index d3614e0b20a2..f786b281ea3d 100644 --- a/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java +++ b/instrumentation/akka/akka-http-10.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/akkahttp/client/AkkaHttpNetAttributesGetter.java @@ -27,10 +27,4 @@ public String peerName(HttpRequest httpRequest, @Nullable HttpResponse httpRespo public Integer peerPort(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) { return httpRequest.uri().authority().port(); } - - @Override - @Nullable - public String peerIp(HttpRequest httpRequest, @Nullable HttpResponse httpResponse) { - return null; - } } diff --git a/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.groovy b/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.groovy index 5bd8d77f5ffa..43b04b606088 100644 --- a/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.groovy +++ b/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.groovy @@ -95,8 +95,8 @@ class RestCamelTest extends AgentInstrumentationSpecification implements RetryOn "$SemanticAttributes.HTTP_USER_AGENT" String "$SemanticAttributes.HTTP_FLAVOR" "1.1" "$SemanticAttributes.HTTP_METHOD" "GET" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.HTTP_ROUTE" "/api/{module}/unit/{unitId}" } diff --git a/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.groovy b/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.groovy index 1d71bb4a1b9d..3b4605337756 100644 --- a/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.groovy +++ b/instrumentation/apache-camel-2.20/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/apachecamel/TwoServicesWithDirectClientCamelTest.groovy @@ -128,8 +128,8 @@ class TwoServicesWithDirectClientCamelTest extends AgentInstrumentationSpecifica "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "127.0.0.1:$portTwo" "$SemanticAttributes.HTTP_TARGET" "/serviceTwo" - "$SemanticAttributes.NET_PEER_PORT" Number - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.port" Number + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.HTTP_USER_AGENT" "Jakarta Commons-HttpClient/3.1" "$SemanticAttributes.HTTP_FLAVOR" "1.1" "$SemanticAttributes.NET_TRANSPORT" IP_TCP diff --git a/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTest.groovy b/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTest.groovy index 8dd5784194bd..dbb7893d8167 100644 --- a/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTest.groovy +++ b/instrumentation/apache-dubbo-2.7/testing/src/main/groovy/io/opentelemetry/instrumentation/apachedubbo/v2_7/AbstractDubboTest.groovy @@ -111,9 +111,9 @@ abstract class AbstractDubboTest extends InstrumentationSpecification { "$SemanticAttributes.RPC_SYSTEM" "apache_dubbo" "$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService" "$SemanticAttributes.RPC_METHOD" "hello" - "$SemanticAttributes.NET_PEER_IP" String - "$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String } - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" String + "net.sock.peer.port" Long + "net.sock.family" { it == "inet6" || it == null } } } } @@ -182,9 +182,9 @@ abstract class AbstractDubboTest extends InstrumentationSpecification { "$SemanticAttributes.RPC_SYSTEM" "apache_dubbo" "$SemanticAttributes.RPC_SERVICE" "io.opentelemetry.instrumentation.apachedubbo.v2_7.api.HelloService" "$SemanticAttributes.RPC_METHOD" "hello" - "$SemanticAttributes.NET_PEER_IP" String - "$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String } - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" String + "net.sock.peer.port" Long + "net.sock.family" { it == "inet6" || it == null } } } } diff --git a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java index 68c20fe7d854..da311b325e01 100644 --- a/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java +++ b/instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientNetAttributesGetter.java @@ -28,10 +28,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } - - @Override - @Nullable - public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java index ecda03fac812..04489aa8a1cd 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java +++ b/instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v2_0/ApacheHttpClientNetAttributesGetter.java @@ -32,10 +32,4 @@ public Integer peerPort(HttpMethod request, @Nullable HttpMethod response) { HostConfiguration hostConfiguration = request.getHostConfiguration(); return hostConfiguration != null ? hostConfiguration.getPort() : null; } - - @Override - @Nullable - public String peerIp(HttpMethod request, @Nullable HttpMethod response) { - return null; - } } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java index dfe289d7eafa..f310ae87be0a 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v4_0/ApacheHttpClientNetAttributesGetter.java @@ -28,10 +28,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } - - @Override - @Nullable - public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java index 2e1b1b8df869..27a4176a3384 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java +++ b/instrumentation/apache-httpclient/apache-httpclient-4.3/library/src/main/java/io/opentelemetry/instrumentation/apachehttpclient/v4_3/ApacheHttpClientNetAttributesGetter.java @@ -29,10 +29,4 @@ public String peerName(ApacheHttpClientRequest request, @Nullable HttpResponse r public Integer peerPort(ApacheHttpClientRequest request, @Nullable HttpResponse response) { return request.getPeerPort(); } - - @Override - @Nullable - public String peerIp(ApacheHttpClientRequest request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java index e0eaa8c01aa0..46d30cffd813 100644 --- a/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java +++ b/instrumentation/apache-httpclient/apache-httpclient-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpclient/v5_0/ApacheHttpClientNetAttributesGetter.java @@ -50,10 +50,4 @@ public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) { return null; } } - - @Override - @Nullable - public String peerIp(HttpRequest request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java index 294f6c6e7d33..c5c44f10d8f9 100644 --- a/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java +++ b/instrumentation/async-http-client/async-http-client-1.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/asynchttpclient/v1_9/AsyncHttpClientNetAttributesGetter.java @@ -28,10 +28,4 @@ public String peerName(Request request, @Nullable Response response) { public Integer peerPort(Request request, @Nullable Response response) { return request.getUri().getPort(); } - - @Override - @Nullable - public String peerIp(Request request, @Nullable Response response) { - return null; - } } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java index ee9ec7584106..a681e8836fbd 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkNetAttributesGetter.java @@ -28,10 +28,4 @@ public String peerName(Request request, @Nullable Response response) { public Integer peerPort(Request request, @Nullable Response response) { return request.getEndpoint().getPort(); } - - @Override - @Nullable - public String peerIp(Request request, @Nullable Response response) { - return null; - } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java index 32e89a3f791b..5d597d01d514 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkNetAttributesGetter.java @@ -34,10 +34,4 @@ public Integer peerPort(ExecutionAttributes request, @Nullable SdkHttpResponse r request.getAttribute(TracingExecutionInterceptor.SDK_HTTP_REQUEST_ATTRIBUTE); return httpRequest.port(); } - - @Override - @Nullable - public String peerIp(ExecutionAttributes request, @Nullable SdkHttpResponse response) { - return null; - } } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy index 2d7111cd2a2a..6a94fa8b3de2 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/groovy/CassandraClientTest.groovy @@ -37,7 +37,7 @@ class CassandraClientTest extends AgentInstrumentationSpecification { def setupSpec() { cassandra = new GenericContainer("cassandra:3") - // limit memory usage + // limit memory usage .withEnv("JVM_OPTS", "-Xmx128m -Xms128m") .withExposedPorts(9042) .withLogConsumer(new Slf4jLogConsumer(logger)) @@ -148,8 +148,8 @@ class CassandraClientTest extends AgentInstrumentationSpecification { } attributes { "$SemanticAttributes.NET_PEER_NAME" "localhost" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" cassandraPort + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "cassandra" "$SemanticAttributes.DB_NAME" keyspace "$SemanticAttributes.DB_STATEMENT" statement diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy b/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy index 3711bfd09149..0d5f345082a8 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/test/groovy/CassandraClientTest.groovy @@ -32,7 +32,7 @@ class CassandraClientTest extends AgentInstrumentationSpecification { def setupSpec() { cassandra = new GenericContainer("cassandra:4.0") - // limit memory usage + // limit memory usage .withEnv("JVM_OPTS", "-Xmx128m -Xms128m") .withExposedPorts(9042) .withLogConsumer(new Slf4jLogConsumer(logger)) @@ -121,8 +121,8 @@ class CassandraClientTest extends AgentInstrumentationSpecification { } attributes { "$SemanticAttributes.NET_PEER_NAME" "localhost" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" cassandraPort + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "cassandra" "$SemanticAttributes.DB_NAME" keyspace "$SemanticAttributes.DB_STATEMENT" statement diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetAttributesGetter.java index 2987673e1dfb..582b8eeb2083 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetAttributesGetter.java @@ -30,10 +30,4 @@ public String peerName(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unu public Integer peerPort(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unused) { return couchbaseRequest.getPeerPort(); } - - @Nullable - @Override - public String peerIp(CouchbaseRequestInfo couchbaseRequest, @Nullable Void unused) { - return null; - } } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java index 0b93f3f5ed56..7d3db6ec4e62 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/ElasticsearchRestNetResponseAttributesGetter.java @@ -7,6 +7,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; +import java.net.Inet6Address; import javax.annotation.Nullable; import org.elasticsearch.client.Response; @@ -38,10 +39,20 @@ public Integer peerPort(ElasticsearchRestRequest request, @Nullable Response res @Override @Nullable - public String peerIp(ElasticsearchRestRequest request, @Nullable Response response) { + public String sockPeerAddr(ElasticsearchRestRequest request, @Nullable Response response) { if (response != null && response.getHost().getAddress() != null) { return response.getHost().getAddress().getHostAddress(); } return null; } + + @Nullable + @Override + public String sockFamily( + ElasticsearchRestRequest elasticsearchRestRequest, @Nullable Response response) { + if (response != null && response.getHost().getAddress() instanceof Inet6Address) { + return "inet6"; + } + return null; + } } diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/test/groovy/Elasticsearch5TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/test/groovy/Elasticsearch5TransportClientTest.groovy index 817f0ae13ddb..90f1a1dec413 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/test/groovy/Elasticsearch5TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/test/groovy/Elasticsearch5TransportClientTest.groovy @@ -125,9 +125,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl name "ClusterHealthAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "ClusterHealthAction" "elasticsearch.action" "ClusterHealthAction" @@ -242,9 +243,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl name "CreateIndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "CreateIndexAction" "elasticsearch.action" "CreateIndexAction" @@ -258,9 +260,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" "elasticsearch.action" "GetAction" @@ -289,9 +292,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl name "IndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.host - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.host : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "IndexAction" "elasticsearch.action" "IndexAction" @@ -310,9 +314,10 @@ class Elasticsearch5TransportClientTest extends AbstractElasticsearchTransportCl name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" "elasticsearch.action" "GetAction" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/test/groovy/Elasticsearch53TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/test/groovy/Elasticsearch53TransportClientTest.groovy index 6c5d9390e199..6f065708bf77 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/test/groovy/Elasticsearch53TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/test/groovy/Elasticsearch53TransportClientTest.groovy @@ -131,9 +131,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC kind CLIENT childOf(span(0)) attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "ClusterHealthAction" "elasticsearch.action" "ClusterHealthAction" @@ -247,9 +248,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC name "CreateIndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "CreateIndexAction" "elasticsearch.action" "CreateIndexAction" @@ -263,9 +265,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" "elasticsearch.action" "GetAction" @@ -294,9 +297,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC name "IndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "IndexAction" "elasticsearch.action" "IndexAction" @@ -316,9 +320,10 @@ class Elasticsearch53TransportClientTest extends AbstractElasticsearchTransportC name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.host == tcpPublishAddress.address ? null : tcpPublishAddress.address - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port + "net.sock.peer.addr" tcpPublishAddress.host != tcpPublishAddress.address ? tcpPublishAddress.address : null + "net.sock.family" { it == "inet6" || it == null } "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" "elasticsearch.action" "GetAction" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/test/groovy/Elasticsearch6TransportClientTest.groovy b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/test/groovy/Elasticsearch6TransportClientTest.groovy index 26b182e3b3b1..9065777ad651 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/test/groovy/Elasticsearch6TransportClientTest.groovy +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/test/groovy/Elasticsearch6TransportClientTest.groovy @@ -105,7 +105,7 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl kind CLIENT childOf(span(0)) attributes { - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "ClusterHealthAction" @@ -223,7 +223,7 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl name "CreateIndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "CreateIndexAction" @@ -238,7 +238,7 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" @@ -268,7 +268,7 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl name "IndexAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "IndexAction" @@ -289,7 +289,7 @@ class Elasticsearch6TransportClientTest extends AbstractElasticsearchTransportCl name "GetAction" kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_IP" tcpPublishAddress.address + "$SemanticAttributes.NET_PEER_NAME" tcpPublishAddress.address "$SemanticAttributes.NET_PEER_PORT" tcpPublishAddress.port "$SemanticAttributes.DB_SYSTEM" "elasticsearch" "$SemanticAttributes.DB_OPERATION" "GetAction" diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java index 4af4dd83c4a4..8203698d4a7a 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetResponseAttributesGetter.java @@ -38,10 +38,12 @@ public Integer peerPort(ElasticTransportRequest request, @Nullable ActionRespons @Override @Nullable - public String peerIp(ElasticTransportRequest request, @Nullable ActionResponse response) { + public String sockPeerAddr(ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getAddress(); } return null; } + + // TODO (trask) implement sockFamily } diff --git a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java index 36ab5e41b707..b9decdb47878 100644 --- a/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java +++ b/instrumentation/google-http-client-1.19/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/googlehttpclient/GoogleHttpClientNetAttributesGetter.java @@ -33,10 +33,4 @@ public Integer peerPort(HttpRequest request, @Nullable HttpResponse response) { } return null; } - - @Override - @Nullable - public String peerIp(HttpRequest request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlyNetAttributesGetter.java b/instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlyNetAttributesGetter.java index 12c5014e93a8..8fe5900bc087 100644 --- a/instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlyNetAttributesGetter.java +++ b/instrumentation/grizzly-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlyNetAttributesGetter.java @@ -18,13 +18,13 @@ public String transport(HttpRequestPacket request) { } @Override - public Integer peerPort(HttpRequestPacket request) { + public Integer sockPeerPort(HttpRequestPacket request) { return request.getRemotePort(); } @Nullable @Override - public String peerIp(HttpRequestPacket request) { + public String sockPeerAddr(HttpRequestPacket request) { return request.getRemoteAddress(); } } diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java index f8a2a7e4dfc7..f63f6dc27c9f 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcStreamingTest.java @@ -18,6 +18,7 @@ import io.grpc.ServerBuilder; import io.grpc.Status; import io.grpc.stub.StreamObserver; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.util.ThrowingRunnable; @@ -195,17 +196,9 @@ public void onCompleted() { equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "Conversation"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), - satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, diff --git a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java index ed02d7d5d238..e37514c98f08 100644 --- a/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java +++ b/instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java @@ -40,6 +40,7 @@ import io.grpc.reflection.v1alpha.ServerReflectionRequest; import io.grpc.reflection.v1alpha.ServerReflectionResponse; import io.grpc.stub.StreamObserver; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; @@ -163,17 +164,9 @@ public void sayHello( equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), - satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -349,17 +342,9 @@ public void sayHello( equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured - satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -546,17 +531,9 @@ public void onCompleted() { equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured - satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -707,17 +684,9 @@ public void sayHello( equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), - satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -867,17 +836,9 @@ public void sayHello( equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured - satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -1128,17 +1089,9 @@ public void onCompleted() { equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), - satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -1277,17 +1230,9 @@ public void onCompleted() { equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayMultipleHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured - satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -1426,17 +1371,9 @@ public void onCompleted() { SemanticAttributes.RPC_SERVICE, "grpc.reflection.v1alpha.ServerReflection"), equalTo(SemanticAttributes.RPC_METHOD, "ServerReflectionInfo"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), - satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, @@ -1558,17 +1495,9 @@ public void sayHello( equalTo(SemanticAttributes.RPC_SYSTEM, "grpc"), equalTo(SemanticAttributes.RPC_SERVICE, "example.Greeter"), equalTo(SemanticAttributes.RPC_METHOD, "SayHello"), - equalTo(SemanticAttributes.NET_PEER_IP, "127.0.0.1"), - // net.peer.name resolves to "127.0.0.1" on windows which is same as - // net.peer.ip so then not captured - satisfies( - SemanticAttributes.NET_PEER_NAME, - val -> - val.satisfiesAnyOf( - v -> assertThat(v).isNull(), - v -> assertThat(v).isEqualTo("localhost"))), + equalTo(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"), satisfies( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), val -> assertThat(val).isNotNull()), equalTo( SemanticAttributes.NET_TRANSPORT, diff --git a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java index 1c288e627df8..f03e2f5cf833 100644 --- a/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java +++ b/instrumentation/http-url-connection/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpurlconnection/HttpUrlNetAttributesGetter.java @@ -27,10 +27,4 @@ public String peerName(HttpURLConnection connection, @Nullable Integer status) { public Integer peerPort(HttpURLConnection connection, @Nullable Integer status) { return connection.getURL().getPort(); } - - @Override - @Nullable - public String peerIp(HttpURLConnection connection, @Nullable Integer status) { - return null; - } } diff --git a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java index 854fff392200..53ac02288f0f 100644 --- a/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java +++ b/instrumentation/java-http-client/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/httpclient/JdkHttpNetAttributesGetter.java @@ -51,10 +51,4 @@ public Integer peerPort(HttpRequest httpRequest, @Nullable HttpResponse respo return null; } } - - @Override - @Nullable - public String peerIp(HttpRequest httpRequest, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java index 63f35227ed60..66a69e60c9a7 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java +++ b/instrumentation/jaxrs-client/jaxrs-client-1.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jaxrsclient/v1_1/JaxRsClientNetAttributesGetter.java @@ -33,10 +33,4 @@ public Integer peerPort(ClientRequest request, @Nullable ClientResponse response } return null; } - - @Override - @Nullable - public String peerIp(ClientRequest request, @Nullable ClientResponse response) { - return null; - } } diff --git a/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/src/test/groovy/JaxRsClientTest.groovy b/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/src/test/groovy/JaxRsClientTest.groovy index b221a27a6b42..32df887e8a33 100644 --- a/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/src/test/groovy/JaxRsClientTest.groovy +++ b/instrumentation/jaxrs-client/jaxrs-client-2.0-testing/src/test/groovy/JaxRsClientTest.groovy @@ -110,8 +110,8 @@ abstract class JaxRsClientTest extends HttpClientTest implem attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } "$SemanticAttributes.NET_PEER_PORT" uri.port > 0 ? uri.port : { it == null || it == 443 } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } "$SemanticAttributes.HTTP_URL" "${uri}" "$SemanticAttributes.HTTP_METHOD" method "$SemanticAttributes.HTTP_STATUS_CODE" statusCode diff --git a/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy b/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy index b4b00a04490b..91acbad24ab9 100644 --- a/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy +++ b/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy @@ -9,9 +9,10 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest import io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint import io.opentelemetry.sdk.trace.data.SpanData import io.opentelemetry.semconv.trace.attributes.SemanticAttributes -import java.util.concurrent.TimeUnit import spock.lang.Unroll +import java.util.concurrent.TimeUnit + import static io.opentelemetry.api.trace.SpanKind.INTERNAL import static io.opentelemetry.api.trace.SpanKind.SERVER import static io.opentelemetry.api.trace.StatusCode.ERROR @@ -267,8 +268,8 @@ abstract class AbstractJaxRsHttpServerTest extends HttpServerTest implemen hasNoParent() } attributes { - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } // Optional - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" fullUrl.getScheme() "$SemanticAttributes.HTTP_HOST" fullUrl.getHost() + ":" + fullUrl.getPort() "$SemanticAttributes.HTTP_TARGET" fullUrl.getPath() + (fullUrl.getQuery() != null ? "?" + fullUrl.getQuery() : "") diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java index 67d45f7bc7d1..4cf08505204f 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetAttributesGetter.java @@ -31,10 +31,4 @@ public String peerName(DbRequest request, @Nullable Void unused) { public Integer peerPort(DbRequest request, @Nullable Void unused) { return request.getDbInfo().getPort(); } - - @Nullable - @Override - public String peerIp(DbRequest request, @Nullable Void unused) { - return null; - } } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java index 0e0338016f7e..ab1973760b37 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisNetAttributesGetter.java @@ -25,10 +25,4 @@ public String peerName(JedisRequest request, @Nullable Void unused) { public Integer peerPort(JedisRequest request, @Nullable Void unused) { return request.getConnection().getPort(); } - - @Override - @Nullable - public String peerIp(JedisRequest request, @Nullable Void unused) { - return null; - } } diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/test/groovy/Jedis30ClientTest.groovy b/instrumentation/jedis/jedis-3.0/javaagent/src/test/groovy/Jedis30ClientTest.groovy index 4cdbde99b96e..d2398962f992 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/test/groovy/Jedis30ClientTest.groovy +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/test/groovy/Jedis30ClientTest.groovy @@ -53,7 +53,7 @@ class Jedis30ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_OPERATION" "SET" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -80,7 +80,7 @@ class Jedis30ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_OPERATION" "SET" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -95,7 +95,7 @@ class Jedis30ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_OPERATION" "GET" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -122,7 +122,7 @@ class Jedis30ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_OPERATION" "SET" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -137,7 +137,7 @@ class Jedis30ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_OPERATION" "RANDOMKEY" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/test/groovy/Jedis40ClientTest.groovy b/instrumentation/jedis/jedis-4.0/javaagent/src/test/groovy/Jedis40ClientTest.groovy index 585f548b7d71..94ea0be4cfff 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/test/groovy/Jedis40ClientTest.groovy +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/test/groovy/Jedis40ClientTest.groovy @@ -51,8 +51,8 @@ class Jedis40ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET foo ?" "$SemanticAttributes.DB_OPERATION" "SET" + "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -77,8 +77,8 @@ class Jedis40ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET foo ?" "$SemanticAttributes.DB_OPERATION" "SET" + "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -91,8 +91,8 @@ class Jedis40ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET foo" "$SemanticAttributes.DB_OPERATION" "GET" + "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -117,8 +117,8 @@ class Jedis40ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET foo ?" "$SemanticAttributes.DB_OPERATION" "SET" + "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -131,8 +131,8 @@ class Jedis40ClientTest extends AgentInstrumentationSpecification { "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "RANDOMKEY" "$SemanticAttributes.DB_OPERATION" "RANDOMKEY" + "$SemanticAttributes.NET_PEER_NAME" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } diff --git a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java index 7b52e61c9011..1ac6a689748b 100644 --- a/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java +++ b/instrumentation/jetty-httpclient/jetty-httpclient-9.2/library/src/main/java/io/opentelemetry/instrumentation/jetty/httpclient/v9_2/internal/JettyHttpClientNetAttributesGetter.java @@ -34,12 +34,4 @@ public String peerName(Request request, @Nullable Response response) { public Integer peerPort(Request request, @Nullable Response response) { return request.getPort(); } - - @Override - @Nullable - public String peerIp(Request request, @Nullable Response response) { - // Return null unless the library supports resolution to something similar to SocketAddress - // https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/3012/files#r633188645 - return null; - } } diff --git a/instrumentation/jsf/jsf-common/testing/src/main/groovy/BaseJsfTest.groovy b/instrumentation/jsf/jsf-common/testing/src/main/groovy/BaseJsfTest.groovy index 836785c27d10..6f28adecabef 100644 --- a/instrumentation/jsf/jsf-common/testing/src/main/groovy/BaseJsfTest.groovy +++ b/instrumentation/jsf/jsf-common/testing/src/main/groovy/BaseJsfTest.groovy @@ -98,8 +98,8 @@ abstract class BaseJsfTest extends AgentInstrumentationSpecification implements hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP - "$SemanticAttributes.NET_PEER_PORT" Long - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_METHOD" "GET" "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:$port" } diff --git a/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationBasicTests.groovy b/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationBasicTests.groovy index 68a2a2fcc5d1..f292a4f1a74c 100644 --- a/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationBasicTests.groovy +++ b/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationBasicTests.groovy @@ -90,8 +90,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -148,8 +148,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" "$route?$queryString" @@ -200,8 +200,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -262,8 +262,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { } } attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -328,8 +328,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -375,8 +375,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -454,8 +454,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { status ERROR errorEvent(JasperException, String) attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -502,8 +502,8 @@ class JspInstrumentationBasicTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" "/$jspWebappContext/$staticFile" diff --git a/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationForwardTests.groovy b/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationForwardTests.groovy index b3a97dcc42e8..754a23ac7c23 100644 --- a/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationForwardTests.groovy +++ b/instrumentation/jsp-2.3/javaagent/src/test/groovy/JspInstrumentationForwardTests.groovy @@ -88,8 +88,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -156,8 +156,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -203,8 +203,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -298,8 +298,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { name route kind SERVER attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -379,8 +379,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { status ERROR errorEvent(JasperException, String) attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route @@ -439,8 +439,8 @@ class JspInstrumentationForwardTests extends AgentInstrumentationSpecification { kind SERVER status UNSET attributes { - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" route diff --git a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorNetServerAttributesGetter.kt b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorNetServerAttributesGetter.kt index bc6bd76c10d7..01222d7e2475 100644 --- a/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorNetServerAttributesGetter.kt +++ b/instrumentation/ktor/ktor-1.0/library/src/main/kotlin/io/opentelemetry/instrumentation/ktor/v1_0/KtorNetServerAttributesGetter.kt @@ -15,11 +15,11 @@ internal class KtorNetServerAttributesGetter : NetServerAttributesGetter response) { public Integer peerPort(Request request, @Nullable ApiResponse response) { return request.url().port(); } - - @Nullable - @Override - public String peerIp(Request request, @Nullable ApiResponse response) { - return null; - } } diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java index 6eff970d3cbc..5592d4aec647 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectNetAttributesGetter.java @@ -26,10 +26,4 @@ public String peerName(RedisURI redisUri, @Nullable Void unused) { public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { return redisUri.getPort(); } - - @Override - @Nullable - public String peerIp(RedisURI redisUri, @Nullable Void unused) { - return null; - } } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java index 9a84b513e006..28a33c9b1d3d 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectNetAttributesGetter.java @@ -26,10 +26,4 @@ public String peerName(RedisURI redisUri, @Nullable Void unused) { public Integer peerPort(RedisURI redisUri, @Nullable Void unused) { return redisUri.getPort(); } - - @Override - @Nullable - public String peerIp(RedisURI redisUri, @Nullable Void unused) { - return null; - } } diff --git a/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceReactiveClientTest.groovy b/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceReactiveClientTest.groovy index 46be972eabf0..cb54f0c8722f 100644 --- a/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceReactiveClientTest.groovy +++ b/instrumentation/lettuce/lettuce-5.1/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/lettuce/v5_1/LettuceReactiveClientTest.groovy @@ -46,8 +46,8 @@ class LettuceReactiveClientTest extends AbstractLettuceReactiveClientTest implem attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET a ?" } @@ -65,8 +65,8 @@ class LettuceReactiveClientTest extends AbstractLettuceReactiveClientTest implem attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET a" } diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java index 9e1cd5f15c3e..98ce762d5371 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetAttributesGetter.java @@ -7,12 +7,13 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTransportValues.IP_TCP; -import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.net.InetSocketAddressNetClientAttributesGetter; import io.opentelemetry.instrumentation.lettuce.v5_1.OpenTelemetryTracing.OpenTelemetryEndpoint; +import java.net.InetSocketAddress; import javax.annotation.Nullable; final class LettuceNetAttributesGetter - implements NetClientAttributesGetter { + extends InetSocketAddressNetClientAttributesGetter { @Override public String transport(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { @@ -21,18 +22,8 @@ public String transport(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { @Nullable @Override - public String peerName(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { - return endpoint.name; - } - - @Override - public Integer peerPort(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { - return endpoint.port; - } - - @Nullable - @Override - public String peerIp(OpenTelemetryEndpoint endpoint, @Nullable Void unused) { - return endpoint.ip; + public InetSocketAddress getAddress( + OpenTelemetryEndpoint openTelemetryEndpoint, @Nullable Void unused) { + return openTelemetryEndpoint.address; } } diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java index c58f46da255a..f143b9b6d4ff 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/OpenTelemetryTracing.java @@ -69,10 +69,7 @@ public boolean includeCommandArgsInSpanTags() { @Nullable public Endpoint createEndpoint(SocketAddress socketAddress) { if (socketAddress instanceof InetSocketAddress) { - InetSocketAddress address = (InetSocketAddress) socketAddress; - - String ip = address.getAddress() == null ? null : address.getAddress().getHostAddress(); - return new OpenTelemetryEndpoint(ip, address.getPort(), address.getHostString()); + return new OpenTelemetryEndpoint((InetSocketAddress) socketAddress); } return null; } @@ -113,14 +110,10 @@ public Context getSpanContext() { } static class OpenTelemetryEndpoint implements Endpoint { - @Nullable final String ip; - final int port; - @Nullable final String name; + @Nullable final InetSocketAddress address; - OpenTelemetryEndpoint(@Nullable String ip, int port, @Nullable String name) { - this.ip = ip; - this.port = port; - this.name = name; + OpenTelemetryEndpoint(@Nullable InetSocketAddress address) { + this.address = address; } } diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceAsyncClientTest.groovy b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceAsyncClientTest.groovy index 047bae7631bd..c956b0c8ff9f 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceAsyncClientTest.groovy +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceAsyncClientTest.groovy @@ -33,7 +33,6 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTr abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecification { public static final int DB_INDEX = 0 - public static final String loopback = "127.0.0.1" private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379) @@ -71,7 +70,7 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati host = redisServer.getHost() String dbAddr = host + ":" + port + "/" + DB_INDEX embeddedDbUri = "redis://" + dbAddr - expectedHostAttributeValue = host == loopback ? null : host + expectedHostAttributeValue = host == "127.0.0.1" ? null : host incorrectPort = PortUtils.findOpenPort() String dbAddrNonExistent = host + ":" + incorrectPort + "/" + DB_INDEX @@ -162,8 +161,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET TESTSETKEY ?" } @@ -213,8 +212,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET TESTKEY" } @@ -288,8 +287,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET NON_EXISTENT_KEY" } @@ -352,8 +351,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "RANDOMKEY" "$SemanticAttributes.DB_SYSTEM" "redis" } @@ -419,8 +418,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "HMSET TESTHM firstname ? lastname ? age ?" } @@ -439,8 +438,8 @@ abstract class AbstractLettuceAsyncClientTest extends InstrumentationSpecificati attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "HGETALL TESTHM" } diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceReactiveClientTest.groovy b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceReactiveClientTest.groovy index e040b1b9375d..53de14bf9a09 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceReactiveClientTest.groovy +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceReactiveClientTest.groovy @@ -23,7 +23,6 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTr abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecification { public static final int DB_INDEX = 0 - public static final String loopback = "127.0.0.1" private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379) @@ -48,7 +47,7 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific String host = redisServer.getHost() String dbAddr = host + ":" + port + "/" + DB_INDEX embeddedDbUri = "redis://" + dbAddr - expectedHostAttributeValue = host == loopback ? null : host + expectedHostAttributeValue = host == "127.0.0.1" ? null : host redisClient = createClient(embeddedDbUri) redisClient.setOptions(LettuceTestUtil.CLIENT_OPTIONS) @@ -104,8 +103,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET TESTSETKEY ?" } @@ -142,8 +141,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET TESTKEY" } @@ -193,8 +192,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET NON_EXISTENT_KEY" } @@ -237,8 +236,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "RANDOMKEY" "$SemanticAttributes.DB_SYSTEM" "redis" } @@ -266,8 +265,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "COMMAND" "$SemanticAttributes.DB_SYSTEM" "redis" } @@ -314,8 +313,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET a ?" } @@ -333,8 +332,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET a" } @@ -372,8 +371,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET a ?" } @@ -391,8 +390,8 @@ abstract class AbstractLettuceReactiveClientTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET a" } diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.groovy b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.groovy index b65a77ae4f1c..db9d2b39af72 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.groovy +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientAuthTest.groovy @@ -16,7 +16,6 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NetTr abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecification { public static final int DB_INDEX = 0 - public static final String loopback = "127.0.0.1" private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379) @@ -45,7 +44,7 @@ abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecific String host = redisServer.getHost() String dbAddr = host + ":" + port + "/" + DB_INDEX String embeddedDbUri = "redis://" + dbAddr - expectedHostAttributeValue = host == loopback ? null : host + expectedHostAttributeValue = host == "127.0.0.1" ? null : host redisClient = createClient(embeddedDbUri) redisClient.setOptions(LettuceTestUtil.CLIENT_OPTIONS) @@ -70,8 +69,8 @@ abstract class AbstractLettuceSyncClientAuthTest extends InstrumentationSpecific attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "AUTH ?" } diff --git a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.groovy b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.groovy index 608be43fea0c..fe87c5d80a32 100644 --- a/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.groovy +++ b/instrumentation/lettuce/lettuce-5.1/testing/src/main/groovy/io/opentelemetry/instrumentation/lettuce/v5_1/AbstractLettuceSyncClientTest.groovy @@ -24,7 +24,6 @@ import static java.nio.charset.StandardCharsets.UTF_8 abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecification { public static final int DB_INDEX = 0 - public static final String loopback = "127.0.0.1" private static GenericContainer redisServer = new GenericContainer<>("redis:6.2.3-alpine").withExposedPorts(6379) @@ -58,7 +57,7 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio String dbAddr = host + ":" + port + "/" + DB_INDEX String embeddedDbUri = "redis://" + dbAddr embeddedDbLocalhostUri = "redis://localhost:" + port + "/" + DB_INDEX - expectedHostAttributeValue = host == loopback ? null : host + expectedHostAttributeValue = host == "127.0.0.1" ? null : host int incorrectPort = PortUtils.findOpenPort() String dbAddrNonExistent = host + ":" + incorrectPort + "/" + DB_INDEX @@ -126,8 +125,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET TESTSETKEY ?" } @@ -158,8 +157,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio kind CLIENT attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_NAME" "localhost" + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SET TESTSETKEY ?" @@ -193,8 +192,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET TESTKEY" } @@ -223,8 +222,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "GET NON_EXISTENT_KEY" } @@ -253,8 +252,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "RANDOMKEY" "$SemanticAttributes.DB_SYSTEM" "redis" } @@ -283,8 +282,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "LPUSH TESTLIST ?" } @@ -313,8 +312,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "HMSET user firstname ? lastname ? age ?" } @@ -343,8 +342,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "HGETALL TESTHM" } @@ -378,8 +377,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "EVAL $b64Script 1 TESTLIST ? ?" } @@ -412,8 +411,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "MSET key1 ? key2 ?" } @@ -442,8 +441,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "DEBUG SEGFAULT" } @@ -478,8 +477,8 @@ abstract class AbstractLettuceSyncClientTest extends InstrumentationSpecificatio attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" expectedHostAttributeValue - "$SemanticAttributes.NET_PEER_IP" loopback "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_SYSTEM" "redis" "$SemanticAttributes.DB_STATEMENT" "SHUTDOWN NOSAVE" if (!Boolean.getBoolean("testLatestDeps")) { diff --git a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesGetter.java b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesGetter.java index 50ebb9606dc5..95f447ac41a3 100644 --- a/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesGetter.java +++ b/instrumentation/liberty/liberty-dispatcher/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/liberty/dispatcher/LibertyDispatcherNetAttributesGetter.java @@ -19,13 +19,13 @@ public String transport(LibertyRequest libertyRequest) { @Override @Nullable - public Integer peerPort(LibertyRequest libertyRequest) { + public Integer sockPeerPort(LibertyRequest libertyRequest) { return libertyRequest.peerPort(); } @Override @Nullable - public String peerIp(LibertyRequest libertyRequest) { + public String sockPeerAddr(LibertyRequest libertyRequest) { return libertyRequest.peerIp(); } } diff --git a/instrumentation/mongo/mongo-common/testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy b/instrumentation/mongo/mongo-common/testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy index ef731b217b8a..2166382aa421 100644 --- a/instrumentation/mongo/mongo-common/testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy +++ b/instrumentation/mongo/mongo-common/testing/src/main/groovy/io/opentelemetry/instrumentation/mongo/testing/AbstractMongoClientTest.groovy @@ -388,8 +388,8 @@ abstract class AbstractMongoClientTest extends InstrumentationSpecification { } attributes { "$SemanticAttributes.NET_PEER_NAME" "localhost" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" { statementEval.call(it.replaceAll(" ", "")) } diff --git a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy index e3bbdb15e8ee..eab3a9f3d217 100644 --- a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy +++ b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ClientSslTest.groovy @@ -92,7 +92,7 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(2) { @@ -106,7 +106,7 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } } @@ -148,7 +148,7 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(2) { @@ -159,7 +159,7 @@ class Netty40ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(3) { diff --git a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy index 905c7c6ee5c1..7f7909d910f3 100644 --- a/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy +++ b/instrumentation/netty/netty-4.0/javaagent/src/test/groovy/Netty40ConnectionSpanTest.groovy @@ -108,7 +108,7 @@ class Netty40ConnectionSpanTest extends InstrumentationSpecification implements "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(2) { @@ -156,7 +156,7 @@ class Netty40ConnectionSpanTest extends InstrumentationSpecification implements "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } } diff --git a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy index c521e22cf655..3f760bac6f3d 100644 --- a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy +++ b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ClientSslTest.groovy @@ -106,7 +106,7 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(3) { @@ -120,7 +120,7 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } } @@ -174,7 +174,7 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(3) { @@ -185,7 +185,7 @@ class Netty41ClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } span(4) { diff --git a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy index 496035acf8ae..0ba3d38e379f 100644 --- a/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy +++ b/instrumentation/netty/netty-4.1/javaagent/src/test/groovy/Netty41ConnectionSpanTest.groovy @@ -120,7 +120,7 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(3) { @@ -180,7 +180,7 @@ class Netty41ConnectionSpanTest extends InstrumentationSpecification implements "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" uri.host "$SemanticAttributes.NET_PEER_PORT" uri.port - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } } diff --git a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java index ce2dd1e51522..874dd82591ed 100644 --- a/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java +++ b/instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/OkHttp2NetAttributesGetter.java @@ -29,10 +29,4 @@ public String peerName(Request request, @Nullable Response response) { public Integer peerPort(Request request, @Nullable Response response) { return request.url().getPort(); } - - @Override - @Nullable - public String peerIp(Request request, @Nullable Response response) { - return null; - } } diff --git a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java index 28904beaac2d..318b6d8d9733 100644 --- a/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java +++ b/instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/OkHttpNetAttributesGetter.java @@ -33,10 +33,4 @@ public String peerName(Request request, @Nullable Response response) { public Integer peerPort(Request request, @Nullable Response response) { return request.url().port(); } - - @Override - @Nullable - public String peerIp(Request request, @Nullable Response response) { - return null; - } } diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java index e8b95cb61ffb..3b30d16be2b6 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitChannelNetAttributesGetter.java @@ -6,6 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.rabbitmq; import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; +import java.net.Inet6Address; import javax.annotation.Nullable; public class RabbitChannelNetAttributesGetter @@ -21,7 +22,7 @@ public String transport(ChannelAndMethod channelAndMethod, @Nullable Void unused @Override public String peerName(ChannelAndMethod channelAndMethod, @Nullable Void unused) { // not using InetAddress.getHostName() since that can trigger reverse name lookup - return null; + return channelAndMethod.getChannel().getConnection().getAddress().getHostAddress(); } @Nullable @@ -32,7 +33,16 @@ public Integer peerPort(ChannelAndMethod channelAndMethod, @Nullable Void unused @Nullable @Override - public String peerIp(ChannelAndMethod channelAndMethod, @Nullable Void unused) { + public String sockPeerAddr(ChannelAndMethod channelAndMethod, @Nullable Void unused) { return channelAndMethod.getChannel().getConnection().getAddress().getHostAddress(); } + + @Nullable + @Override + public String sockFamily(ChannelAndMethod channelAndMethod, @Nullable Void unused) { + if (channelAndMethod.getChannel().getConnection().getAddress() instanceof Inet6Address) { + return "inet6"; + } + return null; + } } diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java index d51e752b8a29..a34f22c4bb9a 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java +++ b/instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/RabbitReceiveNetAttributesGetter.java @@ -7,6 +7,7 @@ import com.rabbitmq.client.GetResponse; import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; +import java.net.Inet6Address; import javax.annotation.Nullable; public class RabbitReceiveNetAttributesGetter @@ -22,7 +23,7 @@ public String transport(ReceiveRequest request, @Nullable GetResponse response) @Override public String peerName(ReceiveRequest request, @Nullable GetResponse response) { // not using InetAddress.getHostName() since that can trigger reverse name lookup - return null; + return request.getConnection().getAddress().getHostAddress(); } @Nullable @@ -33,7 +34,16 @@ public Integer peerPort(ReceiveRequest request, @Nullable GetResponse response) @Nullable @Override - public String peerIp(ReceiveRequest request, @Nullable GetResponse response) { + public String sockPeerAddr(ReceiveRequest request, @Nullable GetResponse response) { return request.getConnection().getAddress().getHostAddress(); } + + @Nullable + @Override + public String sockFamily(ReceiveRequest request, @Nullable GetResponse response) { + if (request.getConnection().getAddress() instanceof Inet6Address) { + return "inet6"; + } + return null; + } } diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMqTest.groovy b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMqTest.groovy index 595129218bd7..93c1193c1c2f 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMqTest.groovy +++ b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/RabbitMqTest.groovy @@ -23,7 +23,6 @@ import org.springframework.amqp.rabbit.connection.CachingConnectionFactory import org.springframework.amqp.rabbit.core.RabbitAdmin import org.springframework.amqp.rabbit.core.RabbitTemplate -import static com.google.common.net.InetAddresses.isInetAddress import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.CONSUMER import static io.opentelemetry.api.trace.SpanKind.PRODUCER @@ -307,22 +306,24 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb spanName = spanName + " " + operation } + def spanKind + switch (trace.span(index).attributes.get(AttributeKey.stringKey("rabbitmq.command"))) { + case "basic.publish": + spanKind = PRODUCER + break + case "basic.get": + spanKind = CLIENT + break + case "basic.deliver": + spanKind = CONSUMER + break + default: + spanKind = CLIENT + } + trace.span(index) { name spanName - - switch (trace.span(index).attributes.get(AttributeKey.stringKey("rabbitmq.command"))) { - case "basic.publish": - kind PRODUCER - break - case "basic.get": - kind CLIENT - break - case "basic.deliver": - kind CONSUMER - break - default: - kind CLIENT - } + kind spanKind if (parentSpan) { childOf((SpanData) parentSpan) @@ -340,9 +341,13 @@ class RabbitMqTest extends AgentInstrumentationSpecification implements WithRabb } attributes { - "$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String } - "$SemanticAttributes.NET_PEER_IP" { it == null || isInetAddress(it as String) } - "$SemanticAttributes.NET_PEER_PORT" { it == null || it instanceof Long } + // "localhost" on linux, "127.0.0.1" on windows + if (spanKind != CONSUMER) { + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" } + "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" || it == null } + "net.sock.family" { it == null || it == "inet6" } + } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION" exchange diff --git a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/ReactorRabbitMqTest.groovy b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/ReactorRabbitMqTest.groovy index 2c16bff49dd8..d56fbcee72b8 100644 --- a/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/ReactorRabbitMqTest.groovy +++ b/instrumentation/rabbitmq-2.7/javaagent/src/test/groovy/ReactorRabbitMqTest.groovy @@ -10,8 +10,6 @@ import reactor.rabbitmq.ExchangeSpecification import reactor.rabbitmq.RabbitFlux import reactor.rabbitmq.SenderOptions -import static com.google.common.net.InetAddresses.isInetAddress - class ReactorRabbitMqTest extends AgentInstrumentationSpecification implements WithRabbitMqTrait { def setupSpec() { @@ -39,9 +37,11 @@ class ReactorRabbitMqTest extends AgentInstrumentationSpecification implements W name 'exchange.declare' kind SpanKind.CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" { it == null || it instanceof String } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } - "$SemanticAttributes.NET_PEER_PORT" { it == null || it instanceof Long } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" } + "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" || it == null } + "net.sock.family" { it == null || it == "inet6" } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" "rabbitmq.command" "exchange.declare" diff --git a/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy b/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy index b459bcb5d2a7..1645bb67cda4 100644 --- a/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy +++ b/instrumentation/ratpack/ratpack-1.4/testing/src/main/groovy/io/opentelemetry/instrumentation/ratpack/server/AbstractRatpackRoutesTest.groovy @@ -96,10 +96,8 @@ abstract class AbstractRatpackRoutesTest extends InstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_METHOD" "GET" "$SemanticAttributes.HTTP_STATUS_CODE" 200 diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java index 27584507426f..8d5cfb8674ea 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackHttpNetAttributesGetter.java @@ -32,10 +32,4 @@ public String peerName(RequestSpec request, @Nullable HttpResponse response) { public Integer peerPort(RequestSpec request, @Nullable HttpResponse response) { return request.getUri().getPort(); } - - @Override - @Nullable - public String peerIp(RequestSpec request, @Nullable HttpResponse response) { - return null; - } } diff --git a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesGetter.java b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesGetter.java index e11457f58457..4c24558fba46 100644 --- a/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesGetter.java +++ b/instrumentation/ratpack/ratpack-1.7/library/src/main/java/io/opentelemetry/instrumentation/ratpack/internal/RatpackNetAttributesGetter.java @@ -21,13 +21,13 @@ public String transport(Request request) { } @Override - public Integer peerPort(Request request) { + public Integer sockPeerPort(Request request) { return request.getRemoteAddress().getPort(); } @Override @Nullable - public String peerIp(Request request) { + public String sockPeerAddr(Request request) { return null; } } diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/ReactorNettyConnectionSpanTest.groovy b/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/ReactorNettyConnectionSpanTest.groovy index 72e82fd9d15c..948c2b4ad72d 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/ReactorNettyConnectionSpanTest.groovy +++ b/instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/ReactorNettyConnectionSpanTest.groovy @@ -76,7 +76,7 @@ class ReactorNettyConnectionSpanTest extends InstrumentationSpecification implem "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(3) { @@ -142,7 +142,7 @@ class ReactorNettyConnectionSpanTest extends InstrumentationSpecification implem "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" PortUtils.UNUSABLE_PORT - "$SemanticAttributes.NET_PEER_IP" { it == null || it == "127.0.0.1" } + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } } } } diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyClientSslTest.groovy b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyClientSslTest.groovy index c982447dbbd0..572ed29f66bb 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyClientSslTest.groovy +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyClientSslTest.groovy @@ -94,7 +94,7 @@ class ReactorNettyClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpsPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(4) { @@ -108,7 +108,7 @@ class ReactorNettyClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpsPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } } @@ -150,7 +150,7 @@ class ReactorNettyClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.HTTP_STATUS_CODE" 200 "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpsPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(2) { @@ -171,7 +171,7 @@ class ReactorNettyClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpsPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(4) { @@ -182,7 +182,7 @@ class ReactorNettyClientSslTest extends AgentInstrumentationSpecification { "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpsPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(5) { diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyConnectionSpanTest.groovy b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyConnectionSpanTest.groovy index 859e4dbecded..02aef4e4aedd 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyConnectionSpanTest.groovy +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/groovy/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyConnectionSpanTest.groovy @@ -73,7 +73,7 @@ class ReactorNettyConnectionSpanTest extends InstrumentationSpecification implem "$SemanticAttributes.HTTP_STATUS_CODE" 200 "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(2) { @@ -94,7 +94,7 @@ class ReactorNettyConnectionSpanTest extends InstrumentationSpecification implem "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" server.httpPort() - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } span(4) { @@ -169,7 +169,7 @@ class ReactorNettyConnectionSpanTest extends InstrumentationSpecification implem "$SemanticAttributes.NET_TRANSPORT" IP_TCP "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" PortUtils.UNUSABLE_PORT - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" } } } diff --git a/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonAsyncClientTest.groovy b/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonAsyncClientTest.groovy index 9849b7db21b0..a6fdb2e60222 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonAsyncClientTest.groovy +++ b/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonAsyncClientTest.groovy @@ -6,9 +6,6 @@ import io.opentelemetry.api.trace.Span import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.semconv.trace.attributes.SemanticAttributes -import java.util.concurrent.Callable -import java.util.concurrent.CompletionStage -import java.util.concurrent.TimeUnit import org.redisson.Redisson import org.redisson.api.RBucket import org.redisson.api.RFuture @@ -20,6 +17,10 @@ import org.redisson.config.SingleServerConfig import org.testcontainers.containers.GenericContainer import spock.lang.Shared +import java.util.concurrent.Callable +import java.util.concurrent.CompletionStage +import java.util.concurrent.TimeUnit + import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.INTERNAL @@ -78,9 +79,9 @@ abstract class AbstractRedissonAsyncClientTest extends AgentInstrumentationSpeci kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "SET foo ?" "$SemanticAttributes.DB_OPERATION" "SET" } @@ -118,9 +119,9 @@ abstract class AbstractRedissonAsyncClientTest extends AgentInstrumentationSpeci childOf(span(0)) attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "SADD set1 ?" "$SemanticAttributes.DB_OPERATION" "SADD" } diff --git a/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonClientTest.groovy b/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonClientTest.groovy index 98722e2f6f05..40a2163073d8 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonClientTest.groovy +++ b/instrumentation/redisson/redisson-common/testing/src/main/groovy/AbstractRedissonClientTest.groovy @@ -78,9 +78,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "SET foo ?" "$SemanticAttributes.DB_OPERATION" "SET" } @@ -92,9 +92,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "GET foo" "$SemanticAttributes.DB_OPERATION" "GET" } @@ -118,9 +118,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "SET batch1 ?;SET batch2 ?" "$SemanticAttributes.DB_OPERATION" null } @@ -142,9 +142,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "RPUSH list1 ?" "$SemanticAttributes.DB_OPERATION" "RPUSH" } @@ -169,9 +169,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "EVAL $script 1 map1 ? ?" "$SemanticAttributes.DB_OPERATION" "EVAL" } @@ -183,9 +183,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "HGET map1 key1" "$SemanticAttributes.DB_OPERATION" "HGET" } @@ -207,9 +207,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "SADD set1 ?" "$SemanticAttributes.DB_OPERATION" "SADD" } @@ -235,9 +235,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "ZADD sort_set1 ? ? ? ? ? ?" "$SemanticAttributes.DB_OPERATION" "ZADD" } @@ -259,9 +259,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" "INCR AtomicLong" "$SemanticAttributes.DB_OPERATION" "INCR" } @@ -288,9 +288,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" { lockScriptPattern.matcher(it).matches() } "$SemanticAttributes.DB_OPERATION" "EVAL" } @@ -304,9 +304,9 @@ abstract class AbstractRedissonClientTest extends AgentInstrumentationSpecificat kind CLIENT attributes { "$SemanticAttributes.DB_SYSTEM" "redis" - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" "$SemanticAttributes.NET_PEER_NAME" "localhost" "$SemanticAttributes.NET_PEER_PORT" port + "net.sock.peer.addr" "127.0.0.1" "$SemanticAttributes.DB_STATEMENT" { lockScriptPattern.matcher(it).matches() } "$SemanticAttributes.DB_OPERATION" "EVAL" } diff --git a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesGetter.java b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesGetter.java index e3ff56cdb7a3..e94f1c6d11e1 100644 --- a/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesGetter.java +++ b/instrumentation/restlet/restlet-1.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v1_0/RestletNetAttributesGetter.java @@ -17,13 +17,13 @@ public String transport(Request request) { } @Override - public Integer peerPort(Request request) { + public Integer sockPeerPort(Request request) { return request.getClientInfo().getPort(); } @Override @Nullable - public String peerIp(Request request) { + public String sockPeerAddr(Request request) { return request.getClientInfo().getAddress(); } } diff --git a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletNetAttributesGetter.java b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletNetAttributesGetter.java index a2918dc9558e..d883e5e4df3a 100644 --- a/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletNetAttributesGetter.java +++ b/instrumentation/restlet/restlet-2.0/library/src/main/java/io/opentelemetry/instrumentation/restlet/v2_0/internal/RestletNetAttributesGetter.java @@ -17,13 +17,13 @@ public String transport(Request request) { } @Override - public Integer peerPort(Request request) { + public Integer sockPeerPort(Request request) { return request.getClientInfo().getPort(); } @Override @Nullable - public String peerIp(Request request) { + public String sockPeerAddr(Request request) { return request.getClientInfo().getAddress(); } } diff --git a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesGetter.java b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesGetter.java index 08954e4d3396..ec0ff1bbab1e 100644 --- a/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesGetter.java +++ b/instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletNetAttributesGetter.java @@ -25,13 +25,13 @@ public String transport(ServletRequestContext requestContext) { @Override @Nullable - public Integer peerPort(ServletRequestContext requestContext) { + public Integer sockPeerPort(ServletRequestContext requestContext) { return accessor.getRequestRemotePort(requestContext.request()); } @Override @Nullable - public String peerIp(ServletRequestContext requestContext) { + public String sockPeerAddr(ServletRequestContext requestContext) { return accessor.getRequestRemoteAddr(requestContext.request()); } } diff --git a/instrumentation/spark-2.3/javaagent/src/test/groovy/SparkJavaBasedTest.groovy b/instrumentation/spark-2.3/javaagent/src/test/groovy/SparkJavaBasedTest.groovy index 50e58c276159..3395cc74e68c 100644 --- a/instrumentation/spark-2.3/javaagent/src/test/groovy/SparkJavaBasedTest.groovy +++ b/instrumentation/spark-2.3/javaagent/src/test/groovy/SparkJavaBasedTest.groovy @@ -48,8 +48,8 @@ class SparkJavaBasedTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_HOST" "localhost:$port" "$SemanticAttributes.HTTP_TARGET" "/param/asdf1234" diff --git a/instrumentation/spring/README.md b/instrumentation/spring/README.md index 990ac03d2161..c018eaeb6780 100644 --- a/instrumentation/spring/README.md +++ b/instrumentation/spring/README.md @@ -759,11 +759,11 @@ To generate a trace, run MainServiceApplication and TimeServiceApplication, and SpanWrapper{ delegate=RecordEventsReadableSpan{traceId=TraceId{traceId=52d6edec17bbf842cf5032ebce2043f8}, spanId=SpanId{spanId=15b72a8e85c842c5}, parentSpanId=SpanId{spanId=57f0106dd1121b54}, name=HTTP GET, kind=CLIENT, attributes={net.peer.name=AttributeValueString{stringValue=localhost}, -http.status_code=AttributeValueLong{longValue=200}, net.peer.port=AttributeValueLong{longValue=8080}, +http.status_code=AttributeValueLong{longValue=200}, net.sock.peer.port=AttributeValueLong{longValue=8080}, http.url=AttributeValueString{stringValue=http://localhost:8080/time}, http.method=AttributeValueString{stringValue=GET}}, status=Status{canonicalCode=OK, description=null}, totalRecordedEvents=0, totalRecordedLinks=0, startEpochNanos=1598409410457933181, endEpochNanos=1598409410925420912}, resolvedLinks=[], resolvedEvents=[], attributes={net.peer.name=AttributeValueString{stringValue=localhost}, -http.status_code=AttributeValueLong{longValue=200}, net.peer.port=AttributeValueLong{longValue=8080}, +http.status_code=AttributeValueLong{longValue=200}, net.sock.peer.port=AttributeValueLong{longValue=8080}, http.url=AttributeValueString{stringValue=http://localhost:8080/time}, http.method=AttributeValueString{stringValue=GET}}, totalAttributeCount=5, totalRecordedEvents=0, status=Status{canonicalCode=OK, description=null}, name=HTTP GET, endEpochNanos=1598409410925420912, hasEnded=true } @@ -771,15 +771,15 @@ totalRecordedEvents=0, status=Status{canonicalCode=OK, description=null}, name=H SpanWrapper{ delegate=RecordEventsReadableSpan{traceId=TraceId{traceId=52d6edec17bbf842cf5032ebce2043f8}, spanId=SpanId{spanId=57f0106dd1121b54}, parentSpanId=SpanId{spanId=0000000000000000}, name=WebMVCTracingFilter.doFilterInteral, kind=SERVER, attributes={http.status_code=AttributeValueLong{longValue=200}, -sampling.probability=AttributeValueDouble{doubleValue=1.0}, net.peer.port=AttributeValueLong{longValue=57578}, +sampling.probability=AttributeValueDouble{doubleValue=1.0}, net.sock.peer.port=AttributeValueLong{longValue=57578}, http.user_agent=AttributeValueString{stringValue=PostmanRuntime/7.26.2}, http.flavor=AttributeValueString{stringValue=1.1}, -http.url=AttributeValueString{stringValue=/message}, net.peer.ip=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}, +http.url=AttributeValueString{stringValue=/message}, net.sock.peer.addr=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}, http.method=AttributeValueString{stringValue=GET}, http.client_ip=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}}, status=Status{canonicalCode=OK, description=null}, totalRecordedEvents=0, totalRecordedLinks=0, startEpochNanos=1598409410399317331, endEpochNanos=1598409411045782693}, resolvedLinks=[], resolvedEvents=[], attributes={http.status_code=AttributeValueLong{longValue=200}, sampling.probability=AttributeValueDouble{doubleValue=1.0}, -net.peer.port=AttributeValueLong{longValue=57578}, http.user_agent=AttributeValueString{stringValue=PostmanRuntime/7.26.2}, +net.sock.peer.port=AttributeValueLong{longValue=57578}, http.user_agent=AttributeValueString{stringValue=PostmanRuntime/7.26.2}, http.flavor=AttributeValueString{stringValue=1.1}, http.url=AttributeValueString{stringValue=/message}, -net.peer.ip=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}, http.method=AttributeValueString{stringValue=GET}, +net.sock.peer.addr=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}, http.method=AttributeValueString{stringValue=GET}, http.client_ip=AttributeValueString{stringValue=0:0:0:0:0:0:0:1}}, totalAttributeCount=9, totalRecordedEvents=0, status=Status{canonicalCode=OK, description=null}, name=WebMVCTracingFilter.doFilterInteral, endEpochNanos=1598409411045782693, hasEnded=true } @@ -801,15 +801,15 @@ status=Status{canonicalCode=OK, description=null}, name=time, endEpochNanos=1598 SpanWrapper{ delegate=RecordEventsReadableSpan{traceId=TraceId{traceId=52d6edec17bbf842cf5032ebce2043f8}, spanId=SpanId{spanId=b4ae77c523215f9d}, parentSpanId=SpanId{spanId=15b72a8e85c842c5}, name=WebMVCTracingFilter.doFilterInteral, kind=SERVER, -attributes={http.status_code=AttributeValueLong{longValue=200}, net.peer.port=AttributeValueLong{longValue=40174}, +attributes={http.status_code=AttributeValueLong{longValue=200}, net.sock.peer.port=AttributeValueLong{longValue=40174}, http.user_agent=AttributeValueString{stringValue=Java/11.0.8}, http.flavor=AttributeValueString{stringValue=1.1}, -http.url=AttributeValueString{stringValue=/time}, net.peer.ip=AttributeValueString{stringValue=127.0.0.1}, +http.url=AttributeValueString{stringValue=/time}, net.sock.peer.addr=AttributeValueString{stringValue=127.0.0.1}, http.method=AttributeValueString{stringValue=GET}, http.client_ip=AttributeValueString{stringValue=127.0.0.1}}, status=Status{canonicalCode=OK, description=null}, totalRecordedEvents=0, totalRecordedLinks=0, startEpochNanos=1598409410680549805, endEpochNanos=1598409410921631068}, resolvedLinks=[], resolvedEvents=[], attributes={http.status_code=AttributeValueLong{longValue=200}, -net.peer.port=AttributeValueLong{longValue=40174}, http.user_agent=AttributeValueString{stringValue=Java/11.0.8}, +net.sock.peer.port=AttributeValueLong{longValue=40174}, http.user_agent=AttributeValueString{stringValue=Java/11.0.8}, http.flavor=AttributeValueString{stringValue=1.1}, http.url=AttributeValueString{stringValue=/time}, -net.peer.ip=AttributeValueString{stringValue=127.0.0.1}, http.method=AttributeValueString{stringValue=GET}, +net.sock.peer.addr=AttributeValueString{stringValue=127.0.0.1}, http.method=AttributeValueString{stringValue=GET}, http.client_ip=AttributeValueString{stringValue=127.0.0.1}}, totalAttributeCount=8, totalRecordedEvents=0, status=Status{canonicalCode=OK, description=null}, name=WebMVCTracingFilter.doFilterInteral, endEpochNanos=1598409410921631068, hasEnded=true } @@ -930,8 +930,8 @@ Shown below is the sample trace generated by `MainService` and `TimeService` usi "http.status_code":"200", "http.url":"/time", "http.user_agent":"Java/11.0.8", - "net.peer.ip":"127.0.0.1", - "net.peer.port":"40174" + "net.sock.peer.addr":"127.0.0.1", + "net.sock.peer.port":"40174" } }, { @@ -951,7 +951,7 @@ Shown below is the sample trace generated by `MainService` and `TimeService` usi "http.status_code":"200", "http.url":"http://localhost:8080/time", "net.peer.name":"localhost", - "net.peer.port":"8080" + "net.sock.peer.port":"8080" } }, { @@ -972,8 +972,9 @@ Shown below is the sample trace generated by `MainService` and `TimeService` usi "http.status_code":"200", "http.url":"/message", "http.user_agent":"PostmanRuntime/7.26.2", - "net.peer.ip":"0:0:0:0:0:0:0:1", - "net.peer.port":"57578", + "net.sock.peer.addr":"0:0:0:0:0:0:0:1", + "net.sock.peer.port":"57578", + "net.sock.family":"inet6" "sampling.probability":"1.0" } } diff --git a/instrumentation/spring/spring-boot-autoconfigure/README.md b/instrumentation/spring/spring-boot-autoconfigure/README.md index 5d7d09a9695c..8b1f76b862b4 100644 --- a/instrumentation/spring/spring-boot-autoconfigure/README.md +++ b/instrumentation/spring/spring-boot-autoconfigure/README.md @@ -230,8 +230,9 @@ The traces below were exported using Zipkin. "http.status_code":"200", "http.url":"/spring-webmvc/sample", "http.user_agent":"PostmanRuntime/7.26.2", - "net.peer.ip":"0:0:0:0:0:0:0:1", - "net.peer.port":"33916", + "net.sock.peer.addr":"0:0:0:0:0:0:0:1", + "net.sock.peer.port":"33916", + "net.sock.family":"inet6" "sampling.probability":"1.0" } } diff --git a/instrumentation/spring/spring-integration-4.1/javaagent/src/test/groovy/SpringIntegrationAndRabbitTest.groovy b/instrumentation/spring/spring-integration-4.1/javaagent/src/test/groovy/SpringIntegrationAndRabbitTest.groovy index b182119e6c36..96cf998ce7e0 100644 --- a/instrumentation/spring/spring-integration-4.1/javaagent/src/test/groovy/SpringIntegrationAndRabbitTest.groovy +++ b/instrumentation/spring/spring-integration-4.1/javaagent/src/test/groovy/SpringIntegrationAndRabbitTest.groovy @@ -6,7 +6,6 @@ import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification import io.opentelemetry.semconv.trace.attributes.SemanticAttributes -import static com.google.common.net.InetAddresses.isInetAddress import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.CONSUMER import static io.opentelemetry.api.trace.SpanKind.PRODUCER @@ -47,9 +46,11 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i childOf span(1) kind CLIENT attributes { - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } - "$SemanticAttributes.NET_PEER_PORT" { it == null || it instanceof Long } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" } + "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" || it == null } + "net.sock.family" { it == null || it == "inet6" } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" } @@ -60,10 +61,11 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i childOf span(1) kind PRODUCER attributes { - // "localhost" on linux, null on windows - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" } "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" || it == null } + "net.sock.family" { it == null || it == "inet6" } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION" "testTopic" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" @@ -115,10 +117,11 @@ class SpringIntegrationAndRabbitTest extends AgentInstrumentationSpecification i name "basic.ack" kind CLIENT attributes { - // "localhost" on linux, null on windows - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" } "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == "0:0:0:0:0:0:0:1" || it == null } + "net.sock.family" { it == null || it == "inet6" } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" } diff --git a/instrumentation/spring/spring-rabbit-1.0/javaagent/src/test/groovy/ContextPropagationTest.groovy b/instrumentation/spring/spring-rabbit-1.0/javaagent/src/test/groovy/ContextPropagationTest.groovy index 0b4379f626f2..53128f13e086 100644 --- a/instrumentation/spring/spring-rabbit-1.0/javaagent/src/test/groovy/ContextPropagationTest.groovy +++ b/instrumentation/spring/spring-rabbit-1.0/javaagent/src/test/groovy/ContextPropagationTest.groovy @@ -21,7 +21,6 @@ import spock.lang.Shared import java.time.Duration -import static com.google.common.net.InetAddresses.isInetAddress import static io.opentelemetry.api.trace.SpanKind.CLIENT import static io.opentelemetry.api.trace.SpanKind.CONSUMER import static io.opentelemetry.api.trace.SpanKind.PRODUCER @@ -85,10 +84,10 @@ class ContextPropagationTest extends AgentInstrumentationSpecification { kind PRODUCER childOf span(0) attributes { - // "localhost" on linux, null on windows - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" } "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION" "" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" @@ -136,10 +135,10 @@ class ContextPropagationTest extends AgentInstrumentationSpecification { name "basic.ack" kind CLIENT attributes { - // "localhost" on linux, null on windows - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } - "$SemanticAttributes.NET_PEER_IP" { isInetAddress(it as String) } + // "localhost" on linux, "127.0.0.1" on windows + "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == "127.0.0.1" } "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" { it == "127.0.0.1" || it == null } "$SemanticAttributes.MESSAGING_SYSTEM" "rabbitmq" "$SemanticAttributes.MESSAGING_DESTINATION_KIND" "queue" } diff --git a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesGetter.java b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesGetter.java index e3f49cb78cdf..2996c93fbe13 100644 --- a/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesGetter.java +++ b/instrumentation/spring/spring-web-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/web/SpringWebNetAttributesGetter.java @@ -28,10 +28,4 @@ public String peerName(HttpRequest httpRequest, @Nullable ClientHttpResponse res public Integer peerPort(HttpRequest httpRequest, @Nullable ClientHttpResponse response) { return httpRequest.getURI().getPort(); } - - @Override - @Nullable - public String peerIp(HttpRequest httpRequest, @Nullable ClientHttpResponse response) { - return null; - } } diff --git a/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy b/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy index bc60631e4309..21a8ff651c3f 100644 --- a/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy +++ b/instrumentation/spring/spring-webflux-5.0/javaagent/src/test/groovy/SpringWebfluxTest.groovy @@ -81,9 +81,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" urlPath "$SemanticAttributes.HTTP_METHOD" "GET" @@ -148,9 +147,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" urlPath "$SemanticAttributes.HTTP_METHOD" "GET" @@ -235,9 +233,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" urlPath "$SemanticAttributes.HTTP_METHOD" "GET" @@ -300,9 +297,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { status UNSET attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/notfoundgreet" "$SemanticAttributes.HTTP_METHOD" "GET" @@ -344,9 +340,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/echo" "$SemanticAttributes.HTTP_METHOD" "POST" @@ -393,9 +388,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" urlPath "$SemanticAttributes.HTTP_METHOD" "GET" @@ -457,9 +451,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/double-greet-redirect" "$SemanticAttributes.HTTP_METHOD" "GET" @@ -489,9 +482,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/double-greet" "$SemanticAttributes.HTTP_METHOD" "GET" @@ -536,9 +528,8 @@ class SpringWebfluxTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" - "$SemanticAttributes.NET_PEER_PORT" Long + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" urlPath "$SemanticAttributes.HTTP_METHOD" "GET" diff --git a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/internal/SpringWebfluxNetAttributesGetter.java b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/internal/SpringWebfluxNetAttributesGetter.java index 33200670504a..090694ea317e 100644 --- a/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/internal/SpringWebfluxNetAttributesGetter.java +++ b/instrumentation/spring/spring-webflux-5.0/library/src/main/java/io/opentelemetry/instrumentation/spring/webflux/client/internal/SpringWebfluxNetAttributesGetter.java @@ -33,10 +33,4 @@ public String peerName(ClientRequest request, @Nullable ClientResponse response) public Integer peerPort(ClientRequest request, @Nullable ClientResponse response) { return request.url().getPort(); } - - @Nullable - @Override - public String peerIp(ClientRequest request, @Nullable ClientResponse response) { - return null; - } } diff --git a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesGetter.java b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesGetter.java index 0d41652a0563..2cfc0654ec8a 100644 --- a/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesGetter.java +++ b/instrumentation/spring/spring-webmvc-3.1/library/src/main/java/io/opentelemetry/instrumentation/spring/webmvc/SpringWebMvcNetAttributesGetter.java @@ -18,13 +18,13 @@ public String transport(HttpServletRequest request) { } @Override - public Integer peerPort(HttpServletRequest request) { + public Integer sockPeerPort(HttpServletRequest request) { return request.getRemotePort(); } @Override @Nullable - public String peerIp(HttpServletRequest request) { + public String sockPeerAddr(HttpServletRequest request) { return request.getRemoteAddr(); } } diff --git a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesGetter.java b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesGetter.java index 0ac80ec45ad9..2573db0127bc 100644 --- a/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesGetter.java +++ b/instrumentation/tomcat/tomcat-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/tomcat/common/TomcatNetAttributesGetter.java @@ -21,14 +21,14 @@ public String transport(Request request) { @Override @Nullable - public Integer peerPort(Request request) { + public Integer sockPeerPort(Request request) { request.action(ActionCode.REQ_REMOTEPORT_ATTRIBUTE, request); return request.getRemotePort(); } @Override @Nullable - public String peerIp(Request request) { + public String sockPeerAddr(Request request) { request.action(ActionCode.REQ_HOST_ADDR_ATTRIBUTE, request); return request.remoteAddr().toString(); } diff --git a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy index a07e616c2378..f75256d1f08b 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy @@ -139,8 +139,8 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr } attributes { - "$SemanticAttributes.NET_PEER_PORT" { it instanceof Long } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_CLIENT_IP" TEST_CLIENT_IP "$SemanticAttributes.HTTP_SCHEME" uri.getScheme() "$SemanticAttributes.HTTP_HOST" uri.getHost() + ":" + uri.getPort() @@ -153,8 +153,6 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_TARGET" "/sendResponse" - // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } @@ -194,8 +192,8 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr errorEvent(Exception, "exception after sending response", 2) attributes { - "$SemanticAttributes.NET_PEER_PORT" { it instanceof Long } - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_CLIENT_IP" TEST_CLIENT_IP "$SemanticAttributes.HTTP_SCHEME" uri.getScheme() "$SemanticAttributes.HTTP_HOST" uri.getHost() + ":" + uri.getPort() @@ -208,8 +206,6 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "$SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH" Long "$SemanticAttributes.HTTP_SCHEME" "http" "$SemanticAttributes.HTTP_TARGET" "/sendResponseWithException" - // net.peer.name resolves to "127.0.0.1" on windows which is same as net.peer.ip so then not captured - "$SemanticAttributes.NET_PEER_NAME" { it == "localhost" || it == null } "$SemanticAttributes.NET_TRANSPORT" SemanticAttributes.NetTransportValues.IP_TCP } } diff --git a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java index c85f74962c39..b7b8154d9a3e 100644 --- a/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java +++ b/instrumentation/vertx/vertx-http-client/vertx-http-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/client/Vertx4NetAttributesGetter.java @@ -29,10 +29,4 @@ public String peerName(HttpClientRequest request, @Nullable HttpClientResponse r public Integer peerPort(HttpClientRequest request, @Nullable HttpClientResponse response) { return request.getPort(); } - - @Nullable - @Override - public String peerIp(HttpClientRequest request, @Nullable HttpClientResponse response) { - return null; - } } diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy index bf748c67f68a..c2f3a3479d2b 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/latestDepTest/groovy/VertxReactivePropagationTest.groovy @@ -64,9 +64,8 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_PORT" Long - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/listProducts" "$SemanticAttributes.HTTP_METHOD" "GET" @@ -155,9 +154,8 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { childOf(span(0)) attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_PORT" Long - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId" "$SemanticAttributes.HTTP_METHOD" "GET" diff --git a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy index bf748c67f68a..c2f3a3479d2b 100644 --- a/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy +++ b/instrumentation/vertx/vertx-rx-java-3.5/javaagent/src/version35Test/groovy/VertxReactivePropagationTest.groovy @@ -64,9 +64,8 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { hasNoParent() attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_PORT" Long - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "/listProducts" "$SemanticAttributes.HTTP_METHOD" "GET" @@ -155,9 +154,8 @@ class VertxReactivePropagationTest extends AgentInstrumentationSpecification { childOf(span(0)) attributes { "$SemanticAttributes.NET_TRANSPORT" IP_TCP - "$SemanticAttributes.NET_PEER_NAME" { it == null || it == "localhost" } - "$SemanticAttributes.NET_PEER_PORT" Long - "$SemanticAttributes.NET_PEER_IP" "127.0.0.1" + "net.sock.peer.addr" "127.0.0.1" + "net.sock.peer.port" Long "$SemanticAttributes.HTTP_HOST" { it == "localhost" || it == "localhost:${port}" } "$SemanticAttributes.HTTP_TARGET" "$baseUrl?$TEST_REQUEST_ID_PARAMETER=$requestId" "$SemanticAttributes.HTTP_METHOD" "GET" diff --git a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy index 7b3524a84c2a..6db401d956e8 100644 --- a/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy +++ b/testing-common/src/main/groovy/io/opentelemetry/instrumentation/test/base/HttpServerTest.groovy @@ -149,7 +149,7 @@ abstract class HttpServerTest extends InstrumentationSpecification imple [ SemanticAttributes.HTTP_ROUTE, SemanticAttributes.NET_TRANSPORT, - SemanticAttributes.NET_PEER_PORT + AttributeKey.stringKey("net.sock.peer.port") ] as Set } @@ -215,12 +215,12 @@ abstract class HttpServerTest extends InstrumentationSpecification imple // the main trace assertion method to groovy to be able to call these assertions. @Override void assertTheTraces( - int size, - String traceId, - String parentId, - String method, - ServerEndpoint endpoint, - AggregatedHttpResponse response) { + int size, + String traceId, + String parentId, + String method, + ServerEndpoint endpoint, + AggregatedHttpResponse response) { HttpServerTest.this.assertTheTraces(size, traceId, parentId, method, endpoint, response) } 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 2e493720e680..c0bc688dcc84 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 @@ -946,13 +946,15 @@ SpanDataAssert assertClientSpan( } // TODO(anuraaga): Move to test knob rather than always treating as optional - if (attrs.asMap().containsKey(SemanticAttributes.NET_PEER_IP)) { + if (attrs.asMap().containsKey(AttributeKey.stringKey("net.sock.peer.addr"))) { if (uri.getHost().equals("192.0.2.1")) { // NB(anuraaga): This branch seems to currently only be exercised on Java 15. // It would be good to understand how the JVM version is impacting this check. - assertThat(attrs).containsEntry(SemanticAttributes.NET_PEER_IP, "192.0.2.1"); + assertThat(attrs) + .containsEntry(AttributeKey.stringKey("net.sock.peer.addr"), "192.0.2.1"); } else { - assertThat(attrs).containsEntry(SemanticAttributes.NET_PEER_IP, "127.0.0.1"); + assertThat(attrs) + .containsEntry(AttributeKey.stringKey("net.sock.peer.addr"), "127.0.0.1"); } } diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java index 37e99a12cad5..4385d4fe9bac 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/AbstractHttpServerTest.java @@ -551,19 +551,21 @@ protected SpanDataAssert assertServerSpan( .containsEntry( SemanticAttributes.NET_TRANSPORT, SemanticAttributes.NetTransportValues.IP_TCP); } - if (httpAttributes.contains(SemanticAttributes.NET_PEER_PORT)) { + if (httpAttributes.contains(AttributeKey.longKey("net.sock.peer.port"))) { assertThat(attrs) .hasEntrySatisfying( - SemanticAttributes.NET_PEER_PORT, + AttributeKey.longKey("net.sock.peer.port"), value -> assertThat(value) .isInstanceOf(Long.class) .isNotEqualTo(Long.valueOf(port))); } - if (httpAttributes.contains(SemanticAttributes.NET_PEER_IP) + if (httpAttributes.contains(AttributeKey.stringKey("net.sock.peer.addr")) || attrs.get(SemanticAttributes.HTTP_REQUEST_CONTENT_LENGTH) != null) { assertThat(attrs) - .containsEntry(SemanticAttributes.NET_PEER_IP, options.peerIp.apply(endpoint)); + .containsEntry( + AttributeKey.stringKey("net.sock.peer.addr"), + options.sockPeerAddr.apply(endpoint)); } assertThat(attrs) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/HttpServerTestOptions.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/HttpServerTestOptions.java index b93e1f4c3dce..764ac1e8b24e 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/HttpServerTestOptions.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/http/HttpServerTestOptions.java @@ -32,7 +32,7 @@ public final class HttpServerTestOptions { BiFunction expectedServerSpanNameMapper = DEFAULT_EXPECTED_SERVER_SPAN_NAME_MAPPER; Function expectedHttpRoute = unused -> null; - Function peerIp = unused -> "127.0.0.1"; + Function sockPeerAddr = unused -> "127.0.0.1"; String contextPath = ""; Throwable expectedException = new Exception(ServerEndpoint.EXCEPTION.getBody()); @@ -71,8 +71,8 @@ public HttpServerTestOptions setExpectedHttpRoute( return this; } - public HttpServerTestOptions setPeerIp(Function peerIp) { - this.peerIp = peerIp; + public HttpServerTestOptions setSockPeerAddr(Function sockPeerAddr) { + this.sockPeerAddr = sockPeerAddr; return this; } From b61a419d1b732bccd7ee42d16c2c77b602b78a15 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 1 Aug 2022 16:40:44 -0700 Subject: [PATCH 09/12] Feedback --- .../net/NetClientAttributesExtractor.java | 22 ++++++++++++------- .../net/NetClientAttributesGetter.java | 11 +++++++++- .../net/NetServerAttributesExtractor.java | 8 +++++-- .../net/NetServerAttributesGetter.java | 14 +++++++++++- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java index 8555df09fadd..520ae5c02205 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesExtractor.java @@ -26,6 +26,15 @@ public final class NetClientAttributesExtractor implements AttributesExtractor { + private static final AttributeKey NET_SOCK_PEER_ADDR = + AttributeKey.stringKey("net.sock.peer.addr"); + public static final AttributeKey NET_SOCK_PEER_PORT = + AttributeKey.longKey("net.sock.peer.port"); + public static final AttributeKey NET_SOCK_FAMILY = + AttributeKey.stringKey("net.sock.family"); + public static final AttributeKey NET_SOCK_PEER_NAME = + AttributeKey.stringKey("net.sock.peer.name"); + private final NetClientAttributesGetter getter; public static NetClientAttributesExtractor create( @@ -61,21 +70,18 @@ public void onEnd( String sockPeerAddr = getter.sockPeerAddr(request, response); if (sockPeerAddr != null && !sockPeerAddr.equals(peerName)) { - internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); + internalSet(attributes, NET_SOCK_PEER_ADDR, sockPeerAddr); Integer sockPeerPort = getter.sockPeerPort(request, response); - if (sockPeerPort != null && !sockPeerPort.equals(peerPort)) { - internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); + if (sockPeerPort != null && sockPeerPort > 0 && !sockPeerPort.equals(peerPort)) { + internalSet(attributes, NET_SOCK_PEER_PORT, (long) sockPeerPort); } - internalSet( - attributes, - AttributeKey.stringKey("net.sock.family"), - getter.sockFamily(request, response)); + internalSet(attributes, NET_SOCK_FAMILY, getter.sockFamily(request, response)); String sockPeerName = getter.sockPeerName(request, response); if (sockPeerName != null && !sockPeerName.equals(peerName)) { - internalSet(attributes, AttributeKey.stringKey("net.sock.peer.name"), sockPeerName); + internalSet(attributes, NET_SOCK_PEER_NAME, sockPeerName); } } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java index 9adc30a80f0d..9e84a061a57c 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java @@ -26,11 +26,20 @@ public interface NetClientAttributesGetter { @Nullable Integer peerPort(REQUEST request, @Nullable RESPONSE response); + /** + * @deprecated implement {@link #sockPeerAddr(Object, Object)} instead. + */ + @Deprecated @Nullable - default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) { + default String peerIp(REQUEST request, @Nullable RESPONSE response) { return null; } + @Nullable + default String sockPeerAddr(REQUEST request, @Nullable RESPONSE response) { + return peerIp(request, response); + } + @Nullable default Integer sockPeerPort(REQUEST request, @Nullable RESPONSE response) { return null; diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java index e7e2aa8da97d..6d6f2312d2f0 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesExtractor.java @@ -23,6 +23,10 @@ public final class NetServerAttributesExtractor implements AttributesExtractor { + public static final AttributeKey NET_SOCK_PEER_ADDR = + AttributeKey.stringKey("net.sock.peer.addr"); + public static final AttributeKey NET_SOCK_PEER_PORT = + AttributeKey.longKey("net.sock.peer.port"); private final NetServerAttributesGetter getter; public static NetServerAttributesExtractor create( @@ -40,11 +44,11 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST String sockPeerAddr = getter.sockPeerAddr(request); - internalSet(attributes, AttributeKey.stringKey("net.sock.peer.addr"), sockPeerAddr); + internalSet(attributes, NET_SOCK_PEER_ADDR, sockPeerAddr); Integer sockPeerPort = getter.sockPeerPort(request); if (sockPeerPort != null && sockPeerPort > 0) { - internalSet(attributes, AttributeKey.longKey("net.sock.peer.port"), (long) sockPeerPort); + internalSet(attributes, NET_SOCK_PEER_PORT, (long) sockPeerPort); } } diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index 24ddd10feda6..e1e83a3812e5 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -20,9 +20,21 @@ public interface NetServerAttributesGetter { @Nullable String transport(REQUEST request); + /** + * @deprecated implement {@link #sockPeerAddr(Object)} instead. + */ + @Deprecated + @Nullable + default String peerIp(REQUEST request) { + return null; + } + @Nullable Integer sockPeerPort(REQUEST request); @Nullable - String sockPeerAddr(REQUEST request); + default String sockPeerAddr(REQUEST request) { + // TODO (trask) remove default after removing peerIp() method + return peerIp(request); + } } From a1cdd4aa44857b78c04dff9301152e697f9c8f95 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 3 Aug 2022 16:24:51 -0700 Subject: [PATCH 10/12] One more default method --- .../net/NetServerAttributesGetter.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index e1e83a3812e5..bf0ca20cf34d 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -20,6 +20,16 @@ public interface NetServerAttributesGetter { @Nullable String transport(REQUEST request); + + /** + * @deprecated implement {@link #sockPeerPort(Object)} instead. + */ + @Deprecated + @Nullable + default Integer peerPort(REQUEST request) { + return null; + } + /** * @deprecated implement {@link #sockPeerAddr(Object)} instead. */ @@ -30,7 +40,10 @@ default String peerIp(REQUEST request) { } @Nullable - Integer sockPeerPort(REQUEST request); + default Integer sockPeerPort(REQUEST request) { + // TODO (trask) remove default after removing peerPort() method + return peerPort(request); + } @Nullable default String sockPeerAddr(REQUEST request) { From 306f748933a845ba2a1fea0893ca88204db8f423 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 3 Aug 2022 20:13:49 -0700 Subject: [PATCH 11/12] Spotless --- .../api/instrumenter/net/NetServerAttributesGetter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index bf0ca20cf34d..8990d1c604a2 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -20,7 +20,6 @@ public interface NetServerAttributesGetter { @Nullable String transport(REQUEST request); - /** * @deprecated implement {@link #sockPeerPort(Object)} instead. */ From 8aae7713afedee03bca75a0f04e8ebc3652f9702 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 17 Aug 2022 11:09:07 -0700 Subject: [PATCH 12/12] Fix javadoc --- .../api/instrumenter/net/NetClientAttributesGetter.java | 2 ++ .../api/instrumenter/net/NetServerAttributesGetter.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java index 9e84a061a57c..039d7ee12d65 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetClientAttributesGetter.java @@ -27,6 +27,8 @@ public interface NetClientAttributesGetter { Integer peerPort(REQUEST request, @Nullable RESPONSE response); /** + * Returns the peerIp. + * * @deprecated implement {@link #sockPeerAddr(Object, Object)} instead. */ @Deprecated diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java index 8990d1c604a2..51704f7e1b23 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/net/NetServerAttributesGetter.java @@ -21,6 +21,8 @@ public interface NetServerAttributesGetter { String transport(REQUEST request); /** + * Returns the peerPort. + * * @deprecated implement {@link #sockPeerPort(Object)} instead. */ @Deprecated @@ -30,6 +32,8 @@ default Integer peerPort(REQUEST request) { } /** + * Returns the peerIp. + * * @deprecated implement {@link #sockPeerAddr(Object)} instead. */ @Deprecated