diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java index c06393e35998..47c2a12678c2 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java @@ -17,7 +17,7 @@ @ExtendWith(MockitoExtension.class) class DbClientSpanNameExtractorTest { @Mock DbClientAttributesGetter dbAttributesGetter; - @Mock SqlClientAttributesGetter sqlAttributesGetter; + @Mock SqlClientAttributesGetter sqlAttributesGetter; @Test void shouldExtractFullSpanName() { diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorTest.java index f0b31197a3e2..0e46ad96465e 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorTest.java @@ -24,7 +24,7 @@ class SqlClientAttributesExtractorTest { static final class TestAttributesGetter - implements SqlClientAttributesGetter> { + implements SqlClientAttributesGetter, Void> { @Override public String getRawQueryText(Map map) { diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchDbAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchDbAttributesGetter.java index 90589d7332d6..c929905bb62f 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchDbAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchDbAttributesGetter.java @@ -16,13 +16,14 @@ import java.util.stream.Collectors; import javax.annotation.Nullable; import org.apache.http.HttpEntity; +import org.elasticsearch.client.Response; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ final class ElasticsearchDbAttributesGetter - implements DbClientAttributesGetter { + implements DbClientAttributesGetter { private static final Logger logger = Logger.getLogger(ElasticsearchDbAttributesGetter.class.getName()); diff --git a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportAttributesGetter.java b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportAttributesGetter.java index 8d046eb7aae7..714e8c8fe821 100644 --- a/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportAttributesGetter.java +++ b/instrumentation/elasticsearch/elasticsearch-transport-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/transport/ElasticsearchTransportAttributesGetter.java @@ -8,9 +8,10 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; +import org.elasticsearch.action.ActionResponse; final class ElasticsearchTransportAttributesGetter - implements DbClientAttributesGetter { + implements DbClientAttributesGetter { @Override public String getDbSystem(ElasticTransportRequest request) { diff --git a/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java b/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java index afc92f2fcad9..36d3e4cc1a8c 100644 --- a/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java +++ b/instrumentation/jdbc/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jdbc/JdbcSingletons.java @@ -13,10 +13,8 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.DbRequest; import io.opentelemetry.instrumentation.jdbc.internal.JdbcAttributesGetter; -import io.opentelemetry.instrumentation.jdbc.internal.JdbcNetworkAttributesGetter; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig; import io.opentelemetry.javaagent.bootstrap.jdbc.DbInfo; @@ -31,7 +29,6 @@ public final class JdbcSingletons { static { JdbcAttributesGetter dbAttributesGetter = new JdbcAttributesGetter(); - JdbcNetworkAttributesGetter netAttributesGetter = new JdbcNetworkAttributesGetter(); STATEMENT_INSTRUMENTER = Instrumenter.builder( @@ -46,10 +43,9 @@ public final class JdbcSingletons { "otel.instrumentation.jdbc.statement-sanitizer.enabled", AgentCommonConfig.get().isStatementSanitizationEnabled())) .build()) - .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) .addAttributesExtractor( PeerServiceAttributesExtractor.create( - netAttributesGetter, AgentCommonConfig.get().getPeerServiceResolver())) + dbAttributesGetter, AgentCommonConfig.get().getPeerServiceResolver())) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcAttributesGetter.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcAttributesGetter.java index b5623f4d99ce..64a23da14680 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcAttributesGetter.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcAttributesGetter.java @@ -13,7 +13,7 @@ * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ -public final class JdbcAttributesGetter implements SqlClientAttributesGetter { +public final class JdbcAttributesGetter implements SqlClientAttributesGetter { @Nullable @Override @@ -47,4 +47,16 @@ public String getConnectionString(DbRequest request) { public String getRawQueryText(DbRequest request) { return request.getQueryText(); } + + @Nullable + @Override + public String getServerAddress(DbRequest request) { + return request.getDbInfo().getHost(); + } + + @Nullable + @Override + public Integer getServerPort(DbRequest request) { + return request.getDbInfo().getPort(); + } } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java index 2e0b1e583bb7..809243624e69 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcInstrumenterFactory.java @@ -14,7 +14,6 @@ import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil; -import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor; import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo; import javax.sql.DataSource; @@ -25,8 +24,6 @@ public final class JdbcInstrumenterFactory { public static final String INSTRUMENTATION_NAME = "io.opentelemetry.jdbc"; private static final JdbcAttributesGetter dbAttributesGetter = new JdbcAttributesGetter(); - private static final JdbcNetworkAttributesGetter netAttributesGetter = - new JdbcNetworkAttributesGetter(); public static Instrumenter createStatementInstrumenter() { return createStatementInstrumenter(GlobalOpenTelemetry.get()); @@ -51,7 +48,6 @@ public static Instrumenter createStatementInstrumenter( SqlClientAttributesExtractor.builder(dbAttributesGetter) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) - .addAttributesExtractor(ServerAttributesExtractor.create(netAttributesGetter)) .setEnabled(enabled) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetworkAttributesGetter.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetworkAttributesGetter.java index a09ca312672b..002d4b3bd49d 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetworkAttributesGetter.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcNetworkAttributesGetter.java @@ -6,23 +6,9 @@ package io.opentelemetry.instrumentation.jdbc.internal; import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesGetter; -import javax.annotation.Nullable; /** * This class is internal and is hence not for public use. Its APIs are unstable and can change at * any time. */ -public final class JdbcNetworkAttributesGetter implements ServerAttributesGetter { - - @Nullable - @Override - public String getServerAddress(DbRequest request) { - return request.getDbInfo().getHost(); - } - - @Nullable - @Override - public Integer getServerPort(DbRequest request) { - return request.getDbInfo().getPort(); - } -} +public final class JdbcNetworkAttributesGetter implements ServerAttributesGetter {} diff --git a/instrumentation/opensearch/opensearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/OpenSearchRestAttributesGetter.java b/instrumentation/opensearch/opensearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/OpenSearchRestAttributesGetter.java index a8479bf6b0bc..b6362e1e6dd9 100644 --- a/instrumentation/opensearch/opensearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/OpenSearchRestAttributesGetter.java +++ b/instrumentation/opensearch/opensearch-rest-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/opensearch/rest/OpenSearchRestAttributesGetter.java @@ -8,9 +8,10 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; +import org.opensearch.client.Response; final class OpenSearchRestAttributesGetter - implements DbClientAttributesGetter { + implements DbClientAttributesGetter { @Override public String getDbSystem(OpenSearchRestRequest request) { diff --git a/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java b/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java index 36ebe81accbf..39e41f6ae771 100644 --- a/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java +++ b/instrumentation/r2dbc-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/r2dbc/v1_0/R2dbcSingletons.java @@ -8,7 +8,7 @@ import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded.R2dbcTelemetry; -import io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded.internal.R2dbcNetAttributesGetter; +import io.opentelemetry.instrumentation.r2dbc.v1_0.internal.shaded.internal.R2dbcSqlAttributesGetter; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.javaagent.bootstrap.internal.AgentInstrumentationConfig; @@ -23,7 +23,7 @@ public final class R2dbcSingletons { AgentCommonConfig.get().isStatementSanitizationEnabled())) .addAttributeExtractor( PeerServiceAttributesExtractor.create( - R2dbcNetAttributesGetter.INSTANCE, + R2dbcSqlAttributesGetter.INSTANCE, AgentCommonConfig.get().getPeerServiceResolver())) .build(); diff --git a/instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/SpymemcachedAttributesGetter.java b/instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/SpymemcachedAttributesGetter.java index 6f1eadd6acc9..6eed4eb79d6f 100644 --- a/instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/SpymemcachedAttributesGetter.java +++ b/instrumentation/spymemcached-2.12/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spymemcached/SpymemcachedAttributesGetter.java @@ -9,7 +9,7 @@ import javax.annotation.Nullable; public class SpymemcachedAttributesGetter - implements DbClientAttributesGetter { + implements DbClientAttributesGetter { @Override public String getDbSystem(SpymemcachedRequest spymemcachedRequest) { diff --git a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java index 92c27b4ddb19..91cdce26d45d 100644 --- a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientAttributesGetter.java @@ -9,7 +9,7 @@ import javax.annotation.Nullable; public enum VertxSqlClientAttributesGetter - implements SqlClientAttributesGetter { + implements SqlClientAttributesGetter { INSTANCE; @Override