diff --git a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractor.java b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractor.java index a1d3ae026022..825894041454 100644 --- a/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractor.java +++ b/instrumentation-api-semconv/src/main/java/io/opentelemetry/instrumentation/api/instrumenter/network/NetworkAttributesExtractor.java @@ -41,7 +41,8 @@ public static NetworkAttributesExtractor AddressAndPortExtractor.noop(), AddressAndPortExtractor.noop(), /* captureLocalSocketAttributes= */ true, - /* captureOldPeerDomainAttribute= */ false, + // capture the old net.sock.peer.name attr for backwards compatibility + /* captureOldPeerDomainAttribute= */ true, SemconvStability.emitStableHttpSemconv(), SemconvStability.emitOldHttpSemconv()); } diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboNetworkServerAttributesGetter.java b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboNetworkServerAttributesGetter.java index 0d1bc51acee8..df25e545f3e9 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboNetworkServerAttributesGetter.java +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboNetworkServerAttributesGetter.java @@ -5,7 +5,7 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; @@ -13,7 +13,7 @@ final class DubboNetworkServerAttributesGetter implements ServerAttributesGetter, - ClientAttributesGetter { + NetworkAttributesGetter { @Nullable @Override @@ -29,14 +29,14 @@ public Integer getServerPort(DubboRequest request) { @Nullable @Override - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkLocalInetSocketAddress( DubboRequest request, @Nullable Result result) { return request.localAddress(); } @Override @Nullable - public InetSocketAddress getClientInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( DubboRequest request, @Nullable Result result) { return request.remoteAddress(); } diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTelemetryBuilder.java b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTelemetryBuilder.java index b815eb28533b..16a009dd38ee 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTelemetryBuilder.java +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/DubboTelemetryBuilder.java @@ -12,7 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcServerAttributesExtractor; @@ -72,7 +72,7 @@ public DubboTelemetry build() { .addAttributesExtractor(RpcServerAttributesExtractor.create(rpcAttributesGetter)) .addAttributesExtractor( ServerAttributesExtractor.createForServerSide(netServerAttributesGetter)) - .addAttributesExtractor(ClientAttributesExtractor.create(netServerAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netServerAttributesGetter)) .addAttributesExtractors(attributesExtractors); InstrumenterBuilder clientInstrumenterBuilder = @@ -80,6 +80,7 @@ public DubboTelemetry build() { openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) .addAttributesExtractor(RpcClientAttributesExtractor.create(rpcAttributesGetter)) .addAttributesExtractor(ServerAttributesExtractor.create(netClientAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netClientAttributesGetter)) .addAttributesExtractors(attributesExtractors); if (peerService != null) { diff --git a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboClientNetworkAttributesGetter.java b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboClientNetworkAttributesGetter.java index 659e4ca27166..a40354f3c303 100644 --- a/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboClientNetworkAttributesGetter.java +++ b/instrumentation/apache-dubbo-2.7/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/apachedubbo/v2_7/internal/DubboClientNetworkAttributesGetter.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.apachedubbo.v2_7.internal; import io.opentelemetry.instrumentation.apachedubbo.v2_7.DubboRequest; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; @@ -16,7 +17,8 @@ * any time. */ public final class DubboClientNetworkAttributesGetter - implements ServerAttributesGetter { + implements ServerAttributesGetter, + NetworkAttributesGetter { @Nullable @Override @@ -31,7 +33,7 @@ public Integer getServerPort(DubboRequest request) { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( DubboRequest request, @Nullable Result response) { return request.remoteAddress(); } diff --git a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java index dd7666092231..6caf1e1617f3 100644 --- a/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java +++ b/instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/apachecamel/RestCamelTest.java @@ -115,6 +115,9 @@ void restComponentServerAndClientCallWithJettyBackend() { val -> val.isInstanceOf(String.class)), satisfies( SemanticAttributes.NET_SOCK_PEER_PORT, + val -> val.isInstanceOf(Long.class)), + satisfies( + SemanticAttributes.NET_SOCK_HOST_PORT, val -> val.isInstanceOf(Long.class))), span -> span.hasName("GET /api/{module}/unit/{unitId}") diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetworkAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetworkAttributesGetter.java index 0a8207d6963e..fb1f2a26e426 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetworkAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraNetworkAttributesGetter.java @@ -6,16 +6,16 @@ package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0; import com.datastax.driver.core.ExecutionInfo; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( CassandraRequest request, @Nullable ExecutionInfo executionInfo) { return executionInfo == null ? null : executionInfo.getQueriedHost().getSocketAddress(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java index 695bdb9a501c..97bd78d9878f 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java @@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; import io.opentelemetry.semconv.SemanticAttributes; @@ -37,7 +37,7 @@ public final class CassandraSingletons { CommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - ServerAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetworkAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetworkAttributesGetter.java index 2bf26ec44bcf..ba185cb1bbaa 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetworkAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraNetworkAttributesGetter.java @@ -7,17 +7,17 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import com.datastax.oss.driver.api.core.metadata.Node; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( CassandraRequest request, @Nullable ExecutionInfo executionInfo) { if (executionInfo == null) { return null; diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java index 2c3a8705bbcf..16d0a1a109d0 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java @@ -11,7 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; import io.opentelemetry.semconv.SemanticAttributes; @@ -36,7 +36,7 @@ public final class CassandraSingletons { CommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - ServerAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraNetworkAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraNetworkAttributesGetter.java index ca7e93a2b804..33c4c1dc1a5d 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraNetworkAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraNetworkAttributesGetter.java @@ -7,17 +7,17 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import com.datastax.oss.driver.api.core.metadata.Node; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( CassandraRequest request, @Nullable ExecutionInfo executionInfo) { if (executionInfo == null) { return null; diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraTelemetryBuilder.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraTelemetryBuilder.java index c08e6cb20593..559b00eef4ed 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraTelemetryBuilder.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraTelemetryBuilder.java @@ -12,7 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.SqlClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.semconv.SemanticAttributes; /** A builder of {@link CassandraTelemetry}. */ @@ -59,7 +59,7 @@ protected Instrumenter createInstrumenter( .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( - ServerAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetworkAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetworkAttributesGetter.java index 35b19adadf24..3424e2085061 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetworkAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseNetworkAttributesGetter.java @@ -5,17 +5,17 @@ package io.opentelemetry.javaagent.instrumentation.couchbase.v2_0; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; public class CouchbaseNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Nullable @Override - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( CouchbaseRequestInfo couchbaseRequest, @Nullable Void unused) { SocketAddress peerAddress = couchbaseRequest.getPeerAddress(); if (peerAddress instanceof InetSocketAddress) { diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseSingletons.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseSingletons.java index 58421bd25080..647e13748c6e 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseSingletons.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseSingletons.java @@ -12,9 +12,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; -import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.InstrumentationConfig; public final class CouchbaseSingletons { @@ -33,10 +31,7 @@ public final class CouchbaseSingletons { Instrumenter.builder( GlobalOpenTelemetry.get(), INSTRUMENTATION_NAME, spanNameExtractor) .addAttributesExtractor(DbClientAttributesExtractor.create(couchbaseAttributesGetter)) - .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) - .addAttributesExtractor( - PeerServiceAttributesExtractor.create( - netAttributesGetter, CommonConfig.get().getPeerServiceResolver())) + .addAttributesExtractor(NetworkAttributesExtractor.create(netAttributesGetter)) .addContextCustomizer( (context, couchbaseRequest, startAttributes) -> CouchbaseRequestInfo.init(context, couchbaseRequest)); diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java index 60308996e2aa..31c20c1056cf 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_0/Elasticsearch5TransportSingletons.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetworkAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; @@ -18,7 +18,7 @@ public final class Elasticsearch5TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.0", new Elasticsearch5TransportExperimentalAttributesExtractor(), - ServerAttributesExtractor.create(new ElasticTransportNetworkAttributesGetter())); + NetworkAttributesExtractor.create(new ElasticTransportNetworkAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java index f29a445de1a9..ce299ced5ffa 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-5.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v5_3/Elasticsearch53TransportSingletons.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v5_3; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportNetworkAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; @@ -18,7 +18,7 @@ public final class Elasticsearch53TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-5.3", new Elasticsearch53TransportExperimentalAttributesExtractor(), - ServerAttributesExtractor.create(new ElasticTransportNetworkAttributesGetter())); + NetworkAttributesExtractor.create(new ElasticTransportNetworkAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetworkAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetworkAttributesGetter.java index 51351b57bf90..5305465df878 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetworkAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportNetworkAttributesGetter.java @@ -5,18 +5,18 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import java.net.InetSocketAddress; import javax.annotation.Nullable; import org.elasticsearch.action.ActionResponse; public class Elasticsearch6TransportNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().address(); diff --git a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java index e8123e7207bb..8de019d8d5eb 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-6.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/v6_0/Elasticsearch6TransportSingletons.java @@ -6,7 +6,7 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.v6_0; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticTransportRequest; import io.opentelemetry.javaagent.instrumentation.elasticsearch.transport.ElasticsearchTransportInstrumenterFactory; import org.elasticsearch.action.ActionResponse; @@ -17,7 +17,7 @@ public final class Elasticsearch6TransportSingletons { ElasticsearchTransportInstrumenterFactory.create( "io.opentelemetry.elasticsearch-transport-6.0", new Elasticsearch6TransportExperimentalAttributesExtractor(), - ServerAttributesExtractor.create(new Elasticsearch6TransportNetworkAttributesGetter())); + NetworkAttributesExtractor.create(new Elasticsearch6TransportNetworkAttributesGetter())); public static Instrumenter instrumenter() { return INSTRUMENTER; diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetworkAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetworkAttributesGetter.java index 939bba50e482..39308734e8e9 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetworkAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticTransportNetworkAttributesGetter.java @@ -5,28 +5,16 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import javax.annotation.Nullable; import org.elasticsearch.action.ActionResponse; public class ElasticTransportNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable - public String getServerAddress(ElasticTransportRequest request) { - return null; - } - - @Override - @Nullable - public Integer getServerPort(ElasticTransportRequest request) { - return null; - } - - @Override - @Nullable - public String getServerSocketAddress( + public String getNetworkPeerAddress( ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getAddress(); @@ -36,17 +24,7 @@ public String getServerSocketAddress( @Nullable @Override - public String getServerSocketDomain( - ElasticTransportRequest request, @Nullable ActionResponse response) { - if (response != null && response.remoteAddress() != null) { - return response.remoteAddress().getHost(); - } - return null; - } - - @Nullable - @Override - public Integer getServerSocketPort( + public Integer getNetworkPeerPort( ElasticTransportRequest request, @Nullable ActionResponse response) { if (response != null && response.remoteAddress() != null) { return response.remoteAddress().getPort(); diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcNetworkServerAttributesGetter.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcNetworkServerAttributesGetter.java index 3fd4406d9082..d8e7ff79e659 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcNetworkServerAttributesGetter.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcNetworkServerAttributesGetter.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6; import io.grpc.Status; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -14,7 +14,7 @@ final class GrpcNetworkServerAttributesGetter implements ServerAttributesGetter, - ClientAttributesGetter { + NetworkAttributesGetter { @Nullable @Override @@ -29,7 +29,7 @@ public Integer getServerPort(GrpcRequest grpcRequest) { @Nullable @Override - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkLocalInetSocketAddress( GrpcRequest grpcRequest, @Nullable Status status) { // TODO: later version introduces TRANSPORT_ATTR_LOCAL_ADDR, might be a good idea to use it return null; @@ -37,7 +37,7 @@ public InetSocketAddress getServerInetSocketAddress( @Override @Nullable - public InetSocketAddress getClientInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( GrpcRequest request, @Nullable Status status) { SocketAddress address = request.getPeerSocketAddress(); if (address instanceof InetSocketAddress) { diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTelemetryBuilder.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTelemetryBuilder.java index 1a15d94f811d..0c51ca8eeb10 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTelemetryBuilder.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTelemetryBuilder.java @@ -13,7 +13,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ClientAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.rpc.RpcClientMetrics; @@ -177,6 +177,7 @@ public GrpcTelemetry build() { .addAttributesExtractors(additionalExtractors) .addAttributesExtractor(RpcClientAttributesExtractor.create(rpcAttributesGetter)) .addAttributesExtractor(ServerAttributesExtractor.create(netClientAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netClientAttributesGetter)) .addAttributesExtractors(additionalClientExtractors) .addAttributesExtractor( new GrpcAttributesExtractor( @@ -188,7 +189,7 @@ public GrpcTelemetry build() { .addAttributesExtractor(RpcServerAttributesExtractor.create(rpcAttributesGetter)) .addAttributesExtractor( ServerAttributesExtractor.createForServerSide(netServerAttributesGetter)) - .addAttributesExtractor(ClientAttributesExtractor.create(netServerAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netServerAttributesGetter)) .addAttributesExtractor( new GrpcAttributesExtractor( GrpcRpcAttributesGetter.INSTANCE, capturedServerRequestMetadata)) diff --git a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcClientNetworkAttributesGetter.java b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcClientNetworkAttributesGetter.java index c2d342da7946..deb6e61da568 100644 --- a/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcClientNetworkAttributesGetter.java +++ b/instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/internal/GrpcClientNetworkAttributesGetter.java @@ -6,6 +6,7 @@ package io.opentelemetry.instrumentation.grpc.v1_6.internal; import io.grpc.Status; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; import io.opentelemetry.instrumentation.grpc.v1_6.GrpcRequest; import java.net.InetSocketAddress; @@ -17,7 +18,8 @@ * any time. */ public final class GrpcClientNetworkAttributesGetter - implements ServerAttributesGetter { + implements ServerAttributesGetter, + NetworkAttributesGetter { @Nullable @Override @@ -32,7 +34,7 @@ public Integer getServerPort(GrpcRequest grpcRequest) { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( GrpcRequest request, @Nullable Status response) { SocketAddress address = request.getPeerSocketAddress(); if (address instanceof InetSocketAddress) { 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 234c7ee9bede..1120cdf73950 100644 --- a/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy +++ b/instrumentation/jaxrs/jaxrs-common/testing/src/main/groovy/AbstractJaxRsHttpServerTest.groovy @@ -285,6 +285,7 @@ abstract class AbstractJaxRsHttpServerTest extends HttpServerTest implemen "$SemanticAttributes.NET_SOCK_PEER_ADDR" "127.0.0.1" "$SemanticAttributes.NET_SOCK_PEER_PORT" Long "$SemanticAttributes.NET_SOCK_HOST_ADDR" "127.0.0.1" + "$SemanticAttributes.NET_SOCK_HOST_PORT" { it instanceof Long || it == null } "$SemanticAttributes.HTTP_SCHEME" fullUrl.getScheme() "$SemanticAttributes.HTTP_TARGET" fullUrl.getPath() + (fullUrl.getQuery() != null ? "?" + fullUrl.getQuery() : "") "$SemanticAttributes.HTTP_METHOD" method diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetworkAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetworkAttributesGetter.java index 6fdf8ae2660c..edfe8d81c5d8 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetworkAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisNetworkAttributesGetter.java @@ -5,12 +5,15 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v3_0; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; import java.net.InetSocketAddress; import java.net.Socket; import javax.annotation.Nullable; -final class JedisNetworkAttributesGetter implements ServerAttributesGetter { +final class JedisNetworkAttributesGetter + implements ServerAttributesGetter, + NetworkAttributesGetter { @Nullable @Override @@ -25,7 +28,7 @@ public Integer getServerPort(JedisRequest jedisRequest) { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( JedisRequest jedisRequest, @Nullable Void unused) { Socket socket = jedisRequest.getConnection().getSocket(); if (socket != null && socket.getRemoteSocketAddress() instanceof InetSocketAddress) { diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java index 2314f4905f8d..fd18d97e6ee3 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisSingletons.java @@ -11,6 +11,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; @@ -30,6 +31,7 @@ public final class JedisSingletons { DbClientSpanNameExtractor.create(dbAttributesGetter)) .addAttributesExtractor(DbClientAttributesExtractor.create(dbAttributesGetter)) .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netAttributesGetter)) .addAttributesExtractor( PeerServiceAttributesExtractor.create( netAttributesGetter, CommonConfig.get().getPeerServiceResolver())) diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetworkAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetworkAttributesGetter.java index b72554bdaafa..ba0ac2321d51 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetworkAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisNetworkAttributesGetter.java @@ -5,16 +5,16 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v4_0; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; -final class JedisNetworkAttributesGetter implements ServerAttributesGetter { +final class JedisNetworkAttributesGetter implements NetworkAttributesGetter { @Override @Nullable - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( JedisRequest jedisRequest, @Nullable Void unused) { SocketAddress socketAddress = jedisRequest.getRemoteSocketAddress(); if (socketAddress instanceof InetSocketAddress) { diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java index f03f6ec09c89..340ecb4435d8 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisSingletons.java @@ -10,9 +10,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.net.PeerServiceAttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; -import io.opentelemetry.javaagent.bootstrap.internal.CommonConfig; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; public final class JedisSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.jedis-4.0"; @@ -29,10 +27,7 @@ public final class JedisSingletons { INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(dbAttributesGetter)) .addAttributesExtractor(DbClientAttributesExtractor.create(dbAttributesGetter)) - .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) - .addAttributesExtractor( - PeerServiceAttributesExtractor.create( - netAttributesGetter, CommonConfig.get().getPeerServiceResolver())) + .addAttributesExtractor(NetworkAttributesExtractor.create(netAttributesGetter)) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetworkAttributesGetter.java b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetworkAttributesGetter.java index 9c7d823466c0..18de90dc66b2 100644 --- a/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetworkAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.1/library/src/main/java/io/opentelemetry/instrumentation/lettuce/v5_1/LettuceNetworkAttributesGetter.java @@ -5,17 +5,17 @@ package io.opentelemetry.instrumentation.lettuce.v5_1; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import io.opentelemetry.instrumentation.lettuce.v5_1.OpenTelemetryTracing.OpenTelemetryEndpoint; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class LettuceNetworkAttributesGetter - implements ServerAttributesGetter { + implements NetworkAttributesGetter { @Nullable @Override - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( 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 3756541d395c..4bedf6eaf387 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 @@ -26,7 +26,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.db.RedisCommandSanitizer; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; import io.opentelemetry.semconv.SemanticAttributes; import io.opentelemetry.semconv.SemanticAttributes.DbSystemValues; import java.net.InetSocketAddress; @@ -39,7 +39,7 @@ final class OpenTelemetryTracing implements Tracing { private static final AttributesExtractor serverAttributesExtractor = - ServerAttributesExtractor.create(new LettuceNetworkAttributesGetter()); + NetworkAttributesExtractor.create(new LettuceNetworkAttributesGetter()); private final TracerProvider tracerProvider; OpenTelemetryTracing(io.opentelemetry.api.trace.Tracer tracer, RedisCommandSanitizer sanitizer) { diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyBaseUrlOnlyTest.java b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyBaseUrlOnlyTest.java index 4ade1ecbeb4d..357ef3d10c23 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyBaseUrlOnlyTest.java +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/ReactorNettyBaseUrlOnlyTest.java @@ -121,7 +121,10 @@ void testSuccessfulRequest() { equalTo(SemanticAttributes.NET_PROTOCOL_VERSION, "1.1"), equalTo(SemanticAttributes.NET_PEER_NAME, "localhost"), equalTo(SemanticAttributes.NET_PEER_PORT, server.httpPort()), - equalTo(SemanticAttributes.NET_SOCK_PEER_ADDR, "127.0.0.1")), + equalTo(SemanticAttributes.NET_SOCK_PEER_ADDR, "127.0.0.1"), + satisfies( + SemanticAttributes.NET_SOCK_PEER_PORT, + AbstractLongAssert::isNotNegative)), span -> span.hasName("test-http-server").hasKind(SERVER).hasParent(trace.getSpan(1)))); } diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonInstrumenterFactory.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonInstrumenterFactory.java index ebe4a626f283..022580a34fdf 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonInstrumenterFactory.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonInstrumenterFactory.java @@ -10,7 +10,7 @@ import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesExtractor; public final class RedissonInstrumenterFactory { @@ -23,7 +23,7 @@ public static Instrumenter createInstrumenter(String inst instrumentationName, DbClientSpanNameExtractor.create(dbAttributesGetter)) .addAttributesExtractor(DbClientAttributesExtractor.create(dbAttributesGetter)) - .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) + .addAttributesExtractor(NetworkAttributesExtractor.create(netAttributesGetter)) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java index 79ad404fc305..c27818d8b2f5 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonNetAttributesGetter.java @@ -5,14 +5,14 @@ package io.opentelemetry.javaagent.instrumentation.redisson; -import io.opentelemetry.instrumentation.api.instrumenter.network.ServerAttributesGetter; +import io.opentelemetry.instrumentation.api.instrumenter.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; -final class RedissonNetAttributesGetter implements ServerAttributesGetter { +final class RedissonNetAttributesGetter implements NetworkAttributesGetter { @Override - public InetSocketAddress getServerInetSocketAddress( + public InetSocketAddress getNetworkPeerInetSocketAddress( RedissonRequest request, @Nullable Void unused) { return request.getAddress(); } 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 d9c809cf1352..c1cf673d54db 100644 --- a/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy +++ b/instrumentation/undertow-1.4/javaagent/src/test/groovy/UndertowServerTest.groovy @@ -160,6 +160,7 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "$SemanticAttributes.NET_SOCK_PEER_ADDR" "127.0.0.1" "$SemanticAttributes.NET_SOCK_PEER_PORT" Long "$SemanticAttributes.NET_SOCK_HOST_ADDR" "127.0.0.1" + "$SemanticAttributes.NET_SOCK_HOST_PORT" Long } } if (SemconvStability.emitStableHttpSemconv()) { @@ -232,6 +233,7 @@ class UndertowServerTest extends HttpServerTest implements AgentTestTr "$SemanticAttributes.NET_SOCK_PEER_ADDR" "127.0.0.1" "$SemanticAttributes.NET_SOCK_PEER_PORT" Long "$SemanticAttributes.NET_SOCK_HOST_ADDR" "127.0.0.1" + "$SemanticAttributes.NET_SOCK_HOST_PORT" Long } } if (SemconvStability.emitStableHttpSemconv()) {