From 70258469f0c66cd76ca39ff8bd1cb16ca3deb3eb Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 12 Jun 2024 17:50:16 -0700 Subject: [PATCH 01/93] Protype for db stable semconv --- .../db/DbClientCommonAttributesExtractor.java | 16 ++++-- .../db/DbClientCommonAttributesGetter.java | 3 + .../api/internal/SemconvStability.java | 55 +++++++++++++++++++ .../LettuceConnectAttributesExtractor.java | 12 +++- .../v4_0/LettuceDbAttributesGetter.java | 6 ++ .../LettuceConnectAttributesExtractor.java | 12 +++- .../VertxRedisClientAttributesExtractor.java | 14 ++++- 7 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index e3a6614c7660..d076e983688b 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -11,6 +11,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.internal.SpanKey; import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; import javax.annotation.Nullable; @@ -21,6 +22,7 @@ abstract class DbClientCommonAttributesExtractor< // copied from DbIncubatingAttributes private static final AttributeKey DB_NAME = AttributeKey.stringKey("db.name"); + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); private static final AttributeKey DB_USER = AttributeKey.stringKey("db.user"); private static final AttributeKey DB_CONNECTION_STRING = @@ -34,10 +36,16 @@ abstract class DbClientCommonAttributesExtractor< @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { - internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); - internalSet(attributes, DB_USER, getter.getUser(request)); - internalSet(attributes, DB_NAME, getter.getName(request)); - internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); + if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet(attributes, DB_NAMESPACE, getter.getNamespace(request)); + } + + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); + internalSet(attributes, DB_USER, getter.getUser(request)); + internalSet(attributes, DB_NAME, getter.getName(request)); + internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); + } } @Override diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index 430be029cb0c..ad27d8758395 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -19,6 +19,9 @@ public interface DbClientCommonAttributesGetter { @Nullable String getName(REQUEST request); + @Nullable + String getNamespace(REQUEST request); + @Nullable String getConnectionString(REQUEST request); } diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java new file mode 100644 index 000000000000..81ac63218cf1 --- /dev/null +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java @@ -0,0 +1,55 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.internal; + +import static java.util.Arrays.asList; + +import java.util.HashSet; +import java.util.Set; + +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class SemconvStability { + + private static final boolean emitOldDatabaseSemconv; + private static final boolean emitStableDatabaseSemconv; + + static { + boolean oldDatabase = true; + boolean stableDatabase = false; + + String value = ConfigPropertiesUtil.getString("otel.semconv-stability.opt-in"); + if (value != null) { + Set values = new HashSet<>(asList(value.split(","))); + if (values.contains("database")) { + oldDatabase = false; + stableDatabase = true; + } + // no else -- technically it's possible to set "database,database/dup", in which case we + // should emit + // both sets of attributes + if (values.contains("database/dup")) { + oldDatabase = true; + stableDatabase = true; + } + } + + emitOldDatabaseSemconv = oldDatabase; + emitStableDatabaseSemconv = stableDatabase; + } + + public static boolean emitOldDatabaseSemconv() { + return emitOldDatabaseSemconv; + } + + public static boolean emitStableDatabaseSemconv() { + return emitStableDatabaseSemconv; + } + + private SemconvStability() {} +} diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java index 7609edbc402c..601841ce1cef 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java @@ -6,9 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; import com.lambdaworks.redis.RedisURI; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; @@ -20,7 +22,15 @@ public void onStart(AttributesBuilder attributes, Context parentContext, RedisUR int database = redisUri.getDatabase(); if (database != 0) { - attributes.put(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, (long) database); + if (SemconvStability.emitStableDatabaseSemconv()) { + attributes.put( + AttributeKey.stringKey("db.namespace"), + redisUri.getHost()); // TODO (heya) required further discussion + } + + if (SemconvStability.emitOldDatabaseSemconv()) { + attributes.put(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, (long) database); + } } } diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index 0322e0e61dd9..8eaa86ef7d5c 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -29,6 +29,12 @@ public String getName(RedisCommand request) { return null; } + @Nullable + @Override + public String getNamespace(RedisCommand request) { + return null; + } + @Override @Nullable public String getConnectionString(RedisCommand request) { diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java index 142e7b15abb6..32aeb99317d7 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java @@ -6,9 +6,11 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; import io.lettuce.core.RedisURI; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; @@ -20,7 +22,15 @@ public void onStart(AttributesBuilder attributes, Context parentContext, RedisUR int database = redisUri.getDatabase(); if (database != 0) { - attributes.put(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, (long) database); + if (SemconvStability.emitStableDatabaseSemconv()) { + attributes.put( + AttributeKey.stringKey("db.namespace"), + redisUri.getHost()); // TODO (heya) required further discussion + } + + if (SemconvStability.emitOldDatabaseSemconv()) { + attributes.put(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, (long) database); + } } } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java index 5203ed1e96b8..640879aa73c9 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java @@ -7,9 +7,11 @@ 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; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; @@ -20,8 +22,16 @@ enum VertxRedisClientAttributesExtractor @Override public void onStart( AttributesBuilder attributes, Context parentContext, VertxRedisClientRequest request) { - internalSet( - attributes, DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, request.getDatabaseIndex()); + if (SemconvStability.emitStableDatabaseSemconv()) { + attributes.put( + AttributeKey.stringKey("db.namespace"), + request.getHost()); // TODO (heya) required further discussion + } + + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet( + attributes, DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, request.getDatabaseIndex()); + } } @Override From 89395e0c0ab0dc11ab6ae5f9a5efb6de8c7181e0 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 13 Jun 2024 13:34:18 -0700 Subject: [PATCH 02/93] Update redis db.namespace value --- .../lettuce/v4_0/LettuceConnectAttributesExtractor.java | 6 +++--- .../lettuce/v5_0/LettuceConnectAttributesExtractor.java | 6 +++--- .../v4_0/redis/VertxRedisClientAttributesExtractor.java | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java index 601841ce1cef..95b7daee81b8 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceConnectAttributesExtractor.java @@ -16,6 +16,8 @@ final class LettuceConnectAttributesExtractor implements AttributesExtractor { + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); + @Override public void onStart(AttributesBuilder attributes, Context parentContext, RedisURI redisUri) { attributes.put(DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.REDIS); @@ -23,9 +25,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, RedisUR int database = redisUri.getDatabase(); if (database != 0) { if (SemconvStability.emitStableDatabaseSemconv()) { - attributes.put( - AttributeKey.stringKey("db.namespace"), - redisUri.getHost()); // TODO (heya) required further discussion + attributes.put(DB_NAMESPACE, String.valueOf(database)); } if (SemconvStability.emitOldDatabaseSemconv()) { diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java index 32aeb99317d7..bdd05cbf87ff 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceConnectAttributesExtractor.java @@ -16,6 +16,8 @@ final class LettuceConnectAttributesExtractor implements AttributesExtractor { + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); + @Override public void onStart(AttributesBuilder attributes, Context parentContext, RedisURI redisUri) { attributes.put(DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.REDIS); @@ -23,9 +25,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, RedisUR int database = redisUri.getDatabase(); if (database != 0) { if (SemconvStability.emitStableDatabaseSemconv()) { - attributes.put( - AttributeKey.stringKey("db.namespace"), - redisUri.getHost()); // TODO (heya) required further discussion + attributes.put(DB_NAMESPACE, String.valueOf(database)); } if (SemconvStability.emitOldDatabaseSemconv()) { diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java index 640879aa73c9..7553309750d0 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java @@ -19,13 +19,13 @@ enum VertxRedisClientAttributesExtractor implements AttributesExtractor { INSTANCE; + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); + @Override public void onStart( AttributesBuilder attributes, Context parentContext, VertxRedisClientRequest request) { if (SemconvStability.emitStableDatabaseSemconv()) { - attributes.put( - AttributeKey.stringKey("db.namespace"), - request.getHost()); // TODO (heya) required further discussion + attributes.put(DB_NAMESPACE, String.valueOf(request.getDatabaseIndex())); } if (SemconvStability.emitOldDatabaseSemconv()) { From e021f5e6f4fb866fd65329b23262f8ae32c37e8a Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 3 Oct 2024 10:47:06 -0700 Subject: [PATCH 03/93] Update --- .../db/DbClientAttributesExtractor.java | 15 ++++++- .../db/DbClientCommonAttributesExtractor.java | 3 +- .../db/SqlClientAttributesExtractor.java | 23 +++++++--- .../semconv/rpc/RpcMetricsAdvice.java | 44 +++++++++---------- .../db/DbClientAttributesExtractorTest.java | 7 +++ .../db/SqlClientAttributesExtractorTest.java | 8 ++++ .../InternalNetworkAttributesExtractor.java | 13 +++--- .../DataSourceDbAttributesExtractor.java | 13 ++++-- .../jdbc/internal/JdbcAttributesGetter.java | 7 +++ .../lettuce/v5_1/OpenTelemetryTracing.java | 9 +++- 10 files changed, 102 insertions(+), 40 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index 09c8fbc72570..73faf73f95a2 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -11,6 +11,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; /** * Extractor of // copied from DbIncubatingAttributes private static final AttributeKey DB_STATEMENT = AttributeKey.stringKey("db.statement"); + private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); + private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); + private static final AttributeKey DB_OPERATION_NAME = + AttributeKey.stringKey("db.operation.name"); /** Creates the database client attributes extractor with default configuration. */ public static AttributesExtractor create( @@ -42,7 +47,13 @@ public static AttributesExtractor create( public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { super.onStart(attributes, parentContext, request); - internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); - internalSet(attributes, DB_OPERATION, getter.getOperation(request)); + if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet(attributes, DB_QUERY_TEXT, getter.getStatement(request)); + internalSet(attributes, DB_OPERATION_NAME, getter.getOperation(request)); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); + internalSet(attributes, DB_OPERATION, getter.getOperation(request)); + } } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index d076e983688b..8649c27f0c51 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -39,13 +39,12 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST if (SemconvStability.emitStableDatabaseSemconv()) { internalSet(attributes, DB_NAMESPACE, getter.getNamespace(request)); } - if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); internalSet(attributes, DB_USER, getter.getUser(request)); internalSet(attributes, DB_NAME, getter.getName(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } + internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); } @Override diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index eacf266333bc..5b728c9d79b2 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -11,6 +11,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; /** * Extractor of // copied from DbIncubatingAttributes private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); + private static final AttributeKey DB_OPERATION_NAME = + AttributeKey.stringKey("db.operation.name"); private static final AttributeKey DB_STATEMENT = AttributeKey.stringKey("db.statement"); + private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); /** Creates the SQL client attributes extractor with default configuration. */ public static AttributesExtractor create( @@ -68,11 +72,20 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST String rawStatement = getter.getRawStatement(request); SqlStatementInfo sanitizedStatement = sanitizer.sanitize(rawStatement); String operation = sanitizedStatement.getOperation(); - internalSet( - attributes, - DB_STATEMENT, - statementSanitizationEnabled ? sanitizedStatement.getFullStatement() : rawStatement); - internalSet(attributes, DB_OPERATION, operation); + if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet( + attributes, + DB_QUERY_TEXT, + statementSanitizationEnabled ? sanitizedStatement.getFullStatement() : rawStatement); + internalSet(attributes, DB_OPERATION_NAME, operation); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet( + attributes, + DB_STATEMENT, + statementSanitizationEnabled ? sanitizedStatement.getFullStatement() : rawStatement); + internalSet(attributes, DB_OPERATION, operation); + } if (!SQL_CALL.equals(operation)) { internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier()); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java index 0a24cca3f39c..87c149a5f8fd 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java @@ -8,9 +8,12 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder; import io.opentelemetry.api.metrics.DoubleHistogramBuilder; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; final class RpcMetricsAdvice { @@ -18,23 +21,30 @@ final class RpcMetricsAdvice { private static final AttributeKey RPC_GRPC_STATUS_CODE = AttributeKey.longKey("rpc.grpc.status_code"); + private static final List> attributesAdvice = new ArrayList<>(); + + static { + attributesAdvice.addAll( + Arrays.asList( + RpcCommonAttributesExtractor.RPC_SYSTEM, + RpcCommonAttributesExtractor.RPC_SERVICE, + RpcCommonAttributesExtractor.RPC_METHOD, + RPC_GRPC_STATUS_CODE, + ServerAttributes.SERVER_ADDRESS, + ServerAttributes.SERVER_PORT)); + if (SemconvStability.emitOldDatabaseSemconv()) { + attributesAdvice.add(NetworkAttributes.NETWORK_TYPE); + attributesAdvice.add(NetworkAttributes.NETWORK_TRANSPORT); + } + } + static void applyClientDurationAdvice(DoubleHistogramBuilder builder) { if (!(builder instanceof ExtendedDoubleHistogramBuilder)) { return; } // the list of recommended metrics attributes is from // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md - ((ExtendedDoubleHistogramBuilder) builder) - .setAttributesAdvice( - Arrays.asList( - RpcCommonAttributesExtractor.RPC_SYSTEM, - RpcCommonAttributesExtractor.RPC_SERVICE, - RpcCommonAttributesExtractor.RPC_METHOD, - RPC_GRPC_STATUS_CODE, - NetworkAttributes.NETWORK_TYPE, - NetworkAttributes.NETWORK_TRANSPORT, - ServerAttributes.SERVER_ADDRESS, - ServerAttributes.SERVER_PORT)); + ((ExtendedDoubleHistogramBuilder) builder).setAttributesAdvice(attributesAdvice); } static void applyServerDurationAdvice(DoubleHistogramBuilder builder) { @@ -43,17 +53,7 @@ static void applyServerDurationAdvice(DoubleHistogramBuilder builder) { } // the list of recommended metrics attributes is from // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md - ((ExtendedDoubleHistogramBuilder) builder) - .setAttributesAdvice( - Arrays.asList( - RpcCommonAttributesExtractor.RPC_SYSTEM, - RpcCommonAttributesExtractor.RPC_SERVICE, - RpcCommonAttributesExtractor.RPC_METHOD, - RPC_GRPC_STATUS_CODE, - NetworkAttributes.NETWORK_TYPE, - NetworkAttributes.NETWORK_TRANSPORT, - ServerAttributes.SERVER_ADDRESS, - ServerAttributes.SERVER_PORT)); + ((ExtendedDoubleHistogramBuilder) builder).setAttributesAdvice(attributesAdvice); } private RpcMetricsAdvice() {} diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index 68991d1b813a..fe5bba727250 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -16,6 +16,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nullable; import org.junit.jupiter.api.Test; class DbClientAttributesExtractorTest { @@ -36,6 +37,12 @@ public String getName(Map map) { return map.get("db.name"); } + @Nullable + @Override + public String getNamespace(Map map) { + return map.get("db.namespace"); + } + @Override public String getConnectionString(Map map) { return map.get("db.connection_string"); 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 f782a20b16ff..5bc0e139aea5 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 @@ -7,6 +7,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import static org.assertj.core.api.InstanceOfAssertFactories.map; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; @@ -16,6 +17,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nullable; import org.junit.jupiter.api.Test; class SqlClientAttributesExtractorTest { @@ -43,6 +45,12 @@ public String getName(Map map) { return map.get("db.name"); } + @Nullable + @Override + public String getNamespace(Map map) { + return map.get("db.namespace"); + } + @Override public String getConnectionString(Map map) { return map.get("db.connection_string"); diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java index 7d0cb9eea012..08ae9f47db22 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java @@ -8,6 +8,7 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; import io.opentelemetry.semconv.NetworkAttributes; import java.util.Locale; @@ -38,11 +39,13 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO if (captureProtocolAttributes) { String transport = lowercase(getter.getNetworkTransport(request, response)); - internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport); - internalSet( - attributes, - NetworkAttributes.NETWORK_TYPE, - lowercase(getter.getNetworkType(request, response))); + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport); + internalSet( + attributes, + NetworkAttributes.NETWORK_TYPE, + lowercase(getter.getNetworkType(request, response))); + } internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName); internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion); } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceDbAttributesExtractor.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceDbAttributesExtractor.java index fb35e335d9d7..7e71ddd5c6ab 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceDbAttributesExtractor.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DataSourceDbAttributesExtractor.java @@ -11,6 +11,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.jdbc.internal.dbinfo.DbInfo; import javax.annotation.Nullable; import javax.sql.DataSource; @@ -20,6 +21,7 @@ enum DataSourceDbAttributesExtractor implements AttributesExtractor DB_NAME = AttributeKey.stringKey("db.name"); + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); private static final AttributeKey DB_USER = AttributeKey.stringKey("db.user"); private static final AttributeKey DB_CONNECTION_STRING = @@ -39,10 +41,15 @@ public void onEnd( if (dbInfo == null) { return; } + if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet(attributes, DB_NAMESPACE, getName(dbInfo)); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, DB_USER, dbInfo.getUser()); + internalSet(attributes, DB_NAME, getName(dbInfo)); + internalSet(attributes, DB_CONNECTION_STRING, dbInfo.getShortUrl()); + } internalSet(attributes, DB_SYSTEM, dbInfo.getSystem()); - internalSet(attributes, DB_USER, dbInfo.getUser()); - internalSet(attributes, DB_NAME, getName(dbInfo)); - internalSet(attributes, DB_CONNECTION_STRING, dbInfo.getShortUrl()); } private static String getName(DbInfo dbInfo) { 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 ba04f3807395..8dd7da5b2f28 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 @@ -34,6 +34,13 @@ public String getName(DbRequest request) { return dbInfo.getName() == null ? dbInfo.getDb() : dbInfo.getName(); } + @Nullable + @Override + public String getNamespace(DbRequest request) { + DbInfo dbInfo = request.getDbInfo(); + return dbInfo.getName() == null ? dbInfo.getDb() : dbInfo.getName(); + } + @Nullable @Override public String getConnectionString(DbRequest request) { 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 d040634872b6..402f7ffda5f7 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 @@ -27,6 +27,7 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.semconv.network.ServerAttributesExtractor; import java.net.InetSocketAddress; @@ -41,6 +42,7 @@ final class OpenTelemetryTracing implements Tracing { // copied from DbIncubatingAttributes private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); private static final AttributeKey DB_STATEMENT = AttributeKey.stringKey("db.statement"); + private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); // copied from DbIncubatingAttributes.DbSystemValues private static final String REDIS = "redis"; @@ -338,7 +340,12 @@ private void finish(Span span) { if (name != null) { String statement = sanitizer.sanitize(name, argsList != null ? argsList : splitArgs(argsString)); - span.setAttribute(DB_STATEMENT, statement); + if (SemconvStability.emitStableDatabaseSemconv()) { + span.setAttribute(DB_QUERY_TEXT, statement); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + span.setAttribute(DB_STATEMENT, statement); + } } span.end(); } From 08c882e43018a5e3b608643f462553bd81ccaf41 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 31 Jul 2024 14:38:11 -0700 Subject: [PATCH 04/93] Update --- .../build.gradle.kts | 35 ++++++++++++ .../cassandra-3.0/javaagent/build.gradle.kts | 12 +++- .../cassandra/v3_0/CassandraSingletons.java | 10 +++- .../v3_0/CassandraSqlAttributesGetter.java | 6 ++ .../src/test/java/CassandraClientTest.java | 44 +++++++-------- .../v4_0/CassandraSqlAttributesGetter.java | 6 ++ .../v4_4/CassandraSqlAttributesGetter.java | 6 ++ .../javaagent/build.gradle.kts | 10 ++++ .../couchbase-2.0/javaagent/build.gradle.kts | 20 +++++-- .../v2_0/CouchbaseAttributesGetter.java | 6 ++ .../couchbase-2.6/javaagent/build.gradle.kts | 22 ++++++-- .../redisson-3.17/javaagent/build.gradle.kts | 16 +++++- .../runtimemetrics/java8/Classes.java | 6 ++ .../junit/db/SemconvStabilityUtil.java | 56 +++++++++++++++++++ 14 files changed, 216 insertions(+), 39 deletions(-) create mode 100644 testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java diff --git a/instrumentation-api-incubator/build.gradle.kts b/instrumentation-api-incubator/build.gradle.kts index 00d887da1b25..c1d0b6202460 100644 --- a/instrumentation-api-incubator/build.gradle.kts +++ b/instrumentation-api-incubator/build.gradle.kts @@ -24,6 +24,41 @@ dependencies { testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") } +testing { + suites { + val testStableDatabaseSemconv by registering(JvmTestSuite::class) { + dependencies { + implementation(project()) + implementation(project(":testing-common")) + implementation("io.opentelemetry:opentelemetry-sdk") + implementation("io.opentelemetry:opentelemetry-sdk-testing") + } + targets { + all { + testTask.configure { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + } + } + } + val testBothDatabaseSemconv by registering(JvmTestSuite::class) { + dependencies { + implementation(project()) + implementation(project(":testing-common")) + implementation("io.opentelemetry:opentelemetry-sdk") + implementation("io.opentelemetry:opentelemetry-sdk-testing") + } + targets { + all { + testTask.configure { + jvmArgs("-Dotel.semconv-stability.opt-in=database/dup") + } + } + } + } + } +} + tasks { // exclude auto-generated code named("checkstyleMain") { diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts index f4dfa06370fb..14bda18fec4c 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts @@ -44,7 +44,15 @@ dependencies { configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0") tasks { - test { - usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + withType().configureEach { + usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) + } + + check { + dependsOn(testStableSemconv) } } 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 841f48fdbc6e..3e010ff6d559 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 @@ -7,10 +7,12 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -21,10 +23,16 @@ public final class CassandraSingletons { // could use RESPONSE "ResultSet" here, but using RESPONSE "ExecutionInfo" in cassandra-4.0 // instrumentation (see comment over there for why), so also using here for consistency private static final Instrumenter INSTRUMENTER; + private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); + AttributeKey tableAttribute = DbIncubatingAttributes.DB_CASSANDRA_TABLE; + if (SemconvStability.emitStableDatabaseSemconv()) { + tableAttribute = DB_COLLECTION_NAME; + } + INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -32,7 +40,7 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute(tableAttribute) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 5b973f4e9922..7f4226106883 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -28,6 +28,12 @@ public String getName(CassandraRequest request) { return request.getSession().getLoggedKeyspace(); } + @Nullable + @Override + public String getNamespace(CassandraRequest request) { + return request.getSession().getLoggedKeyspace(); + } + @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 7d581375d537..f31d14388222 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -9,9 +9,11 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.ResultSetFuture; import com.datastax.driver.core.Session; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -100,8 +102,7 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, - "USE " + parameter.keyspace))), + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), "USE " + parameter.keyspace))), trace -> trace.hasSpansSatisfyingExactly( span -> @@ -115,12 +116,11 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), - equalTo(DbIncubatingAttributes.DB_NAME, parameter.keyspace), - equalTo( - DbIncubatingAttributes.DB_STATEMENT, parameter.expectedStatement), - equalTo(DbIncubatingAttributes.DB_OPERATION, parameter.operation), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace), equalTo( - DbIncubatingAttributes.DB_CASSANDRA_TABLE, parameter.table)))); + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)))); } else { testing.waitAndAssertTraces( trace -> @@ -130,17 +130,15 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, parameter.expectedStatement), - equalTo(DbIncubatingAttributes.DB_OPERATION, parameter.operation), - equalTo( - DbIncubatingAttributes.DB_CASSANDRA_TABLE, parameter.table)))); + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)))); } session.close(); @@ -178,7 +176,7 @@ void asyncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), "USE " + parameter.keyspace))), trace -> trace.hasSpansSatisfyingExactly( @@ -188,17 +186,16 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), - equalTo(DbIncubatingAttributes.DB_NAME, parameter.keyspace), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace), equalTo( - DbIncubatingAttributes.DB_STATEMENT, parameter.expectedStatement), - equalTo(DbIncubatingAttributes.DB_OPERATION, parameter.operation), - equalTo(DbIncubatingAttributes.DB_CASSANDRA_TABLE, parameter.table)), + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)), span -> span.hasName("callbackListener") .hasKind(SpanKind.INTERNAL) @@ -213,16 +210,15 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, parameter.expectedStatement), - equalTo(DbIncubatingAttributes.DB_OPERATION, parameter.operation), - equalTo(DbIncubatingAttributes.DB_CASSANDRA_TABLE, parameter.table)), + getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), + equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)), span -> span.hasName("callbackListener") .hasKind(SpanKind.INTERNAL) @@ -232,6 +228,10 @@ void asyncTest(Parameter parameter) { session.close(); } + protected static AttributeKey getAttributeKey(AttributeKey oldKey) { + return SemconvStabilityUtil.getAttributeKey(oldKey); + } + private static Stream provideSyncParameters() { return Stream.of( Arguments.of( diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index e08cf36a940f..610e95276839 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -29,6 +29,12 @@ public String getName(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } + @Nullable + @Override + public String getNamespace(CassandraRequest request) { + return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); + } + @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index f78a1fab53be..cdb9fb92bccf 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -30,6 +30,12 @@ public String getName(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } + @Nullable + @Override + public String getNamespace(CassandraRequest request) { + return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); + } + @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts index afe601decbdc..864031dbd062 100644 --- a/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts @@ -6,3 +6,13 @@ dependencies { compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") } + +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + check { + dependsOn(testStableSemconv) + } +} diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts index d6504dc00f43..b27963b88e76 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts @@ -31,9 +31,19 @@ dependencies { latestDepTestLibrary("com.couchbase.client:java-client:2.5.+") } -tasks.withType().configureEach { - // required on jdk17 - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED") - jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + withType().configureEach { + // required on jdk17 + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED") + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") + } + + check { + dependsOn(testStableSemconv) + } } diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index 05edc5679f75..ee2a5f932ac7 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -28,6 +28,12 @@ public String getName(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.bucket(); } + @Nullable + @Override + public String getNamespace(CouchbaseRequestInfo couchbaseRequest) { + return couchbaseRequest.bucket(); + } + @Override @Nullable public String getConnectionString(CouchbaseRequestInfo couchbaseRequest) { diff --git a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts index 19428dc07b26..a2d7c2905988 100644 --- a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts @@ -34,11 +34,21 @@ dependencies { latestDepTestLibrary("com.couchbase.client:java-client:2.+") } -tasks.withType().configureEach { - // TODO run tests both with and without experimental span attributes - jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true") +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + withType().configureEach { + // TODO run tests both with and without experimental span attributes + jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true") - // required on jdk17 - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") + // required on jdk17 + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") + } + + check { + dependsOn(testStableSemconv) + } } diff --git a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts index a37e1e87a96e..4b4a87924a9e 100644 --- a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts +++ b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts @@ -24,7 +24,17 @@ dependencies { testImplementation(project(":instrumentation:redisson:redisson-common:testing")) } -tasks.test { - systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) - usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + withType().configureEach { + systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) + usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) + } + + check { + dependsOn(testStableSemconv) + } } diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java index 0632ad5a3e4d..1f4b8fbac3bd 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java @@ -14,6 +14,12 @@ import java.util.List; /** + *

In case you enable the preview of stable database semantic conventions (e.g. by setting the {@code + * otel.semconv-stability.opt-in} system property to {@code database}), the metrics being exported will + * follow the + * most recent database semantic conventions. + * * Registers measurements that generate metrics about JVM classes. The metrics generated by this * class follow the diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java new file mode 100644 index 000000000000..7f0868d43328 --- /dev/null +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -0,0 +1,56 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.testing.junit.db; + +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import java.util.HashMap; +import java.util.Map; + +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_CASSANDRA_TABLE; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_COSMOSDB_CONTAINER; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_MONGODB_COLLECTION; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_NAME; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SQL_TABLE; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT; + +// until old database semconv are dropped in 3.0 +public class SemconvStabilityUtil { + private static final Map, AttributeKey> oldToNewMap = new HashMap<>(); + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); + private static final AttributeKey DB_NAMESPACE_LONG = AttributeKey.longKey("db.namespace"); + private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); + private static final AttributeKey DB_OPERATION_NAME = AttributeKey.stringKey("db.operation.name"); + private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); + + static { + addKey(oldToNewMap, DB_NAME, DB_NAMESPACE); + addKey(oldToNewMap, DB_REDIS_DATABASE_INDEX, DB_NAMESPACE_LONG); + addKey(oldToNewMap, DB_STATEMENT, DB_QUERY_TEXT); + addKey(oldToNewMap, DB_OPERATION, DB_OPERATION_NAME); + addKey(oldToNewMap, DB_SQL_TABLE, DB_COLLECTION_NAME); + addKey(oldToNewMap, DB_CASSANDRA_TABLE, DB_COLLECTION_NAME); + addKey(oldToNewMap, DB_MONGODB_COLLECTION, DB_COLLECTION_NAME); + addKey(oldToNewMap, DB_COSMOSDB_CONTAINER, DB_COLLECTION_NAME); + } + + private SemconvStabilityUtil() {} + + private static void addKey( + Map, AttributeKey> map, AttributeKey oldKey, AttributeKey newKey) { + map.put(oldKey, newKey); + } + + @SuppressWarnings("unchecked") + public static AttributeKey getAttributeKey(AttributeKey oldKey) { + if (SemconvStability.emitStableDatabaseSemconv()) { + return (AttributeKey) oldToNewMap.get(oldKey); + } + return oldKey; + } +} From a414139e607413d399a99c790e3b0ba8dfb9c977 Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 9 Aug 2024 14:56:12 -0700 Subject: [PATCH 05/93] Use inline --- .../cassandra-3.0/javaagent/build.gradle.kts | 6 +- .../cassandra/v3_0/CassandraSingletons.java | 3 +- .../src/test/java/CassandraClientTest.java | 78 ++++++++++++++----- .../couchbase-2.0/javaagent/build.gradle.kts | 12 +-- .../couchbase-2.6/javaagent/build.gradle.kts | 16 ++-- .../redisson-3.17/javaagent/build.gradle.kts | 8 +- .../runtimemetrics/java8/Classes.java | 12 +-- .../junit/db/SemconvStabilityUtil.java | 16 ++-- 8 files changed, 95 insertions(+), 56 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts index 14bda18fec4c..924e4db0f3a3 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/build.gradle.kts @@ -48,9 +48,9 @@ tasks { jvmArgs("-Dotel.semconv-stability.opt-in=database") } - withType().configureEach { - usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) - } + withType().configureEach { + usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) + } check { dependsOn(testStableSemconv) 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 3e010ff6d559..efa2af33ce0e 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 @@ -23,7 +23,8 @@ public final class CassandraSingletons { // could use RESPONSE "ResultSet" here, but using RESPONSE "ExecutionInfo" in cassandra-4.0 // instrumentation (see comment over there for why), so also using here for consistency private static final Instrumenter INSTRUMENTER; - private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); + private static final AttributeKey DB_COLLECTION_NAME = + AttributeKey.stringKey("db.collection.name"); static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index f31d14388222..268b8ba7b8f8 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -9,7 +9,6 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.ResultSetFuture; import com.datastax.driver.core.Session; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; @@ -102,7 +101,9 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), "USE " + parameter.keyspace))), + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "USE " + parameter.keyspace))), trace -> trace.hasSpansSatisfyingExactly( span -> @@ -116,11 +117,22 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)))); + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_NAME), + parameter.keyspace), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE), + parameter.table)))); } else { testing.waitAndAssertTraces( trace -> @@ -136,9 +148,17 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)))); + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE), + parameter.table)))); } session.close(); @@ -176,7 +196,8 @@ void asyncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), "USE " + parameter.keyspace))), trace -> trace.hasSpansSatisfyingExactly( @@ -191,11 +212,22 @@ void asyncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_NAME), parameter.keyspace), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)), + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_NAME), + parameter.keyspace), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE), + parameter.table)), span -> span.hasName("callbackListener") .hasKind(SpanKind.INTERNAL) @@ -216,9 +248,17 @@ void asyncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DbIncubatingAttributes.DB_SYSTEM, "cassandra"), equalTo( - getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), parameter.expectedStatement), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_OPERATION), parameter.operation), - equalTo(getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), parameter.table)), + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE), + parameter.table)), span -> span.hasName("callbackListener") .hasKind(SpanKind.INTERNAL) @@ -228,10 +268,6 @@ void asyncTest(Parameter parameter) { session.close(); } - protected static AttributeKey getAttributeKey(AttributeKey oldKey) { - return SemconvStabilityUtil.getAttributeKey(oldKey); - } - private static Stream provideSyncParameters() { return Stream.of( Arguments.of( diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts index b27963b88e76..13f696c31334 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/build.gradle.kts @@ -36,12 +36,12 @@ tasks { jvmArgs("-Dotel.semconv-stability.opt-in=database") } - withType().configureEach { - // required on jdk17 - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED") - jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") - } + withType().configureEach { + // required on jdk17 + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED") + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") + } check { dependsOn(testStableSemconv) diff --git a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts index a2d7c2905988..1c68002dfe1e 100644 --- a/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2.6/javaagent/build.gradle.kts @@ -39,14 +39,14 @@ tasks { jvmArgs("-Dotel.semconv-stability.opt-in=database") } - withType().configureEach { - // TODO run tests both with and without experimental span attributes - jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true") - - // required on jdk17 - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") - } + withType().configureEach { + // TODO run tests both with and without experimental span attributes + jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true") + + // required on jdk17 + jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") + jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") + } check { dependsOn(testStableSemconv) diff --git a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts index 4b4a87924a9e..6e255116700d 100644 --- a/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts +++ b/instrumentation/redisson/redisson-3.17/javaagent/build.gradle.kts @@ -29,10 +29,10 @@ tasks { jvmArgs("-Dotel.semconv-stability.opt-in=database") } - withType().configureEach { - systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) - usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) - } + withType().configureEach { + systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean) + usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) + } check { dependsOn(testStableSemconv) diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java index 1f4b8fbac3bd..d181e976ade1 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java @@ -14,13 +14,13 @@ import java.util.List; /** - *

In case you enable the preview of stable database semantic conventions (e.g. by setting the {@code - * otel.semconv-stability.opt-in} system property to {@code database}), the metrics being exported will - * follow the - * most recent database semantic conventions. + * In case you enable the preview of stable database semantic conventions (e.g. by setting the + * {@code otel.semconv-stability.opt-in} system property to {@code database}), the metrics being + * exported will follow the most + * recent database semantic conventions. * - * Registers measurements that generate metrics about JVM classes. The metrics generated by this + *

Registers measurements that generate metrics about JVM classes. The metrics generated by this * class follow the * stable JVM metrics semantic conventions. diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index 7f0868d43328..a3a333a4f35a 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -5,11 +5,6 @@ package io.opentelemetry.instrumentation.testing.junit.db; -import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; -import java.util.HashMap; -import java.util.Map; - import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_CASSANDRA_TABLE; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_COSMOSDB_CONTAINER; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_MONGODB_COLLECTION; @@ -19,14 +14,21 @@ import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SQL_TABLE; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import java.util.HashMap; +import java.util.Map; + // until old database semconv are dropped in 3.0 public class SemconvStabilityUtil { private static final Map, AttributeKey> oldToNewMap = new HashMap<>(); private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); private static final AttributeKey DB_NAMESPACE_LONG = AttributeKey.longKey("db.namespace"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); - private static final AttributeKey DB_OPERATION_NAME = AttributeKey.stringKey("db.operation.name"); - private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); + private static final AttributeKey DB_OPERATION_NAME = + AttributeKey.stringKey("db.operation.name"); + private static final AttributeKey DB_COLLECTION_NAME = + AttributeKey.stringKey("db.collection.name"); static { addKey(oldToNewMap, DB_NAME, DB_NAMESPACE); From b42b8bf8c61cf2cf74fc96d1cf80617df0916180 Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 9 Aug 2024 15:48:29 -0700 Subject: [PATCH 06/93] Fix --- .../api/internal/SemconvStability.java | 10 ++++++ .../cassandra/v3_0/CassandraSingletons.java | 13 ++------ .../testing/build.gradle.kts | 10 ++++++ .../v4/common/AbstractCassandraTest.java | 33 ++++++++++++++----- .../cassandra-4.0/javaagent/build.gradle.kts | 8 +++++ .../cassandra/v4_0/CassandraSingletons.java | 6 ++-- .../ClickHouseAttributesGetter.java | 6 ++++ 7 files changed, 66 insertions(+), 20 deletions(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java index 81ac63218cf1..f5e547bc201f 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java @@ -7,6 +7,7 @@ import static java.util.Arrays.asList; +import io.opentelemetry.api.common.AttributeKey; import java.util.HashSet; import java.util.Set; @@ -51,5 +52,14 @@ public static boolean emitStableDatabaseSemconv() { return emitStableDatabaseSemconv; } + public static AttributeKey getAttributeKey(String oldKey) { + if (emitStableDatabaseSemconv()) { + if ("db.cassandra.table".equals(oldKey)) { + return AttributeKey.stringKey("db.collection.name"); + } + } + return AttributeKey.stringKey(oldKey); + } + private SemconvStability() {} } 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 efa2af33ce0e..6da587d511d9 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 @@ -7,7 +7,6 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; @@ -23,17 +22,9 @@ public final class CassandraSingletons { // could use RESPONSE "ResultSet" here, but using RESPONSE "ExecutionInfo" in cassandra-4.0 // instrumentation (see comment over there for why), so also using here for consistency private static final Instrumenter INSTRUMENTER; - private static final AttributeKey DB_COLLECTION_NAME = - AttributeKey.stringKey("db.collection.name"); static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); - - AttributeKey tableAttribute = DbIncubatingAttributes.DB_CASSANDRA_TABLE; - if (SemconvStability.emitStableDatabaseSemconv()) { - tableAttribute = DB_COLLECTION_NAME; - } - INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -41,7 +32,9 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute(tableAttribute) + .setTableAttribute( + SemconvStability.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE.getKey())) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts b/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts index 8147a0167158..342baa7fd736 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts @@ -8,3 +8,13 @@ dependencies { implementation("org.testcontainers:testcontainers") implementation("com.datastax.oss:java-driver-core:4.0.0") } + +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + check { + dependsOn(testStableSemconv) + } +} diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index e833ab27b155..7a2087a3a3b7 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -31,6 +31,7 @@ import com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -110,9 +111,15 @@ void syncTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DB_SYSTEM, "cassandra"), - equalTo(DB_NAME, parameter.keyspace), - equalTo(DB_STATEMENT, parameter.expectedStatement), - equalTo(DB_OPERATION, parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_NAME), + parameter.keyspace), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_OPERATION), + parameter.operation), equalTo(DB_CASSANDRA_CONSISTENCY_LEVEL, "LOCAL_ONE"), equalTo(DB_CASSANDRA_COORDINATOR_DC, "datacenter1"), satisfies( @@ -123,7 +130,9 @@ void syncTest(Parameter parameter) { val -> val.isInstanceOf(Boolean.class)), equalTo(DB_CASSANDRA_PAGE_SIZE, 5000), equalTo(DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT, 0), - equalTo(DB_CASSANDRA_TABLE, parameter.table)))); + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_CASSANDRA_TABLE), + parameter.table)))); session.close(); } @@ -164,9 +173,15 @@ void asyncTest(Parameter parameter) throws Exception { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DB_SYSTEM, "cassandra"), - equalTo(DB_NAME, parameter.keyspace), - equalTo(DB_STATEMENT, parameter.expectedStatement), - equalTo(DB_OPERATION, parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_NAME), + parameter.keyspace), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_OPERATION), + parameter.operation), equalTo(DB_CASSANDRA_CONSISTENCY_LEVEL, "LOCAL_ONE"), equalTo(DB_CASSANDRA_COORDINATOR_DC, "datacenter1"), satisfies( @@ -177,7 +192,9 @@ void asyncTest(Parameter parameter) throws Exception { val -> val.isInstanceOf(Boolean.class)), equalTo(DB_CASSANDRA_PAGE_SIZE, 5000), equalTo(DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT, 0), - equalTo(DB_CASSANDRA_TABLE, parameter.table)), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_CASSANDRA_TABLE), + parameter.table)), span -> span.hasName("child") .hasKind(SpanKind.INTERNAL) diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts b/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts index 8c5f2faab149..28eb7cf3f557 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/build.gradle.kts @@ -27,4 +27,12 @@ tasks { test { usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) } + + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + check { + dependsOn(testStableSemconv) + } } 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 4da5b599d0a6..d8d065ecd661 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,6 +11,7 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -23,7 +24,6 @@ public final class CassandraSingletons { static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); - INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), @@ -31,7 +31,9 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute( + SemconvStability.getAttributeKey( + DbIncubatingAttributes.DB_CASSANDRA_TABLE.getKey())) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 2e729cdd2416..8c50190e23d0 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -50,6 +50,12 @@ public String getName(ClickHouseDbRequest request) { return dbName; } + @Nullable + @Override + public String getNamespace(ClickHouseDbRequest request) { + return getName(request); + } + @Nullable @Override public String getConnectionString(ClickHouseDbRequest request) { From 4b7c2c07a853ed94867ea7c6e31c5e608deb06d4 Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 9 Aug 2024 15:54:56 -0700 Subject: [PATCH 07/93] Fix compilation error --- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 6b7bcbb41ff6..2a0af4312a31 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -32,6 +32,12 @@ public String getName(DbExecution request) { return request.getName(); } + @Nullable + @Override + public String getNamespace(DbExecution request) { + return request.getName(); + } + @Override @Nullable public String getConnectionString(DbExecution request) { From 52e0880821dd950c3fa4efdf0985a4c99b576f9b Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 9 Aug 2024 16:04:43 -0700 Subject: [PATCH 08/93] Fix --- .../rest/internal/ElasticsearchDbAttributesGetter.java | 6 ++++++ .../transport/ElasticsearchTransportAttributesGetter.java | 6 ++++++ .../instrumentation/geode/GeodeDbAttributesGetter.java | 6 ++++++ .../influxdb/v2_4/InfluxDbAttributesGetter.java | 6 ++++++ .../instrumentation/jedis/v1_4/JedisDbAttributesGetter.java | 6 ++++++ .../instrumentation/jedis/v3_0/JedisDbAttributesGetter.java | 6 ++++++ .../instrumentation/jedis/v4_0/JedisDbAttributesGetter.java | 6 ++++++ .../lettuce/v5_0/LettuceDbAttributesGetter.java | 6 ++++++ .../instrumentation/mongo/v3_1/MongoDbAttributesGetter.java | 6 ++++++ .../opensearch/rest/OpenSearchRestAttributesGetter.java | 6 ++++++ .../rediscala/RediscalaAttributesGetter.java | 6 ++++++ .../redisson/RedissonDbAttributesGetter.java | 6 ++++++ .../spymemcached/SpymemcachedAttributesGetter.java | 6 ++++++ 13 files changed, 78 insertions(+) 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 22bc0374d444..92ac787ce2fc 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 @@ -53,6 +53,12 @@ public String getName(ElasticsearchRestRequest request) { return null; } + @Nullable + @Override + public String getNamespace(ElasticsearchRestRequest request) { + return null; + } + @Override @Nullable public String getConnectionString(ElasticsearchRestRequest request) { 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 537dd06bed20..f64789b51fa7 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 @@ -29,6 +29,12 @@ public String getName(ElasticTransportRequest s) { return null; } + @Nullable + @Override + public String getNamespace(ElasticTransportRequest s) { + return null; + } + @Override @Nullable public String getConnectionString(ElasticTransportRequest s) { diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index f0f15e7f6d2b..7c3be743d908 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -32,6 +32,12 @@ public String getName(GeodeRequest request) { return request.getRegion().getName(); } + @Nullable + @Override + public String getNamespace(GeodeRequest request) { + return request.getRegion().getName(); + } + @Override @Nullable public String getConnectionString(GeodeRequest request) { diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index c73bf348583b..cde119e0e022 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -43,6 +43,12 @@ public String getName(InfluxDbRequest request) { return "".equals(dbName) ? null : dbName; } + @Nullable + @Override + public String getNamespace(InfluxDbRequest request) { + return getName(request); + } + @Nullable @Override public String getConnectionString(InfluxDbRequest influxDbRequest) { diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 8ad1c67c30cb..24b8f87eea62 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -32,6 +32,12 @@ public String getName(JedisRequest request) { return null; } + @Nullable + @Override + public String getNamespace(JedisRequest request) { + return null; + } + @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index e2580f553f96..feaf72fab15f 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -27,6 +27,12 @@ public String getName(JedisRequest request) { return null; } + @Nullable + @Override + public String getNamespace(JedisRequest request) { + return null; + } + @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 4d77c785d768..12971c3134e7 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -27,6 +27,12 @@ public String getName(JedisRequest request) { return null; } + @Nullable + @Override + public String getNamespace(JedisRequest request) { + return null; + } + @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index a3c7050e3c79..7500dcb29ef3 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -37,6 +37,12 @@ public String getName(RedisCommand request) { return null; } + @Nullable + @Override + public String getNamespace(RedisCommand request) { + return null; + } + @Override @Nullable public String getConnectionString(RedisCommand request) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index edb3ffda13a6..8a5b155ec972 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -66,6 +66,12 @@ public String getName(CommandStartedEvent event) { return event.getDatabaseName(); } + @Nullable + @Override + public String getNamespace(CommandStartedEvent event) { + return event.getDatabaseName(); + } + @Override @Nullable public String getConnectionString(CommandStartedEvent event) { 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 79e70641dfd9..c303865c83b0 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 @@ -29,6 +29,12 @@ public String getName(OpenSearchRestRequest request) { return null; } + @Nullable + @Override + public String getNamespace(OpenSearchRestRequest openSearchRestRequest) { + return null; + } + @Override @Nullable public String getConnectionString(OpenSearchRestRequest request) { diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index a99f63faebc2..71eb32bdce1b 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -30,6 +30,12 @@ public String getName(RedisCommand redisCommand) { return null; } + @Nullable + @Override + public String getNamespace(RedisCommand redisCommand) { + return null; + } + @Override @Nullable public String getConnectionString(RedisCommand redisCommand) { diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index e11f73ec316a..f85b48f3150b 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -28,6 +28,12 @@ public String getName(RedissonRequest request) { return null; } + @Nullable + @Override + public String getNamespace(RedissonRequest request) { + return null; + } + @Override public String getConnectionString(RedissonRequest request) { return null; 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 b5778dc96a32..2379bb6df408 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 @@ -27,6 +27,12 @@ public String getName(SpymemcachedRequest spymemcachedRequest) { return null; } + @Nullable + @Override + public String getNamespace(SpymemcachedRequest spymemcachedRequest) { + return null; + } + @Override @Nullable public String getConnectionString(SpymemcachedRequest spymemcachedRequest) { From 2344545f3779cdeea4473beda93ef47262adbe8b Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 19 Aug 2024 14:56:58 -0700 Subject: [PATCH 09/93] Update --- .../db/DbClientCommonAttributesExtractor.java | 2 +- .../db/DbClientCommonAttributesGetter.java | 4 ++ .../semconv/db/DbClientSpanNameExtractor.java | 6 +-- .../db/SqlClientAttributesExtractor.java | 12 ++--- .../semconv/db/SqlClientAttributesGetter.java | 5 ++ .../db/DbClientAttributesExtractorTest.java | 1 + .../db/DbClientSpanNameExtractorTest.java | 14 ++--- .../db/SqlClientAttributesExtractorTest.java | 54 ++++++++++++++----- .../cassandra/v3_0/CassandraRequest.java | 6 +++ .../v3_0/CassandraSqlAttributesGetter.java | 7 ++- .../cassandra/v4_0/CassandraRequest.java | 6 +++ .../v4_0/CassandraSqlAttributesGetter.java | 5 ++ .../cassandra/v4_4/CassandraRequest.java | 6 +++ .../v4_4/CassandraSqlAttributesGetter.java | 7 +++ .../jdbc/internal/DbRequest.java | 6 +++ .../jdbc/internal/JdbcAttributesGetter.java | 5 ++ .../r2dbc/v1_0/internal/DbExecution.java | 8 +++ .../internal/R2dbcSqlAttributesGetter.java | 5 ++ .../sql/VertxSqlClientAttributesGetter.java | 11 ++++ .../vertx/v4_0/sql/VertxSqlClientRequest.java | 8 +++ 20 files changed, 147 insertions(+), 31 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 8649c27f0c51..4fe6a742adaf 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -41,7 +41,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST } if (SemconvStability.emitOldDatabaseSemconv()) { internalSet(attributes, DB_USER, getter.getUser(request)); - internalSet(attributes, DB_NAME, getter.getName(request)); + internalSet(attributes, DB_NAME, getter.getNamespace(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index ad27d8758395..7f0db40c4d7a 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -16,6 +16,10 @@ public interface DbClientCommonAttributesGetter { @Nullable String getUser(REQUEST request); + /** + * @deprecated Use {@link #getNamespace(Object)} instead. + */ + @Deprecated @Nullable String getName(REQUEST request); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index 534db4a2a49e..3fa317e8b4f6 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -72,7 +72,7 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter gette @Override public String extract(REQUEST request) { - String dbName = getter.getName(request); + String dbName = getter.getNamespace(request); String operation = getter.getOperation(request); return computeSpanName(dbName, operation, null); } @@ -92,8 +92,8 @@ private SqlClientSpanNameExtractor(SqlClientAttributesGetter getter) { @Override public String extract(REQUEST request) { - String dbName = getter.getName(request); - SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawStatement(request)); + String dbName = getter.getNamespace(request); + SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getDbQueryText(request)); return computeSpanName( dbName, sanitizedStatement.getOperation(), sanitizedStatement.getMainIdentifier()); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 5b728c9d79b2..da83eb0a30a1 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -20,8 +20,8 @@ * *

It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional * db.sql.table attribute. The raw SQL statements returned by the {@link - * SqlClientAttributesGetter#getRawStatement(Object)} method are sanitized before use, all statement - * parameters are removed. + * SqlClientAttributesGetter#getDbQueryText(Object)} (Object)} method are sanitized before use, all + * statement parameters are removed. */ public final class SqlClientAttributesExtractor extends DbClientCommonAttributesExtractor< @@ -69,21 +69,21 @@ public static SqlClientAttributesExtractorBuilder /** * Get the raw SQL statement. The value returned by this method is later sanitized by the {@link * SqlClientAttributesExtractor} before being set as span attribute. + * + * @deprecated Use {@link #getDbQueryText(Object)} instead. */ + @Deprecated @Nullable String getRawStatement(REQUEST request); + + String getDbQueryText(REQUEST request); } diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index fe5bba727250..fc442443dc1c 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -32,6 +32,7 @@ public String getUser(Map map) { return map.get("db.user"); } + @Deprecated @Override public String getName(Map map) { return map.get("db.name"); 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 39698bdc1ca2..c9e475b07985 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 @@ -24,8 +24,8 @@ void shouldExtractFullSpanName() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getRawStatement(dbRequest)).thenReturn("SELECT * from table"); - when(sqlAttributesGetter.getName(dbRequest)).thenReturn("database"); + when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from table"); + when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -41,8 +41,8 @@ void shouldSkipDbNameIfTableAlreadyHasDbNamePrefix() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getRawStatement(dbRequest)).thenReturn("SELECT * from another.table"); - when(sqlAttributesGetter.getName(dbRequest)).thenReturn("database"); + when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from another.table"); + when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -58,7 +58,7 @@ void shouldExtractOperationAndTable() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getRawStatement(dbRequest)).thenReturn("SELECT * from table"); + when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from table"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -75,7 +75,7 @@ void shouldExtractOperationAndName() { DbRequest dbRequest = new DbRequest(); when(dbAttributesGetter.getOperation(dbRequest)).thenReturn("SELECT"); - when(dbAttributesGetter.getName(dbRequest)).thenReturn("database"); + when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); @@ -107,7 +107,7 @@ void shouldExtractDbName() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getName(dbRequest)).thenReturn("database"); + when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); 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 5bc0e139aea5..044e39ba0be4 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 @@ -7,12 +7,12 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; -import static org.assertj.core.api.InstanceOfAssertFactories.map; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.HashMap; @@ -25,11 +25,17 @@ class SqlClientAttributesExtractorTest { static final class TestAttributesGetter implements SqlClientAttributesGetter> { + @Deprecated @Override public String getRawStatement(Map map) { return map.get("db.statement"); } + @Override + public String getDbQueryText(Map map) { + return map.get("db.query.text"); + } + @Override public String getSystem(Map map) { return map.get("db.system"); @@ -40,6 +46,8 @@ public String getUser(Map map) { return map.get("db.user"); } + @Deprecated + @Nullable @Override public String getName(Map map) { return map.get("db.name"); @@ -64,9 +72,12 @@ void shouldExtractAllAttributes() { Map request = new HashMap<>(); request.put("db.system", "myDb"); request.put("db.user", "username"); - request.put("db.name", "potatoes"); + request.put( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME).getKey(), "potatoes"); request.put("db.connection_string", "mydb:///potatoes"); - request.put("db.statement", "SELECT * FROM potato WHERE id=12345"); + request.put( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT).getKey(), + "SELECT * FROM potato WHERE id=12345"); Context context = Context.root(); @@ -85,11 +96,17 @@ void shouldExtractAllAttributes() { .containsOnly( entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), entry(DbIncubatingAttributes.DB_USER, "username"), - entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), - entry(DbIncubatingAttributes.DB_SQL_TABLE, "potato")); + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM potato WHERE id=?"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_SQL_TABLE), + "potato")); assertThat(endAttributes.build().isEmpty()).isTrue(); } @@ -112,8 +129,12 @@ void shouldNotExtractTableIfAttributeIsNotSet() { // then assertThat(attributes.build()) .containsOnly( - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT *"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT")); } @Test @@ -126,7 +147,8 @@ void shouldExtractTableToSpecifiedKey() { AttributesExtractor, Void> underTest = SqlClientAttributesExtractor., Void>builder(new TestAttributesGetter()) - .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE)) .build(); // when @@ -136,9 +158,15 @@ void shouldExtractTableToSpecifiedKey() { // then assertThat(attributes.build()) .containsOnly( - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), - entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table")); + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM table"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), + "table")); } @Test diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index 5407bb6d2f75..c6175ccca2b5 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -17,5 +17,11 @@ public static CassandraRequest create(Session session, String statement) { public abstract Session getSession(); + /** + * @deprecated Use {@link #getDbQueryText()} instead. + */ + @Deprecated public abstract String getStatement(); + + public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 7f4226106883..35464bb06395 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -43,6 +43,11 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawStatement(CassandraRequest request) { - return request.getStatement(); + return request.getDbQueryText(); + } + + @Override + public String getDbQueryText(CassandraRequest request) { + return request.getDbQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index 9c783cc3f196..dc3421b59eba 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -17,5 +17,11 @@ public static CassandraRequest create(Session session, String statement) { public abstract Session getSession(); + /** + * @deprecated Use {@link #getDbQueryText()} instead. + */ + @Deprecated public abstract String getStatement(); + + public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 610e95276839..05edf86fc760 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -46,4 +46,9 @@ public String getConnectionString(CassandraRequest request) { public String getRawStatement(CassandraRequest request) { return request.getStatement(); } + + @Override + public String getDbQueryText(CassandraRequest request) { + return request.getDbQueryText(); + } } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index 021dfc7b6c6d..daeeb1725531 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -17,5 +17,11 @@ public static CassandraRequest create(Session session, String statement) { public abstract Session getSession(); + /** + * @deprecated Use {@link #getDbQueryText()} ()} instead. + */ + @Deprecated public abstract String getStatement(); + + public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index cdb9fb92bccf..6690b0b5fbe6 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -24,6 +24,7 @@ public String getUser(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getName(CassandraRequest request) { @@ -42,9 +43,15 @@ public String getConnectionString(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getRawStatement(CassandraRequest request) { return request.getStatement(); } + + @Override + public String getDbQueryText(CassandraRequest request) { + return request.getDbQueryText(); + } } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index ef22562b3239..9c5c46ee4180 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -43,6 +43,12 @@ public static DbRequest create(DbInfo dbInfo, String statement) { public abstract DbInfo getDbInfo(); + /** + * @deprecated Use {@link #getDbQueryText()} instead. + */ + @Deprecated @Nullable public abstract String getStatement(); + + public abstract String getDbQueryText(); } 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 8dd7da5b2f28..67870dca9563 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 @@ -52,4 +52,9 @@ public String getConnectionString(DbRequest request) { public String getRawStatement(DbRequest request) { return request.getStatement(); } + + @Override + public String getDbQueryText(DbRequest dbRequest) { + return dbRequest.getDbQueryText(); + } } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java index bcdca4014339..8b77dbd0510b 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java @@ -94,10 +94,18 @@ public String getConnectionString() { return connectionString; } + /** + * @deprecated use {@link #getDbQueryText()} instead + */ + @Deprecated public String getRawStatement() { return rawStatement; } + public String getDbQueryText() { + return rawStatement; + } + public Context getContext() { return context; } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 2a0af4312a31..7e3363def18d 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -49,4 +49,9 @@ public String getConnectionString(DbExecution request) { public String getRawStatement(DbExecution request) { return request.getRawStatement(); } + + @Override + public String getDbQueryText(DbExecution request) { + return request.getDbQueryText(); + } } 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 4fa4a6ea5359..0c0e96f5a0aa 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 @@ -29,6 +29,12 @@ public String getName(VertxSqlClientRequest request) { return request.getDatabase(); } + @Nullable + @Override + public String getNamespace(VertxSqlClientRequest vertxSqlClientRequest) { + return ""; + } + @Override @Nullable public String getConnectionString(VertxSqlClientRequest request) { @@ -40,4 +46,9 @@ public String getConnectionString(VertxSqlClientRequest request) { public String getRawStatement(VertxSqlClientRequest request) { return request.getStatement(); } + + @Override + public String getDbQueryText(VertxSqlClientRequest request) { + return request.getDbQueryText(); + } } diff --git a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java index d644d8b9a742..10866f2cb3ac 100644 --- a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java +++ b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java @@ -16,10 +16,18 @@ public VertxSqlClientRequest(String statement, SqlConnectOptions sqlConnectOptio this.sqlConnectOptions = sqlConnectOptions; } + /** + * @deprecated Use {@link #getDbQueryText()} instead. + */ + @Deprecated public String getStatement() { return statement; } + public String getDbQueryText() { + return statement; + } + public String getUser() { return sqlConnectOptions != null ? sqlConnectOptions.getUser() : null; } From c8b69a7e134ee52e196560cacef5ea6f80a7ed9a Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 20 Aug 2024 09:54:59 -0700 Subject: [PATCH 10/93] Fix --- .../cassandra/v3_0/CassandraRequest.java | 10 ++-------- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 ++ .../cassandra/v4_0/CassandraRequest.java | 10 ++-------- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 4 +++- .../cassandra/v4_4/CassandraRequest.java | 10 ++-------- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 +- .../clickhouse/ClickHouseAttributesGetter.java | 1 + .../couchbase/v2_0/CouchbaseAttributesGetter.java | 1 + .../internal/ElasticsearchDbAttributesGetter.java | 1 + .../ElasticsearchTransportAttributesGetter.java | 1 + .../geode/GeodeDbAttributesGetter.java | 1 + .../influxdb/v2_4/InfluxDbAttributesGetter.java | 4 +++- .../instrumentation/jdbc/internal/DbRequest.java | 11 ++--------- .../jdbc/internal/JdbcAttributesGetter.java | 8 +++++--- .../jedis/v1_4/JedisDbAttributesGetter.java | 1 + .../jedis/v3_0/JedisDbAttributesGetter.java | 1 + .../jedis/v4_0/JedisDbAttributesGetter.java | 1 + .../lettuce/v4_0/LettuceDbAttributesGetter.java | 1 + .../lettuce/v5_0/LettuceDbAttributesGetter.java | 1 + .../mongo/v3_1/MongoDbAttributesGetter.java | 1 + .../mongo/v3_1/MongoSpanNameExtractor.java | 2 +- .../rest/OpenSearchRestAttributesGetter.java | 1 + .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 ++ .../rediscala/RediscalaAttributesGetter.java | 2 ++ .../redisson/RedissonDbAttributesGetter.java | 1 + .../spymemcached/SpymemcachedAttributesGetter.java | 1 + .../v4_0/redis/VertxRedisClientAttributesGetter.java | 9 ++++++++- .../v4_0/sql/VertxSqlClientAttributesGetter.java | 6 ++++-- 28 files changed, 53 insertions(+), 43 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index c6175ccca2b5..d2fb21a77de4 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -11,17 +11,11 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String statement) { - return new AutoValue_CassandraRequest(session, statement); + public static CassandraRequest create(Session session, String dbQueryText) { + return new AutoValue_CassandraRequest(session, dbQueryText); } public abstract Session getSession(); - /** - * @deprecated Use {@link #getDbQueryText()} instead. - */ - @Deprecated - public abstract String getStatement(); - public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 35464bb06395..c9fec176dded 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -22,6 +22,7 @@ public String getUser(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getName(CassandraRequest request) { @@ -40,6 +41,7 @@ public String getConnectionString(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getRawStatement(CassandraRequest request) { diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index dc3421b59eba..508015dbdf5c 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -11,17 +11,11 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String statement) { - return new AutoValue_CassandraRequest(session, statement); + public static CassandraRequest create(Session session, String dbQueryText) { + return new AutoValue_CassandraRequest(session, dbQueryText); } public abstract Session getSession(); - /** - * @deprecated Use {@link #getDbQueryText()} instead. - */ - @Deprecated - public abstract String getStatement(); - public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 05edf86fc760..d9ede1a85ba2 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -23,6 +23,7 @@ public String getUser(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getName(CassandraRequest request) { @@ -41,10 +42,11 @@ public String getConnectionString(CassandraRequest request) { return null; } + @Deprecated @Override @Nullable public String getRawStatement(CassandraRequest request) { - return request.getStatement(); + return request.getDbQueryText(); } @Override diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index daeeb1725531..5b58311b917a 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -11,17 +11,11 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String statement) { - return new AutoValue_CassandraRequest(session, statement); + public static CassandraRequest create(Session session, String dbQueryText) { + return new AutoValue_CassandraRequest(session, dbQueryText); } public abstract Session getSession(); - /** - * @deprecated Use {@link #getDbQueryText()} ()} instead. - */ - @Deprecated - public abstract String getStatement(); - public abstract String getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 6690b0b5fbe6..cd2d032b152a 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -47,7 +47,7 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawStatement(CassandraRequest request) { - return request.getStatement(); + return request.getDbQueryText(); } @Override diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 8c50190e23d0..1e935d733b00 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -40,6 +40,7 @@ public String getUser(ClickHouseDbRequest request) { return null; } + @Deprecated @Nullable @Override public String getName(ClickHouseDbRequest request) { diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index ee2a5f932ac7..0a1330f9cb32 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -22,6 +22,7 @@ public String getUser(CouchbaseRequestInfo couchbaseRequest) { return null; } + @Deprecated @Override @Nullable public String getName(CouchbaseRequestInfo couchbaseRequest) { 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 92ac787ce2fc..0f54da700a8a 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 @@ -47,6 +47,7 @@ public String getUser(ElasticsearchRestRequest request) { return null; } + @Deprecated @Override @Nullable public String getName(ElasticsearchRestRequest request) { 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 f64789b51fa7..d27dd053b5e6 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 @@ -23,6 +23,7 @@ public String getUser(ElasticTransportRequest s) { return null; } + @Deprecated @Override @Nullable public String getName(ElasticTransportRequest s) { diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index 7c3be743d908..da47ca2fe195 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -27,6 +27,7 @@ public String getUser(GeodeRequest request) { return null; } + @Deprecated @Override public String getName(GeodeRequest request) { return request.getRegion().getName(); diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index cde119e0e022..7b302910714a 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -36,6 +36,7 @@ public String getUser(InfluxDbRequest request) { return null; } + @Deprecated @Nullable @Override public String getName(InfluxDbRequest request) { @@ -46,7 +47,8 @@ public String getName(InfluxDbRequest request) { @Nullable @Override public String getNamespace(InfluxDbRequest request) { - return getName(request); + String dbName = request.getDbName(); + return "".equals(dbName) ? null : dbName; } @Nullable diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index 9c5c46ee4180..cc9c3b0b9b9b 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -37,18 +37,11 @@ public static DbRequest create(Statement statement, String dbStatementString) { return create(extractDbInfo(connection), dbStatementString); } - public static DbRequest create(DbInfo dbInfo, String statement) { - return new AutoValue_DbRequest(dbInfo, statement); + public static DbRequest create(DbInfo dbInfo, String dbQueryText) { + return new AutoValue_DbRequest(dbInfo, dbQueryText); } public abstract DbInfo getDbInfo(); - /** - * @deprecated Use {@link #getDbQueryText()} instead. - */ - @Deprecated - @Nullable - public abstract String getStatement(); - public abstract String getDbQueryText(); } 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 67870dca9563..86ce337ecb90 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 @@ -27,6 +27,7 @@ public String getUser(DbRequest request) { return request.getDbInfo().getUser(); } + @Deprecated @Nullable @Override public String getName(DbRequest request) { @@ -47,14 +48,15 @@ public String getConnectionString(DbRequest request) { return request.getDbInfo().getShortUrl(); } + @Deprecated @Nullable @Override public String getRawStatement(DbRequest request) { - return request.getStatement(); + return request.getDbQueryText(); } @Override - public String getDbQueryText(DbRequest dbRequest) { - return dbRequest.getDbQueryText(); + public String getDbQueryText(DbRequest request) { + return request.getDbQueryText(); } } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 24b8f87eea62..83d1dc280101 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -27,6 +27,7 @@ public String getUser(JedisRequest request) { return null; } + @Deprecated @Override public String getName(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index feaf72fab15f..f94a661cc307 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -22,6 +22,7 @@ public String getUser(JedisRequest request) { return null; } + @Deprecated @Override public String getName(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 12971c3134e7..593803561f16 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -22,6 +22,7 @@ public String getUser(JedisRequest request) { return null; } + @Deprecated @Override public String getName(JedisRequest request) { return null; diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index 8eaa86ef7d5c..d41cbeec4e00 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -23,6 +23,7 @@ public String getUser(RedisCommand request) { return null; } + @Deprecated @Override @Nullable public String getName(RedisCommand request) { diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 7500dcb29ef3..082ec6aa4d59 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -31,6 +31,7 @@ public String getUser(RedisCommand request) { return null; } + @Deprecated @Override @Nullable public String getName(RedisCommand request) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 8a5b155ec972..1df3a93a3783 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -60,6 +60,7 @@ public String getUser(CommandStartedEvent event) { return null; } + @Deprecated @Override @Nullable public String getName(CommandStartedEvent event) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java index 7910675fb919..464fbcaca66d 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java @@ -23,7 +23,7 @@ class MongoSpanNameExtractor implements SpanNameExtractor { @Override public String extract(CommandStartedEvent event) { String operation = dbAttributesGetter.getOperation(event); - String dbName = dbAttributesGetter.getName(event); + String dbName = dbAttributesGetter.getNamespace(event); if (operation == null) { return dbName == null ? DEFAULT_SPAN_NAME : dbName; } 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 c303865c83b0..59ee5ad62758 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 @@ -23,6 +23,7 @@ public String getUser(OpenSearchRestRequest request) { return null; } + @Deprecated @Override @Nullable public String getName(OpenSearchRestRequest request) { diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 7e3363def18d..aa3af0e8d4b0 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -26,6 +26,7 @@ public String getUser(DbExecution request) { return request.getUser(); } + @Deprecated @Override @Nullable public String getName(DbExecution request) { @@ -44,6 +45,7 @@ public String getConnectionString(DbExecution request) { return request.getConnectionString(); } + @Deprecated @Override @Nullable public String getRawStatement(DbExecution request) { diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index 71eb32bdce1b..664d94780752 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -24,6 +24,7 @@ public String getUser(RedisCommand redisCommand) { return null; } + @Deprecated @Override @Nullable public String getName(RedisCommand redisCommand) { @@ -42,6 +43,7 @@ public String getConnectionString(RedisCommand redisCommand) { return null; } + @Deprecated @Override @Nullable public String getStatement(RedisCommand redisCommand) { diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index f85b48f3150b..841c3cdf251e 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -22,6 +22,7 @@ public String getUser(RedissonRequest request) { return null; } + @Deprecated @Nullable @Override public String getName(RedissonRequest request) { 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 2379bb6df408..97a89ef41182 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 @@ -21,6 +21,7 @@ public String getUser(SpymemcachedRequest spymemcachedRequest) { return null; } + @Deprecated @Override @Nullable public String getName(SpymemcachedRequest spymemcachedRequest) { diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index d662aa053ad6..fcd1a2712880 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -29,10 +29,17 @@ public String getUser(VertxRedisClientRequest request) { return request.getUser(); } + @Deprecated @Override @Nullable public String getName(VertxRedisClientRequest request) { - return null; + return String.valueOf(request.getDatabaseIndex()); + } + + @Nullable + @Override + public String getNamespace(VertxRedisClientRequest request) { + return String.valueOf(request.getDatabaseIndex()); } @Override 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 0c0e96f5a0aa..936ae1e2a35f 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 @@ -23,6 +23,7 @@ public String getUser(VertxSqlClientRequest request) { return request.getUser(); } + @Deprecated @Override @Nullable public String getName(VertxSqlClientRequest request) { @@ -31,8 +32,8 @@ public String getName(VertxSqlClientRequest request) { @Nullable @Override - public String getNamespace(VertxSqlClientRequest vertxSqlClientRequest) { - return ""; + public String getNamespace(VertxSqlClientRequest request) { + return request.getDatabase(); } @Override @@ -41,6 +42,7 @@ public String getConnectionString(VertxSqlClientRequest request) { return null; } + @Deprecated @Override @Nullable public String getRawStatement(VertxSqlClientRequest request) { From 7004ada94ee701893617c8621bb4168891c637ef Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 20 Aug 2024 09:56:44 -0700 Subject: [PATCH 11/93] Comment --- .../incubator/semconv/db/DbClientCommonAttributesExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 4fe6a742adaf..8649c27f0c51 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -41,7 +41,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST } if (SemconvStability.emitOldDatabaseSemconv()) { internalSet(attributes, DB_USER, getter.getUser(request)); - internalSet(attributes, DB_NAME, getter.getNamespace(request)); + internalSet(attributes, DB_NAME, getter.getName(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); From 5ac19868e69c52ae884f2335aa08ba0e9710273e Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 20 Aug 2024 13:55:56 -0700 Subject: [PATCH 12/93] Suppress deprecation --- .../incubator/semconv/db/DbClientCommonAttributesExtractor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 8649c27f0c51..844a8ffb2370 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -34,6 +34,7 @@ abstract class DbClientCommonAttributesExtractor< this.getter = getter; } + @SuppressWarnings("deprecation") // until old db semconv are dropped @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { if (SemconvStability.emitStableDatabaseSemconv()) { From d4aedaecc604ca4ff58400b8160a15975856de23 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 20 Aug 2024 14:19:24 -0700 Subject: [PATCH 13/93] Fix deprecation --- .../instrumentation/r2dbc/v1_0/DbExecutionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java b/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java index b7de3b7c05a5..8bbe82db7f16 100644 --- a/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java +++ b/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java @@ -45,6 +45,6 @@ void dbExecution() { assertEquals("localhost", dbExecution.getHost()); assertEquals(3306, dbExecution.getPort()); assertEquals("mariadb://localhost:3306", dbExecution.getConnectionString()); - assertEquals("SELECT * from person where last_name = 'tom'", dbExecution.getRawStatement()); + assertEquals("SELECT * from person where last_name = 'tom'", dbExecution.getDbQueryText()); } } From eedb882c4a9fd8be3cd160e3dab2ca38e79f1b5b Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 20 Aug 2024 17:28:53 -0700 Subject: [PATCH 14/93] Fix span name for vertxRedisClient --- .../vertx/v4_0/redis/VertxRedisClientAttributesGetter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index fcd1a2712880..1d4c9f28f6e5 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -33,13 +33,13 @@ public String getUser(VertxRedisClientRequest request) { @Override @Nullable public String getName(VertxRedisClientRequest request) { - return String.valueOf(request.getDatabaseIndex()); + return null; } @Nullable @Override public String getNamespace(VertxRedisClientRequest request) { - return String.valueOf(request.getDatabaseIndex()); + return null; } @Override From fea0cc7dd90da434ec43695e24652e2c1f98cba6 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 21 Aug 2024 13:31:07 -0700 Subject: [PATCH 15/93] Fix --- .../db/DbClientAttributesExtractorTest.java | 22 ++- .../AbstractRedissonAsyncClientTest.java | 26 +++- .../redisson/AbstractRedissonClientTest.java | 127 ++++++++++++++---- 3 files changed, 137 insertions(+), 38 deletions(-) diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index fc442443dc1c..121d9c215b42 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -12,6 +12,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.HashMap; @@ -67,10 +68,15 @@ void shouldExtractAllAvailableAttributes() { Map request = new HashMap<>(); request.put("db.system", "myDb"); request.put("db.user", "username"); - request.put("db.name", "potatoes"); + request.put( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME).getKey(), "potatoes"); request.put("db.connection_string", "mydb:///potatoes"); - request.put("db.statement", "SELECT * FROM potato"); - request.put("db.operation", "SELECT"); + request.put( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT).getKey(), + "SELECT * FROM potato"); + request.put( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION).getKey(), + "SELECT"); Context context = Context.root(); @@ -89,10 +95,14 @@ void shouldExtractAllAvailableAttributes() { .containsOnly( entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), entry(DbIncubatingAttributes.DB_USER, "username"), - entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM potato"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT")); assertThat(endAttributes.build().isEmpty()).isTrue(); } diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 6f565a02a80d..78dc22af323c 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -16,6 +16,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.io.Serializable; @@ -226,7 +227,10 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "MULTI;SET batch1 ?")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "MULTI;SET batch1 ?")) .hasParent(trace.getSpan(0)), span -> span.hasName("SET") @@ -236,8 +240,14 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SET batch2 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SET")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SET batch2 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SET")) .hasParent(trace.getSpan(0)), span -> span.hasName("EXEC") @@ -247,8 +257,14 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "EXEC"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "EXEC")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "EXEC"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "EXEC")) .hasParent(trace.getSpan(0)), span -> span.hasName("callback").hasKind(INTERNAL).hasParent(trace.getSpan(0)))); } diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index ca9fa0d72f6c..2a1658e0478e 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -16,6 +16,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.sdk.testing.assertj.TraceAssert; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -122,8 +123,14 @@ void stringCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SET foo ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SET"))), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SET foo ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SET"))), trace -> trace.hasSpansSatisfyingExactly( span -> @@ -134,8 +141,14 @@ void stringCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "GET foo"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "GET")))); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "GET foo"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "GET")))); } @Test @@ -161,7 +174,8 @@ void batchCommand() equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), "SET batch1 ?;SET batch2 ?")))); } @@ -202,7 +216,10 @@ void atomicBatchCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "MULTI;SET batch1 ?")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "MULTI;SET batch1 ?")) .hasParent(trace.getSpan(0)), span -> span.hasName("SET") @@ -212,8 +229,14 @@ void atomicBatchCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SET batch2 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SET")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SET batch2 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SET")) .hasParent(trace.getSpan(0)), span -> span.hasName("EXEC") @@ -223,8 +246,14 @@ void atomicBatchCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "EXEC"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "EXEC")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "EXEC"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "EXEC")) .hasParent(trace.getSpan(0)))); } @@ -245,8 +274,14 @@ void listCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "RPUSH list1 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "RPUSH")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "RPUSH list1 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "RPUSH")) .hasNoParent())); } @@ -271,9 +306,13 @@ void hashCommand() { equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), String.format("EVAL %s 1 map1 ? ?", script)), - equalTo(DbIncubatingAttributes.DB_OPERATION, "EVAL"))), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "EVAL"))), trace -> trace.hasSpansSatisfyingExactly( span -> @@ -284,8 +323,14 @@ void hashCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "HGET map1 key1"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "HGET")))); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "HGET map1 key1"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "HGET")))); } @Test @@ -305,8 +350,14 @@ void setCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SADD set1 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SADD")))); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SADD set1 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SADD")))); } @Test @@ -334,8 +385,13 @@ void sortedSetCommand() equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), equalTo( - DbIncubatingAttributes.DB_STATEMENT, "ZADD sort_set1 ? ? ? ? ? ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "ZADD")))); + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "ZADD sort_set1 ? ? ? ? ? ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "ZADD")))); } private static void invokeAddAll(RScoredSortedSet object, Map arg) @@ -360,8 +416,14 @@ void atomicLongCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "INCR AtomicLong"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "INCR")))); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "INCR AtomicLong"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "INCR")))); } @Test @@ -386,9 +448,13 @@ void lockCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "EVAL"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "EVAL"), satisfies( - DbIncubatingAttributes.DB_STATEMENT, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), stringAssert -> stringAssert.startsWith("EVAL"))))); traceAsserts.add( trace -> @@ -401,7 +467,10 @@ void lockCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "EVAL"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "EVAL"), satisfies( DbIncubatingAttributes.DB_STATEMENT, stringAssert -> stringAssert.startsWith("EVAL"))))); @@ -417,9 +486,13 @@ void lockCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "DEL"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "DEL"), satisfies( - DbIncubatingAttributes.DB_STATEMENT, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), stringAssert -> stringAssert.startsWith("DEL"))))); } From 844f068010c56521a0f5d5d8c7bd0925f2e7dcae Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 12:00:39 -0700 Subject: [PATCH 16/93] Fix network_type --- .../redisson/AbstractRedissonClientTest.java | 134 ++++++++++++++---- 1 file changed, 103 insertions(+), 31 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 2a1658e0478e..24da443f4ff3 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -119,7 +119,12 @@ void stringCommand() { span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -137,7 +142,12 @@ void stringCommand() { span.hasName("GET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -169,7 +179,12 @@ void batchCommand() span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -212,7 +227,12 @@ void atomicBatchCommand() { span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -225,7 +245,12 @@ void atomicBatchCommand() { span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -242,7 +267,12 @@ void atomicBatchCommand() { span.hasName("EXEC") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -270,7 +300,12 @@ void listCommand() { span.hasName("RPUSH") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -301,7 +336,12 @@ void hashCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -319,7 +359,12 @@ void hashCommand() { span.hasName("HGET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -342,22 +387,22 @@ void setCommand() { orderByRootSpanKind(SpanKind.INTERNAL, SpanKind.CLIENT), trace -> trace.hasSpansSatisfyingExactly( - span -> - span.hasName("SADD") - .hasKind(CLIENT) - .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), - equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), - equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo( - SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_STATEMENT), - "SADD set1 ?"), - equalTo( - SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_OPERATION), - "SADD")))); + span -> { + span.hasName("SADD") + .hasKind(CLIENT) + .hasAttributesSatisfyingExactly( + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo(DbIncubatingAttributes.DB_STATEMENT, "SADD set1 ?"), + equalTo(DbIncubatingAttributes.DB_OPERATION, "SADD")); + })); } @Test @@ -380,7 +425,12 @@ void sortedSetCommand() span.hasName("ZADD") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -412,7 +462,12 @@ void atomicLongCommand() { span.hasName("INCR") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -444,7 +499,12 @@ void lockCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -463,7 +523,12 @@ void lockCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -472,7 +537,8 @@ void lockCommand() { DbIncubatingAttributes.DB_OPERATION), "EVAL"), satisfies( - DbIncubatingAttributes.DB_STATEMENT, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), stringAssert -> stringAssert.startsWith("EVAL"))))); if (lockHas3Traces()) { traceAsserts.add( @@ -482,7 +548,13 @@ void lockCommand() { span.hasName("DEL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), From 7418c42e1e279b1fdf222708c0355330af960a4a Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 15:42:09 -0700 Subject: [PATCH 17/93] Fix cassandra tests --- .../v4/common/AbstractCassandraTest.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index 7a2087a3a3b7..e7739b873af9 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -30,6 +30,7 @@ import com.datastax.oss.driver.api.core.config.DriverConfigLoader; import com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; @@ -102,10 +103,13 @@ void syncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> + val -> { + if (SemconvStability.emitOldDatabaseSemconv()) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6"))), + v -> assertThat(v).isEqualTo("ipv6")); + } + }), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -164,10 +168,13 @@ void asyncTest(Parameter parameter) throws Exception { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> + val -> { + if (SemconvStability.emitOldDatabaseSemconv()) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6"))), + v -> assertThat(v).isEqualTo("ipv6")); + } + }), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From 9f1412e865fedc6f49fccad69a8ac0136c39a971 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 16:12:09 -0700 Subject: [PATCH 18/93] Fix cassandraClient test --- .../src/test/java/CassandraClientTest.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 268b8ba7b8f8..1d5fa3db337a 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -94,7 +94,13 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -111,7 +117,13 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -189,7 +201,13 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From 02dab035702c103b34b3579ddb00f8849a90d2ae Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 17:05:56 -0700 Subject: [PATCH 19/93] Fix RedissonClientTest --- .../redisson/AbstractRedissonClientTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 24da443f4ff3..ad945760a4be 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -400,8 +400,14 @@ void setCommand() { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SADD set1 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SADD")); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SADD set1 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SADD")); })); } From 267ea56a3e7c95816bea7fc6903fee5f0005eaf9 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 17:35:55 -0700 Subject: [PATCH 20/93] Fix db.statement vs. db.query.text --- .../semconv/db/SqlClientAttributesExtractor.java | 12 ++++++++---- .../semconv/db/DbClientAttributesExtractorTest.java | 4 ++++ .../db/SqlClientAttributesExtractorTest.java | 13 ++++++++----- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index da83eb0a30a1..2ef0ba727c42 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -65,25 +65,29 @@ public static SqlClientAttributesExtractorBuilder map) { @Override public String getOperation(Map map) { + if (SemconvStability.emitStableDatabaseSemconv()) { + return map.get("db.operation.name"); + } return map.get("db.operation"); } } 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 044e39ba0be4..e4c0af52869b 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 @@ -12,6 +12,7 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; @@ -72,12 +73,14 @@ void shouldExtractAllAttributes() { Map request = new HashMap<>(); request.put("db.system", "myDb"); request.put("db.user", "username"); - request.put( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME).getKey(), "potatoes"); request.put("db.connection_string", "mydb:///potatoes"); - request.put( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT).getKey(), - "SELECT * FROM potato WHERE id=12345"); + if (SemconvStability.emitOldDatabaseSemconv()) { + request.put("db.name", "potatoes"); + request.put("db.statement", "SELECT * FROM potato WHERE id=12345"); + } else if (SemconvStability.emitStableDatabaseSemconv()) { + request.put("db.namespace", "potatoes"); + request.put("db.query.text", "SELECT * FROM potato WHERE id=12345"); + } Context context = Context.root(); From 08d4ffd51d0ecf00bd9d7b77ad7cc5e4a211cf70 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 17:47:49 -0700 Subject: [PATCH 21/93] Fix --- instrumentation-api-incubator/build.gradle.kts | 4 ++++ .../javaagent/src/test/java/CassandraClientTest.java | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/instrumentation-api-incubator/build.gradle.kts b/instrumentation-api-incubator/build.gradle.kts index c1d0b6202460..846dd96908c5 100644 --- a/instrumentation-api-incubator/build.gradle.kts +++ b/instrumentation-api-incubator/build.gradle.kts @@ -75,4 +75,8 @@ tasks { sourcesJar { dependsOn("generateJflex") } + + check { + dependsOn(testing.suites) + } } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 1d5fa3db337a..929f7d0fa63b 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -154,6 +154,13 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From e7dba95e3144ed97825e811388dacf121025ed90 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 28 Aug 2024 18:42:05 -0700 Subject: [PATCH 22/93] Fix AbstractRedissonAsyncClientTest --- .../AbstractRedissonAsyncClientTest.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 78dc22af323c..1b60c0ca8961 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -116,7 +116,12 @@ void futureSet() throws ExecutionException, InterruptedException, TimeoutExcepti span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -149,7 +154,12 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo span.hasName("SADD") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -223,7 +233,12 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -236,7 +251,12 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -253,7 +273,12 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("EXEC") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), From 630ae935cbb5242ca14ea035649f598285403872 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 09:22:11 -0700 Subject: [PATCH 23/93] Fix --- .../AbstractRedissonAsyncClientTest.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 1b60c0ca8961..78a207a087bf 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -125,8 +125,14 @@ void futureSet() throws ExecutionException, InterruptedException, TimeoutExcepti equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SET foo ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SET")))); + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SET foo ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SET")))); } @Test @@ -163,8 +169,14 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, "SADD set1 ?"), - equalTo(DbIncubatingAttributes.DB_OPERATION, "SADD")) + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SADD set1 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SADD")) .hasParent(trace.getSpan(0)), span -> span.hasName("callback").hasKind(INTERNAL).hasParent(trace.getSpan(0)))); } From 2db670b919b2334197604ed932728708e7dc7415 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 11:45:21 -0700 Subject: [PATCH 24/93] Fix couchbase tests --- .../testing/junit/db/SemconvStabilityUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index a3a333a4f35a..eaf873b32236 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -55,4 +55,8 @@ public static AttributeKey getAttributeKey(AttributeKey oldKey) { } return oldKey; } + + public boolean isStable() { + return SemconvStability.emitStableDatabaseSemconv(); + } } From 52a654bf975efa3dfed97986c17e116b75d4d586 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 12:24:22 -0700 Subject: [PATCH 25/93] Fix --- .../testing/junit/db/SemconvStabilityUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index eaf873b32236..4dc3d62f1e2a 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -50,13 +50,13 @@ private static void addKey( @SuppressWarnings("unchecked") public static AttributeKey getAttributeKey(AttributeKey oldKey) { - if (SemconvStability.emitStableDatabaseSemconv()) { + if (isStable()) { return (AttributeKey) oldToNewMap.get(oldKey); } return oldKey; } - public boolean isStable() { + public static boolean isStable() { return SemconvStability.emitStableDatabaseSemconv(); } } From 4bad92846b02a40297698ca3e34268e4daeb452a Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 16:34:56 -0700 Subject: [PATCH 26/93] Fix cassandraclienttest 3.0 --- .../src/test/java/CassandraClientTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 929f7d0fa63b..664d668d8e50 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -232,6 +232,13 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -267,6 +274,13 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStabilityUtil.getAttributeKey( + NetworkAttributes.NETWORK_TYPE) + == null + ? null + : "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From d387c6428ca4072e3fe26d08332248df7472fcd4 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 17:40:27 -0700 Subject: [PATCH 27/93] Fix cassandra sync test --- .../cassandra/cassandra-4.4/library/build.gradle.kts | 10 ++++++++++ .../cassandra/v4_4/CassandraTelemetryBuilder.java | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts b/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts index c0f0592742a9..963467200f5d 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4.4/library/build.gradle.kts @@ -10,3 +10,13 @@ dependencies { testImplementation(project(":instrumentation:cassandra:cassandra-4.4:testing")) } + +tasks { + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + check { + dependsOn(testStableSemconv) + } +} 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 6d39ac2d6f0a..b3d063ac43d8 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 @@ -13,6 +13,7 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; /** A builder of {@link CassandraTelemetry}. */ @@ -58,7 +59,7 @@ protected Instrumenter createInstrumenter( openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute(DB_CASSANDRA_TABLE) + .setTableAttribute(SemconvStability.getAttributeKey(DB_CASSANDRA_TABLE.getKey())) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( From ef407b48324cd378827613f67355dcd8fc16c100 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 17:48:43 -0700 Subject: [PATCH 28/93] Fix --- .../testing/cassandra/v4_4/AbstractCassandra44Test.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index bd3357978d36..55ba36774bf1 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -27,6 +27,7 @@ import com.datastax.oss.driver.api.core.CqlSession; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.cassandra.v4.common.AbstractCassandraTest; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.NetworkAttributes; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; @@ -61,10 +62,13 @@ void reactiveTest(Parameter parameter) { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> + val -> { + if (SemconvStability.emitOldDatabaseSemconv()) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6"))), + v -> assertThat(v).isEqualTo("ipv6")); + } + }), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From 5d942c399551efdcfa4f80a5c4b3f7c83a902072 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 29 Aug 2024 18:04:07 -0700 Subject: [PATCH 29/93] Fix --- .../cassandra/v4_4/AbstractCassandra44Test.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 55ba36774bf1..1dc8c26c3698 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -28,6 +28,7 @@ import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.cassandra.v4.common.AbstractCassandraTest; import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; import java.util.stream.Stream; import org.junit.jupiter.params.ParameterizedTest; @@ -75,8 +76,12 @@ void reactiveTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DB_SYSTEM, "cassandra"), equalTo(DB_NAME, parameter.keyspace), - equalTo(DB_STATEMENT, parameter.expectedStatement), - equalTo(DB_OPERATION, parameter.operation), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_STATEMENT), + parameter.expectedStatement), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_OPERATION), + parameter.operation), equalTo(DB_CASSANDRA_CONSISTENCY_LEVEL, "LOCAL_ONE"), equalTo(DB_CASSANDRA_COORDINATOR_DC, "datacenter1"), satisfies( @@ -87,7 +92,9 @@ void reactiveTest(Parameter parameter) { val -> val.isInstanceOf(Boolean.class)), equalTo(DB_CASSANDRA_PAGE_SIZE, 5000), equalTo(DB_CASSANDRA_SPECULATIVE_EXECUTION_COUNT, 0), - equalTo(DB_CASSANDRA_TABLE, parameter.table)), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_CASSANDRA_TABLE), + parameter.table)), span -> span.hasName("child") .hasKind(SpanKind.INTERNAL) From e1055650c2ff16e68d342f6f571cf959eb6e0927 Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 30 Aug 2024 08:47:17 -0700 Subject: [PATCH 30/93] Fix --- .../testing/cassandra/v4_4/AbstractCassandra44Test.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 1dc8c26c3698..c08b809f7492 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -75,7 +75,9 @@ void reactiveTest(Parameter parameter) { equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), equalTo(NetworkAttributes.NETWORK_PEER_PORT, cassandraPort), equalTo(DB_SYSTEM, "cassandra"), - equalTo(DB_NAME, parameter.keyspace), + equalTo( + SemconvStabilityUtil.getAttributeKey(DB_NAME), + parameter.keyspace), equalTo( SemconvStabilityUtil.getAttributeKey(DB_STATEMENT), parameter.expectedStatement), From 0caa7aaae53294132d87daaed97db04a1e4657da Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 10:42:59 -0700 Subject: [PATCH 31/93] Deprecate getUser and getConnectionString --- .../incubator/semconv/db/DbClientCommonAttributesGetter.java | 2 ++ .../incubator/semconv/db/SqlClientAttributesExtractor.java | 4 ++-- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 ++ .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 ++ .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 ++ .../clickhouse/ClickHouseAttributesGetter.java | 2 ++ .../couchbase/v2_0/CouchbaseAttributesGetter.java | 2 ++ .../rest/internal/ElasticsearchDbAttributesGetter.java | 2 ++ .../transport/ElasticsearchTransportAttributesGetter.java | 2 ++ .../instrumentation/geode/GeodeDbAttributesGetter.java | 2 ++ .../influxdb/v2_4/InfluxDbAttributesGetter.java | 2 ++ .../instrumentation/jdbc/internal/JdbcAttributesGetter.java | 2 ++ .../instrumentation/jedis/v1_4/JedisDbAttributesGetter.java | 2 ++ .../instrumentation/jedis/v3_0/JedisDbAttributesGetter.java | 2 ++ .../instrumentation/jedis/v4_0/JedisDbAttributesGetter.java | 2 ++ .../lettuce/v4_0/LettuceDbAttributesGetter.java | 2 ++ .../lettuce/v5_0/LettuceDbAttributesGetter.java | 2 ++ .../instrumentation/mongo/v3_1/MongoDbAttributesGetter.java | 2 ++ 18 files changed, 36 insertions(+), 2 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index 7f0db40c4d7a..109893ded31e 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -13,6 +13,7 @@ public interface DbClientCommonAttributesGetter { @Nullable String getSystem(REQUEST request); + @Deprecated @Nullable String getUser(REQUEST request); @@ -26,6 +27,7 @@ public interface DbClientCommonAttributesGetter { @Nullable String getNamespace(REQUEST request); + @Deprecated @Nullable String getConnectionString(REQUEST request); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 2ef0ba727c42..6eeed7610441 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -20,8 +20,8 @@ * *

It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional * db.sql.table attribute. The raw SQL statements returned by the {@link - * SqlClientAttributesGetter#getDbQueryText(Object)} (Object)} method are sanitized before use, all - * statement parameters are removed. + * SqlClientAttributesGetter#getDbQueryText(Object)} method are sanitized before use, all statement + * parameters are removed. */ public final class SqlClientAttributesExtractor extends DbClientCommonAttributesExtractor< diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index c9fec176dded..2541265d3fe8 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -16,6 +16,7 @@ public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } + @Deprecated @Override @Nullable public String getUser(CassandraRequest request) { @@ -35,6 +36,7 @@ public String getNamespace(CassandraRequest request) { return request.getSession().getLoggedKeyspace(); } + @Deprecated @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index d9ede1a85ba2..d0307769f17d 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -17,6 +17,7 @@ public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } + @Deprecated @Override @Nullable public String getUser(CassandraRequest request) { @@ -36,6 +37,7 @@ public String getNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } + @Deprecated @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index cd2d032b152a..9cc5f468f68b 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -18,6 +18,7 @@ public String getSystem(CassandraRequest request) { return CASSANDRA; } + @Deprecated @Override @Nullable public String getUser(CassandraRequest request) { @@ -37,6 +38,7 @@ public String getNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } + @Deprecated @Override @Nullable public String getConnectionString(CassandraRequest request) { diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 1e935d733b00..5572928ce439 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -34,6 +34,7 @@ public String getSystem(ClickHouseDbRequest request) { return DbIncubatingAttributes.DbSystemValues.CLICKHOUSE; } + @Deprecated @Nullable @Override public String getUser(ClickHouseDbRequest request) { @@ -57,6 +58,7 @@ public String getNamespace(ClickHouseDbRequest request) { return getName(request); } + @Deprecated @Nullable @Override public String getConnectionString(ClickHouseDbRequest request) { diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index 0a1330f9cb32..e47bbe3fc9c4 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -16,6 +16,7 @@ public String getSystem(CouchbaseRequestInfo couchbaseRequest) { return DbIncubatingAttributes.DbSystemValues.COUCHBASE; } + @Deprecated @Override @Nullable public String getUser(CouchbaseRequestInfo couchbaseRequest) { @@ -35,6 +36,7 @@ public String getNamespace(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.bucket(); } + @Deprecated @Override @Nullable public String getConnectionString(CouchbaseRequestInfo couchbaseRequest) { 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 0f54da700a8a..1ed361eb76de 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 @@ -41,6 +41,7 @@ public String getSystem(ElasticsearchRestRequest request) { return ELASTICSEARCH; } + @Deprecated @Override @Nullable public String getUser(ElasticsearchRestRequest request) { @@ -60,6 +61,7 @@ public String getNamespace(ElasticsearchRestRequest request) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(ElasticsearchRestRequest request) { 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 d27dd053b5e6..78625a85cfee 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 @@ -17,6 +17,7 @@ public String getSystem(ElasticTransportRequest s) { return DbIncubatingAttributes.DbSystemValues.ELASTICSEARCH; } + @Deprecated @Override @Nullable public String getUser(ElasticTransportRequest s) { @@ -36,6 +37,7 @@ public String getNamespace(ElasticTransportRequest s) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(ElasticTransportRequest s) { diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index da47ca2fe195..00fdb61779dc 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -21,6 +21,7 @@ public String getSystem(GeodeRequest request) { return DbIncubatingAttributes.DbSystemValues.GEODE; } + @Deprecated @Override @Nullable public String getUser(GeodeRequest request) { @@ -39,6 +40,7 @@ public String getNamespace(GeodeRequest request) { return request.getRegion().getName(); } + @Deprecated @Override @Nullable public String getConnectionString(GeodeRequest request) { diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index 7b302910714a..aea03d43dfdd 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -30,6 +30,7 @@ public String getSystem(InfluxDbRequest request) { return "influxdb"; } + @Deprecated @Nullable @Override public String getUser(InfluxDbRequest request) { @@ -51,6 +52,7 @@ public String getNamespace(InfluxDbRequest request) { return "".equals(dbName) ? null : dbName; } + @Deprecated @Nullable @Override public String getConnectionString(InfluxDbRequest influxDbRequest) { 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 86ce337ecb90..9019c1ce73b8 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 @@ -21,6 +21,7 @@ public String getSystem(DbRequest request) { return request.getDbInfo().getSystem(); } + @Deprecated @Nullable @Override public String getUser(DbRequest request) { @@ -42,6 +43,7 @@ public String getNamespace(DbRequest request) { return dbInfo.getName() == null ? dbInfo.getDb() : dbInfo.getName(); } + @Deprecated @Nullable @Override public String getConnectionString(DbRequest request) { diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 83d1dc280101..012b905ee612 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -21,6 +21,7 @@ public String getSystem(JedisRequest request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(JedisRequest request) { @@ -39,6 +40,7 @@ public String getNamespace(JedisRequest request) { return null; } + @Deprecated @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index f94a661cc307..c068078ea200 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -16,6 +16,7 @@ public String getSystem(JedisRequest request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(JedisRequest request) { @@ -34,6 +35,7 @@ public String getNamespace(JedisRequest request) { return null; } + @Deprecated @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 593803561f16..23a04274d734 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -16,6 +16,7 @@ public String getSystem(JedisRequest request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(JedisRequest request) { @@ -34,6 +35,7 @@ public String getNamespace(JedisRequest request) { return null; } + @Deprecated @Override public String getConnectionString(JedisRequest request) { return null; diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index d41cbeec4e00..886ed9c268fb 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -17,6 +17,7 @@ public String getSystem(RedisCommand request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(RedisCommand request) { @@ -36,6 +37,7 @@ public String getNamespace(RedisCommand request) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(RedisCommand request) { diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 082ec6aa4d59..4a11cb470fab 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -25,6 +25,7 @@ public String getSystem(RedisCommand request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(RedisCommand request) { @@ -44,6 +45,7 @@ public String getNamespace(RedisCommand request) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(RedisCommand request) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 1df3a93a3783..ee338228563b 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -54,6 +54,7 @@ public String getSystem(CommandStartedEvent event) { return MONGODB; } + @Deprecated @Override @Nullable public String getUser(CommandStartedEvent event) { @@ -73,6 +74,7 @@ public String getNamespace(CommandStartedEvent event) { return event.getDatabaseName(); } + @Deprecated @Override @Nullable public String getConnectionString(CommandStartedEvent event) { From 5cf662c87970c6d63cf151b68b6ccbf8549136ef Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 11:29:51 -0700 Subject: [PATCH 32/93] Deprecate getOperation and getStatement --- .../db/DbClientAttributesExtractor.java | 8 ++--- .../semconv/db/DbClientAttributesGetter.java | 12 +++++++ .../semconv/db/DbClientSpanNameExtractor.java | 13 ++++---- .../db/SqlClientAttributesExtractor.java | 4 +-- .../semconv/db/SqlClientAttributesGetter.java | 5 +-- .../db/DbClientSpanNameExtractorTest.java | 10 +++--- .../db/SqlClientAttributesExtractorTest.java | 2 +- .../v3_0/CassandraSqlAttributesGetter.java | 2 +- .../v4_0/CassandraSqlAttributesGetter.java | 2 +- .../v4_4/CassandraSqlAttributesGetter.java | 2 +- .../ClickHouseAttributesGetter.java | 20 +++++++++++ .../v2_0/CouchbaseAttributesGetter.java | 14 ++++++++ .../ElasticsearchDbAttributesGetter.java | 33 +++++++++++++++++++ .../ElasticsearchSpanNameExtractor.java | 2 +- ...lasticsearchTransportAttributesGetter.java | 29 +++++++++++----- .../geode/GeodeDbAttributesGetter.java | 15 +++++++++ .../v2_4/InfluxDbAttributesGetter.java | 17 ++++++++++ .../jdbc/internal/JdbcAttributesGetter.java | 2 +- .../jedis/v1_4/JedisDbAttributesGetter.java | 13 ++++++++ .../jedis/v3_0/JedisDbAttributesGetter.java | 14 ++++++++ .../jedis/v4_0/JedisDbAttributesGetter.java | 14 ++++++++ .../v4_0/LettuceDbAttributesGetter.java | 14 ++++++++ .../v5_0/LettuceDbAttributesGetter.java | 19 +++++++++++ .../mongo/v3_1/MongoDbAttributesGetter.java | 14 ++++++++ .../mongo/v3_1/MongoSpanNameExtractor.java | 2 +- .../rest/OpenSearchRestAttributesGetter.java | 14 +++++++- .../internal/R2dbcSqlAttributesGetter.java | 2 +- .../rediscala/RediscalaAttributesGetter.java | 12 +++++++ .../redisson/RedissonDbAttributesGetter.java | 13 ++++++++ .../SpymemcachedAttributesGetter.java | 14 ++++++++ .../sql/VertxSqlClientAttributesGetter.java | 2 +- 31 files changed, 302 insertions(+), 37 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index 73faf73f95a2..94337f6f97d8 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -48,12 +48,12 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST super.onStart(attributes, parentContext, request); if (SemconvStability.emitStableDatabaseSemconv()) { - internalSet(attributes, DB_QUERY_TEXT, getter.getStatement(request)); - internalSet(attributes, DB_OPERATION_NAME, getter.getOperation(request)); + internalSet(attributes, DB_QUERY_TEXT, getter.getDbQueryText(request)); + internalSet(attributes, DB_OPERATION_NAME, getter.getOperationName(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); - internalSet(attributes, DB_OPERATION, getter.getOperation(request)); + internalSet(attributes, DB_STATEMENT, getter.getDbQueryText(request)); + internalSet(attributes, DB_OPERATION, getter.getOperationName(request)); } } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 0d924b3dcfbf..0a506c0cc995 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -20,9 +20,21 @@ */ public interface DbClientAttributesGetter extends DbClientCommonAttributesGetter { + /** + * @deprecated Use {@link #getDbQueyText(Object)} instead. + */ @Nullable String getStatement(REQUEST request); + @Nullable + String getDbQueryText(REQUEST request); + + /** + * @deprecated Use {@link #getOperationName(Object)} instead. + */ @Nullable String getOperation(REQUEST request); + + @Nullable + String getOperationName(REQUEST request); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index 3fa317e8b4f6..879e5a0af1bb 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -13,8 +13,9 @@ public abstract class DbClientSpanNameExtractor implements SpanNameExtr * Returns a {@link SpanNameExtractor} that constructs the span name according to DB semantic * conventions: {@code }. * - * @see DbClientAttributesGetter#getOperation(Object) used to extract {@code }. - * @see DbClientAttributesGetter#getName(Object) used to extract {@code }. + * @see DbClientAttributesGetter#getOperationName(Object) used to extract {@code + * }. + * @see DbClientAttributesGetter#getNamespace(Object) used to extract {@code }. */ public static SpanNameExtractor create( DbClientAttributesGetter getter) { @@ -25,8 +26,8 @@ public static SpanNameExtractor create( * Returns a {@link SpanNameExtractor} that constructs the span name according to DB semantic * conventions: {@code .}. * - * @see SqlStatementInfo#getOperation() used to extract {@code }. - * @see DbClientAttributesGetter#getName(Object) used to extract {@code }. + * @see SqlStatementInfo#getOperation() () used to extract {@code }. + * @see DbClientAttributesGetter#getNamespace(Object) used to extract {@code }. * @see SqlStatementInfo#getMainIdentifier() used to extract {@code } or stored * procedure name. */ @@ -73,7 +74,7 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter gette @Override public String extract(REQUEST request) { String dbName = getter.getNamespace(request); - String operation = getter.getOperation(request); + String operation = getter.getOperationName(request); return computeSpanName(dbName, operation, null); } } @@ -93,7 +94,7 @@ private SqlClientSpanNameExtractor(SqlClientAttributesGetter getter) { @Override public String extract(REQUEST request) { String dbName = getter.getNamespace(request); - SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getDbQueryText(request)); + SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawQueryText(request)); return computeSpanName( dbName, sanitizedStatement.getOperation(), sanitizedStatement.getMainIdentifier()); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 6eeed7610441..80674d3488c0 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -20,7 +20,7 @@ * *

It sets the same set of attributes as {@link DbClientAttributesExtractor} plus an additional * db.sql.table attribute. The raw SQL statements returned by the {@link - * SqlClientAttributesGetter#getDbQueryText(Object)} method are sanitized before use, all statement + * SqlClientAttributesGetter#getRawQueryText(Object)} method are sanitized before use, all statement * parameters are removed. */ public final class SqlClientAttributesExtractor @@ -72,7 +72,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST String statement = SemconvStability.emitStableDatabaseSemconv() - ? getter.getDbQueryText(request) + ? getter.getRawQueryText(request) : getter.getRawStatement(request); SqlStatementInfo sanitizedStatement = sanitizer.sanitize(statement); String operation = sanitizedStatement.getOperation(); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java index 3dc906b05311..68bb417d294d 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java @@ -25,11 +25,12 @@ public interface SqlClientAttributesGetter * Get the raw SQL statement. The value returned by this method is later sanitized by the {@link * SqlClientAttributesExtractor} before being set as span attribute. * - * @deprecated Use {@link #getDbQueryText(Object)} instead. + * @deprecated Use {@link #getRawQueryText(Object)} instead. */ @Deprecated @Nullable String getRawStatement(REQUEST request); - String getDbQueryText(REQUEST request); + @Nullable + String getRawQueryText(REQUEST request); } 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 c9e475b07985..e91fc7b6ff7d 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 @@ -24,7 +24,7 @@ void shouldExtractFullSpanName() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from table"); + when(sqlAttributesGetter.getRawQueryText(dbRequest)).thenReturn("SELECT * from table"); when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -41,7 +41,7 @@ void shouldSkipDbNameIfTableAlreadyHasDbNamePrefix() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from another.table"); + when(sqlAttributesGetter.getRawQueryText(dbRequest)).thenReturn("SELECT * from another.table"); when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -58,7 +58,7 @@ void shouldExtractOperationAndTable() { // given DbRequest dbRequest = new DbRequest(); - when(sqlAttributesGetter.getDbQueryText(dbRequest)).thenReturn("SELECT * from table"); + when(sqlAttributesGetter.getRawQueryText(dbRequest)).thenReturn("SELECT * from table"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -74,7 +74,7 @@ void shouldExtractOperationAndName() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getOperation(dbRequest)).thenReturn("SELECT"); + when(dbAttributesGetter.getOperationName(dbRequest)).thenReturn("SELECT"); when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); @@ -91,7 +91,7 @@ void shouldExtractOperation() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getOperation(dbRequest)).thenReturn("SELECT"); + when(dbAttributesGetter.getOperationName(dbRequest)).thenReturn("SELECT"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); 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 e4c0af52869b..98baacad27bf 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 @@ -33,7 +33,7 @@ public String getRawStatement(Map map) { } @Override - public String getDbQueryText(Map map) { + public String getRawQueryText(Map map) { return map.get("db.query.text"); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 2541265d3fe8..0fe658669608 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -51,7 +51,7 @@ public String getRawStatement(CassandraRequest request) { } @Override - public String getDbQueryText(CassandraRequest request) { + public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index d0307769f17d..bc8dc4cd91af 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -52,7 +52,7 @@ public String getRawStatement(CassandraRequest request) { } @Override - public String getDbQueryText(CassandraRequest request) { + public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 9cc5f468f68b..f44e3c014a36 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -53,7 +53,7 @@ public String getRawStatement(CassandraRequest request) { } @Override - public String getDbQueryText(CassandraRequest request) { + public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } } diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 5572928ce439..4c954d3842db 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -10,6 +10,7 @@ import javax.annotation.Nullable; final class ClickHouseAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Nullable @Override public String getStatement(ClickHouseDbRequest request) { @@ -19,6 +20,16 @@ public String getStatement(ClickHouseDbRequest request) { return request.getSqlStatementInfo().getFullStatement(); } + @Nullable + @Override + public String getDbQueryText(ClickHouseDbRequest request) { + if (request.getSqlStatementInfo() == null) { + return null; + } + return request.getSqlStatementInfo().getFullStatement(); + } + + @Deprecated @Nullable @Override public String getOperation(ClickHouseDbRequest request) { @@ -28,6 +39,15 @@ public String getOperation(ClickHouseDbRequest request) { return request.getSqlStatementInfo().getOperation(); } + @Nullable + @Override + public String getOperationName(ClickHouseDbRequest request) { + if (request.getSqlStatementInfo() == null) { + return null; + } + return request.getSqlStatementInfo().getOperation(); + } + @Nullable @Override public String getSystem(ClickHouseDbRequest request) { diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index e47bbe3fc9c4..13dc3f0ac5e2 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -43,15 +43,29 @@ public String getConnectionString(CouchbaseRequestInfo couchbaseRequest) { return null; } + @Deprecated @Override @Nullable public String getStatement(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.statement(); } + @Nullable + @Override + public String getDbQueryText(CouchbaseRequestInfo couchbaseRequest) { + return couchbaseRequest.statement(); + } + + @Deprecated @Override @Nullable public String getOperation(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.operation(); } + + @Nullable + @Override + public String getOperationName(CouchbaseRequestInfo couchbaseRequest) { + return couchbaseRequest.operation(); + } } 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 1ed361eb76de..05828e26287e 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 @@ -68,6 +68,7 @@ public String getConnectionString(ElasticsearchRestRequest request) { return null; } + @Deprecated @Override @Nullable public String getStatement(ElasticsearchRestRequest request) { @@ -92,10 +93,42 @@ public String getStatement(ElasticsearchRestRequest request) { return null; } + @Nullable + @Override + public String getDbQueryText(ElasticsearchRestRequest request) { + ElasticsearchEndpointDefinition epDefinition = request.getEndpointDefinition(); + HttpEntity httpEntity = request.getHttpEntity(); + if (captureSearchQuery + && epDefinition != null + && epDefinition.isSearchEndpoint() + && httpEntity != null + && httpEntity.isRepeatable()) { + // Retrieve HTTP body for search-type Elasticsearch requests when CAPTURE_SEARCH_QUERY is + // enabled. + try { + return new BufferedReader( + new InputStreamReader(httpEntity.getContent(), StandardCharsets.UTF_8)) + .lines() + .collect(Collectors.joining()); + } catch (IOException e) { + logger.log(FINE, "Failed reading HTTP body content.", e); + } + } + return null; + } + + @Deprecated @Override @Nullable public String getOperation(ElasticsearchRestRequest request) { ElasticsearchEndpointDefinition endpointDefinition = request.getEndpointDefinition(); return endpointDefinition != null ? endpointDefinition.getEndpointName() : null; } + + @Nullable + @Override + public String getOperationName(ElasticsearchRestRequest request) { + ElasticsearchEndpointDefinition endpointDefinition = request.getEndpointDefinition(); + return endpointDefinition != null ? endpointDefinition.getEndpointName() : null; + } } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java index 1faf90ee33e2..c31ecbdea518 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java @@ -21,7 +21,7 @@ public ElasticsearchSpanNameExtractor(ElasticsearchDbAttributesGetter dbAttribut @Override public String extract(ElasticsearchRestRequest elasticsearchRestRequest) { - String name = dbAttributesGetter.getOperation(elasticsearchRestRequest); + String name = dbAttributesGetter.getOperationName(elasticsearchRestRequest); return name != null ? name : elasticsearchRestRequest.getMethod(); } } 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 78625a85cfee..5856829665da 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 @@ -13,45 +13,58 @@ final class ElasticsearchTransportAttributesGetter implements DbClientAttributesGetter { @Override - public String getSystem(ElasticTransportRequest s) { + public String getSystem(ElasticTransportRequest request) { return DbIncubatingAttributes.DbSystemValues.ELASTICSEARCH; } @Deprecated @Override @Nullable - public String getUser(ElasticTransportRequest s) { + public String getUser(ElasticTransportRequest request) { return null; } @Deprecated @Override @Nullable - public String getName(ElasticTransportRequest s) { + public String getName(ElasticTransportRequest request) { return null; } @Nullable @Override - public String getNamespace(ElasticTransportRequest s) { + public String getNamespace(ElasticTransportRequest request) { return null; } @Deprecated @Override @Nullable - public String getConnectionString(ElasticTransportRequest s) { + public String getConnectionString(ElasticTransportRequest request) { return null; } + @Deprecated @Override @Nullable - public String getStatement(ElasticTransportRequest s) { + public String getStatement(ElasticTransportRequest request) { + return null; + } + + @Nullable + @Override + public String getDbQueryText(ElasticTransportRequest request) { return null; } + @Deprecated + @Override + public String getOperation(ElasticTransportRequest request) { + return request.getAction().getClass().getSimpleName(); + } + @Override - public String getOperation(ElasticTransportRequest action) { - return action.getAction().getClass().getSimpleName(); + public String getOperationName(ElasticTransportRequest request) { + return request.getAction().getClass().getSimpleName(); } } diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index 00fdb61779dc..93f3a1209026 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -47,6 +47,7 @@ public String getConnectionString(GeodeRequest request) { return null; } + @Deprecated @Override @Nullable public String getStatement(GeodeRequest request) { @@ -54,9 +55,23 @@ public String getStatement(GeodeRequest request) { return sanitizer.sanitize(request.getQuery()).getFullStatement(); } + @Nullable + @Override + public String getDbQueryText(GeodeRequest request) { + // sanitized statement is cached + return sanitizer.sanitize(request.getQuery()).getFullStatement(); + } + + @Deprecated @Override @Nullable public String getOperation(GeodeRequest request) { return request.getOperation(); } + + @Nullable + @Override + public String getOperationName(GeodeRequest request) { + return request.getOperation(); + } } diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index aea03d43dfdd..1f25477d0c1a 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -10,12 +10,20 @@ final class InfluxDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Nullable @Override public String getStatement(InfluxDbRequest request) { return request.getSqlStatementInfo().getFullStatement(); } + @Nullable + @Override + public String getDbQueryText(InfluxDbRequest request) { + return request.getSqlStatementInfo().getFullStatement(); + } + + @Deprecated @Nullable @Override public String getOperation(InfluxDbRequest request) { @@ -25,6 +33,15 @@ public String getOperation(InfluxDbRequest request) { return request.getSqlStatementInfo().getOperation(); } + @Nullable + @Override + public String getOperationName(InfluxDbRequest request) { + if (request.getOperation() != null) { + return request.getOperation(); + } + return request.getSqlStatementInfo().getOperation(); + } + @Override public String getSystem(InfluxDbRequest request) { return "influxdb"; 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 9019c1ce73b8..b912677c7fa8 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 @@ -58,7 +58,7 @@ public String getRawStatement(DbRequest request) { } @Override - public String getDbQueryText(DbRequest request) { + public String getRawQueryText(DbRequest request) { return request.getDbQueryText(); } } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 012b905ee612..12ac216054a2 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -46,13 +46,26 @@ public String getConnectionString(JedisRequest request) { return null; } + @Deprecated @Override public String getStatement(JedisRequest request) { return sanitizer.sanitize(request.getCommand().name(), request.getArgs()); } + @Nullable + @Override + public String getDbQueryText(JedisRequest request) { + return sanitizer.sanitize(request.getCommand().name(), request.getArgs()); + } + + @Deprecated @Override public String getOperation(JedisRequest request) { return request.getCommand().name(); } + + @Override + public String getOperationName(JedisRequest request) { + return request.getCommand().name(); + } } diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index c068078ea200..58b6d78e91b6 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -41,13 +41,27 @@ public String getConnectionString(JedisRequest request) { return null; } + @Deprecated @Override public String getStatement(JedisRequest request) { return request.getStatement(); } + @Nullable + @Override + public String getDbQueryText(JedisRequest request) { + return request.getStatement(); + } + + @Deprecated @Override public String getOperation(JedisRequest request) { return request.getOperation(); } + + @Nullable + @Override + public String getOperationName(JedisRequest request) { + return request.getOperation(); + } } diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 23a04274d734..2e34c055070b 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -41,13 +41,27 @@ public String getConnectionString(JedisRequest request) { return null; } + @Deprecated @Override public String getStatement(JedisRequest request) { return request.getStatement(); } + @Nullable + @Override + public String getDbQueryText(JedisRequest request) { + return request.getStatement(); + } + + @Deprecated @Override public String getOperation(JedisRequest request) { return request.getOperation(); } + + @Nullable + @Override + public String getOperationName(JedisRequest request) { + return request.getOperation(); + } } diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index 886ed9c268fb..e22a3d46f160 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -44,13 +44,27 @@ public String getConnectionString(RedisCommand request) { return null; } + @Deprecated @Override public String getStatement(RedisCommand request) { return null; } + @Nullable + @Override + public String getDbQueryText(RedisCommand request) { + return null; + } + + @Deprecated @Override public String getOperation(RedisCommand request) { return request.getType().name(); } + + @Nullable + @Override + public String getOperationName(RedisCommand request) { + return request.getType().name(); + } } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 4a11cb470fab..5259b22f7145 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -52,6 +52,7 @@ public String getConnectionString(RedisCommand request) { return null; } + @Deprecated @Override public String getStatement(RedisCommand request) { String command = LettuceInstrumentationUtil.getCommandName(request); @@ -62,8 +63,26 @@ public String getStatement(RedisCommand request) { return sanitizer.sanitize(command, args); } + @Nullable + @Override + public String getDbQueryText(RedisCommand request) { + String command = LettuceInstrumentationUtil.getCommandName(request); + List args = + request.getArgs() == null + ? Collections.emptyList() + : LettuceArgSplitter.splitArgs(request.getArgs().toCommandString()); + return sanitizer.sanitize(command, args); + } + + @Deprecated @Override public String getOperation(RedisCommand request) { return request.getType().name(); } + + @Nullable + @Override + public String getOperationName(RedisCommand request) { + return request.getType().name(); + } } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index ee338228563b..26b7ba2d5a6f 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -93,17 +93,31 @@ public String getConnectionString(CommandStartedEvent event) { return null; } + @Deprecated @Override public String getStatement(CommandStartedEvent event) { return sanitizeStatement(event.getCommand()); } + @Nullable + @Override + public String getDbQueryText(CommandStartedEvent event) { + return sanitizeStatement(event.getCommand()); + } + + @Deprecated @Override @Nullable public String getOperation(CommandStartedEvent event) { return event.getCommandName(); } + @Nullable + @Override + public String getOperationName(CommandStartedEvent event) { + return event.getCommandName(); + } + String sanitizeStatement(BsonDocument command) { StringBuilderWriter stringWriter = new StringBuilderWriter(128); // jsonWriterSettings is generally not null but could be due to security manager or unknown diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java index 464fbcaca66d..7aa302e71e6d 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java @@ -22,7 +22,7 @@ class MongoSpanNameExtractor implements SpanNameExtractor { @Override public String extract(CommandStartedEvent event) { - String operation = dbAttributesGetter.getOperation(event); + String operation = dbAttributesGetter.getOperationName(event); String dbName = dbAttributesGetter.getNamespace(event); if (operation == null) { return dbName == null ? DEFAULT_SPAN_NAME : dbName; 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 59ee5ad62758..111f97dac84f 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 @@ -42,15 +42,27 @@ public String getConnectionString(OpenSearchRestRequest request) { return null; } + @Deprecated @Override - @Nullable public String getStatement(OpenSearchRestRequest request) { return request.getMethod() + " " + request.getOperation(); } + @Override + public String getDbQueryText(OpenSearchRestRequest request) { + return request.getMethod() + " " + request.getOperation(); + } + + @Deprecated @Override @Nullable public String getOperation(OpenSearchRestRequest request) { return request.getMethod(); } + + @Nullable + @Override + public String getOperationName(OpenSearchRestRequest request) { + return request.getMethod(); + } } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index aa3af0e8d4b0..df1ac4b57a72 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -53,7 +53,7 @@ public String getRawStatement(DbExecution request) { } @Override - public String getDbQueryText(DbExecution request) { + public String getRawQueryText(DbExecution request) { return request.getDbQueryText(); } } diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index 664d94780752..abbbe91c26fc 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -50,8 +50,20 @@ public String getStatement(RedisCommand redisCommand) { return null; } + @Nullable + @Override + public String getDbQueryText(RedisCommand redisCommand) { + return null; + } + + @Deprecated @Override public String getOperation(RedisCommand redisCommand) { return redisCommand.getClass().getSimpleName().toUpperCase(Locale.ROOT); } + + @Override + public String getOperationName(RedisCommand redisCommand) { + return redisCommand.getClass().getSimpleName().toUpperCase(Locale.ROOT); + } } diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index 841c3cdf251e..d86f02e926d0 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -40,14 +40,27 @@ public String getConnectionString(RedissonRequest request) { return null; } + @Deprecated @Override public String getStatement(RedissonRequest request) { return request.getStatement(); } + @Override + public String getDbQueryText(RedissonRequest request) { + return request.getStatement(); + } + + @Deprecated @Nullable @Override public String getOperation(RedissonRequest request) { return request.getOperation(); } + + @Nullable + @Override + public String getOperationName(RedissonRequest request) { + return request.getOperation(); + } } 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 97a89ef41182..ab04a6a97da8 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 @@ -40,15 +40,29 @@ public String getConnectionString(SpymemcachedRequest spymemcachedRequest) { return null; } + @Deprecated @Override @Nullable public String getStatement(SpymemcachedRequest spymemcachedRequest) { return null; } + @Nullable + @Override + public String getDbQueryText(SpymemcachedRequest spymemcachedRequest) { + return null; + } + + @Deprecated @Override @Nullable public String getOperation(SpymemcachedRequest spymemcachedRequest) { return spymemcachedRequest.dbOperation(); } + + @Nullable + @Override + public String getOperationName(SpymemcachedRequest spymemcachedRequest) { + return spymemcachedRequest.dbOperation(); + } } 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 936ae1e2a35f..9edf66df229b 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 @@ -50,7 +50,7 @@ public String getRawStatement(VertxSqlClientRequest request) { } @Override - public String getDbQueryText(VertxSqlClientRequest request) { + public String getRawQueryText(VertxSqlClientRequest request) { return request.getDbQueryText(); } } From d563d8ef3fcbce1205fee0d61c65d2f75b262011 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 11:34:56 -0700 Subject: [PATCH 33/93] Revert --- .../semconv/rpc/RpcMetricsAdvice.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java index 87c149a5f8fd..0a24cca3f39c 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/rpc/RpcMetricsAdvice.java @@ -8,12 +8,9 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.incubator.metrics.ExtendedDoubleHistogramBuilder; import io.opentelemetry.api.metrics.DoubleHistogramBuilder; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; final class RpcMetricsAdvice { @@ -21,30 +18,23 @@ final class RpcMetricsAdvice { private static final AttributeKey RPC_GRPC_STATUS_CODE = AttributeKey.longKey("rpc.grpc.status_code"); - private static final List> attributesAdvice = new ArrayList<>(); - - static { - attributesAdvice.addAll( - Arrays.asList( - RpcCommonAttributesExtractor.RPC_SYSTEM, - RpcCommonAttributesExtractor.RPC_SERVICE, - RpcCommonAttributesExtractor.RPC_METHOD, - RPC_GRPC_STATUS_CODE, - ServerAttributes.SERVER_ADDRESS, - ServerAttributes.SERVER_PORT)); - if (SemconvStability.emitOldDatabaseSemconv()) { - attributesAdvice.add(NetworkAttributes.NETWORK_TYPE); - attributesAdvice.add(NetworkAttributes.NETWORK_TRANSPORT); - } - } - static void applyClientDurationAdvice(DoubleHistogramBuilder builder) { if (!(builder instanceof ExtendedDoubleHistogramBuilder)) { return; } // the list of recommended metrics attributes is from // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md - ((ExtendedDoubleHistogramBuilder) builder).setAttributesAdvice(attributesAdvice); + ((ExtendedDoubleHistogramBuilder) builder) + .setAttributesAdvice( + Arrays.asList( + RpcCommonAttributesExtractor.RPC_SYSTEM, + RpcCommonAttributesExtractor.RPC_SERVICE, + RpcCommonAttributesExtractor.RPC_METHOD, + RPC_GRPC_STATUS_CODE, + NetworkAttributes.NETWORK_TYPE, + NetworkAttributes.NETWORK_TRANSPORT, + ServerAttributes.SERVER_ADDRESS, + ServerAttributes.SERVER_PORT)); } static void applyServerDurationAdvice(DoubleHistogramBuilder builder) { @@ -53,7 +43,17 @@ static void applyServerDurationAdvice(DoubleHistogramBuilder builder) { } // the list of recommended metrics attributes is from // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md - ((ExtendedDoubleHistogramBuilder) builder).setAttributesAdvice(attributesAdvice); + ((ExtendedDoubleHistogramBuilder) builder) + .setAttributesAdvice( + Arrays.asList( + RpcCommonAttributesExtractor.RPC_SYSTEM, + RpcCommonAttributesExtractor.RPC_SERVICE, + RpcCommonAttributesExtractor.RPC_METHOD, + RPC_GRPC_STATUS_CODE, + NetworkAttributes.NETWORK_TYPE, + NetworkAttributes.NETWORK_TRANSPORT, + ServerAttributes.SERVER_ADDRESS, + ServerAttributes.SERVER_PORT)); } private RpcMetricsAdvice() {} From 5595a6f5934283d6fae8f6e62ad581f025fb29e6 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 11:40:04 -0700 Subject: [PATCH 34/93] Remove supressionWarning --- .../semconv/db/SqlClientAttributesExtractor.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 80674d3488c0..3d47de17ad79 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -65,29 +65,25 @@ public static SqlClientAttributesExtractorBuilder Date: Mon, 9 Sep 2024 16:11:11 -0700 Subject: [PATCH 35/93] Fix --- .../db/DbClientAttributesExtractor.java | 5 ++-- .../semconv/db/DbClientAttributesGetter.java | 6 +++-- .../db/DbClientAttributesExtractorTest.java | 23 +++++++++++++++---- .../db/SqlClientAttributesExtractorTest.java | 2 ++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index 94337f6f97d8..e156124eee2c 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -43,6 +43,7 @@ public static AttributesExtractor create( super(getter); } + @SuppressWarnings("deprecation") // until old db semconv are dropped @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { super.onStart(attributes, parentContext, request); @@ -52,8 +53,8 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST internalSet(attributes, DB_OPERATION_NAME, getter.getOperationName(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, DB_STATEMENT, getter.getDbQueryText(request)); - internalSet(attributes, DB_OPERATION, getter.getOperationName(request)); + internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); + internalSet(attributes, DB_OPERATION, getter.getOperation(request)); } } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 0a506c0cc995..143f3a5876d0 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -21,8 +21,9 @@ public interface DbClientAttributesGetter extends DbClientCommonAttributesGetter { /** - * @deprecated Use {@link #getDbQueyText(Object)} instead. + * @deprecated Use {@link #getDbQueryText(REQUEST)} instead. */ + @Deprecated @Nullable String getStatement(REQUEST request); @@ -30,8 +31,9 @@ public interface DbClientAttributesGetter extends DbClientCommonAttribu String getDbQueryText(REQUEST request); /** - * @deprecated Use {@link #getOperationName(Object)} instead. + * @deprecated Use {@link #getOperationName(REQUEST)} instead. */ + @Deprecated @Nullable String getOperation(REQUEST request); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index a9b4ff2ba887..9468d2ee5ab2 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -29,6 +29,7 @@ public String getSystem(Map map) { return map.get("db.system"); } + @Deprecated @Override public String getUser(Map map) { return map.get("db.user"); @@ -46,23 +47,35 @@ public String getNamespace(Map map) { return map.get("db.namespace"); } + @Deprecated @Override public String getConnectionString(Map map) { return map.get("db.connection_string"); } + @Deprecated @Override public String getStatement(Map map) { return map.get("db.statement"); } + @Nullable + @Override + public String getDbQueryText(Map map) { + return map.get("db.query.text"); + } + + @Deprecated @Override public String getOperation(Map map) { - if (SemconvStability.emitStableDatabaseSemconv()) { - return map.get("db.operation.name"); - } return map.get("db.operation"); } + + @Nullable + @Override + public String getOperationName(Map map) { + return map.get("db.operation.name"); + } } @SuppressWarnings("deprecation") // TODO DbIncubatingAttributes.DB_CONNECTION_STRING deprecation @@ -71,7 +84,9 @@ void shouldExtractAllAvailableAttributes() { // given Map request = new HashMap<>(); request.put("db.system", "myDb"); - request.put("db.user", "username"); + if (SemconvStability.emitOldDatabaseSemconv()) { + request.put("db.user", "username"); + } request.put( SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME).getKey(), "potatoes"); request.put("db.connection_string", "mydb:///potatoes"); 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 98baacad27bf..9b2354a9c68f 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 @@ -42,6 +42,7 @@ public String getSystem(Map map) { return map.get("db.system"); } + @Deprecated @Override public String getUser(Map map) { return map.get("db.user"); @@ -60,6 +61,7 @@ public String getNamespace(Map map) { return map.get("db.namespace"); } + @Deprecated @Override public String getConnectionString(Map map) { return map.get("db.connection_string"); From f30ff360557def3360e770c6b9afedfdf262b69e Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 17:16:53 -0700 Subject: [PATCH 36/93] Fix --- .../db/SqlClientAttributesExtractor.java | 15 ++- .../db/DbClientAttributesExtractorTest.java | 2 +- .../db/SqlClientAttributesExtractorTest.java | 110 ++++++++++++------ 3 files changed, 82 insertions(+), 45 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 3d47de17ad79..7e26faf850d5 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -65,25 +65,28 @@ public static SqlClientAttributesExtractorBuilder request = new HashMap<>(); request.put("db.system", "myDb"); - request.put("db.user", "username"); - request.put("db.connection_string", "mydb:///potatoes"); if (SemconvStability.emitOldDatabaseSemconv()) { + request.put("db.user", "username"); + request.put("db.connection_string", "mydb:///potatoes"); request.put("db.name", "potatoes"); request.put("db.statement", "SELECT * FROM potato WHERE id=12345"); } else if (SemconvStability.emitStableDatabaseSemconv()) { @@ -97,21 +97,32 @@ void shouldExtractAllAttributes() { underTest.onEnd(endAttributes, context, request, null, null); // then - assertThat(startAttributes.build()) - .containsOnly( - entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), - entry(DbIncubatingAttributes.DB_USER, "username"), - entry(SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), - entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM potato WHERE id=?"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_SQL_TABLE), - "potato")); + if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry(DbIncubatingAttributes.DB_USER, "username"), + entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(DbIncubatingAttributes.DB_SQL_TABLE, "potato")); + } else { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM potato WHERE id=?"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_SQL_TABLE), + "potato")); + } assertThat(endAttributes.build().isEmpty()).isTrue(); } @@ -120,7 +131,11 @@ void shouldExtractAllAttributes() { void shouldNotExtractTableIfAttributeIsNotSet() { // given Map request = new HashMap<>(); - request.put("db.statement", "SELECT *"); + if (SemconvStability.emitOldDatabaseSemconv()) { + request.put("db.statement", "SELECT *"); + } else { + request.put("db.query.text", "SELECT *"); + } Context context = Context.root(); @@ -132,21 +147,32 @@ void shouldNotExtractTableIfAttributeIsNotSet() { underTest.onStart(attributes, context, request); // then - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT *"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT")); + if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); + } else { + assertThat(attributes.build()) + .containsOnly( + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT *"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT")); + } } @Test void shouldExtractTableToSpecifiedKey() { // given Map request = new HashMap<>(); - request.put("db.statement", "SELECT * FROM table"); + if (SemconvStability.emitOldDatabaseSemconv()) { + request.put("db.statement", "SELECT * FROM table"); + } else { + request.put("db.query.text", "SELECT * FROM table"); + } Context context = Context.root(); @@ -161,17 +187,25 @@ void shouldExtractTableToSpecifiedKey() { underTest.onStart(attributes, context, request); // then - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM table"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), - "table")); + if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table")); + } else { + assertThat(attributes.build()) + .containsOnly( + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM table"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), + "table")); + } } @Test From 39694d491da80679717fee149d2696a71b1e904f Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 17:24:05 -0700 Subject: [PATCH 37/93] Fix deprecation --- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index df1ac4b57a72..2ec717eb9066 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -20,6 +20,7 @@ public String getSystem(DbExecution request) { return request.getSystem(); } + @Deprecated @Override @Nullable public String getUser(DbExecution request) { @@ -39,6 +40,7 @@ public String getNamespace(DbExecution request) { return request.getName(); } + @Deprecated @Override @Nullable public String getConnectionString(DbExecution request) { From 463795f2e52ef18f3ee206608f54b8cc5ecfeb40 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 9 Sep 2024 17:25:28 -0700 Subject: [PATCH 38/93] Fix --- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 2 ++ 1 file changed, 2 insertions(+) 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 9edf66df229b..4aba3083b5e7 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 @@ -17,6 +17,7 @@ public String getSystem(VertxSqlClientRequest request) { return null; } + @Deprecated @Override @Nullable public String getUser(VertxSqlClientRequest request) { @@ -36,6 +37,7 @@ public String getNamespace(VertxSqlClientRequest request) { return request.getDatabase(); } + @Deprecated @Override @Nullable public String getConnectionString(VertxSqlClientRequest request) { From b9734027bf1aa16cec6c87c33e82efd6c7474acd Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 10 Sep 2024 09:29:02 -0700 Subject: [PATCH 39/93] Fix --- .../opensearch/rest/OpenSearchRestAttributesGetter.java | 2 ++ .../instrumentation/rediscala/RediscalaAttributesGetter.java | 2 ++ .../instrumentation/redisson/RedissonDbAttributesGetter.java | 2 ++ 3 files changed, 6 insertions(+) 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 111f97dac84f..a369553af6fd 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 @@ -17,6 +17,7 @@ public String getSystem(OpenSearchRestRequest request) { return DbIncubatingAttributes.DbSystemValues.OPENSEARCH; } + @Deprecated @Override @Nullable public String getUser(OpenSearchRestRequest request) { @@ -36,6 +37,7 @@ public String getNamespace(OpenSearchRestRequest openSearchRestRequest) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(OpenSearchRestRequest request) { diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index abbbe91c26fc..74a9354d7092 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -18,6 +18,7 @@ public String getSystem(RedisCommand redisCommand) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(RedisCommand redisCommand) { @@ -37,6 +38,7 @@ public String getNamespace(RedisCommand redisCommand) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(RedisCommand redisCommand) { diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index d86f02e926d0..7dfa05a967ab 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -16,6 +16,7 @@ public String getSystem(RedissonRequest request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Nullable @Override public String getUser(RedissonRequest request) { @@ -35,6 +36,7 @@ public String getNamespace(RedissonRequest request) { return null; } + @Deprecated @Override public String getConnectionString(RedissonRequest request) { return null; From e4b92358d588ba3abb180fac1d6e993951652368 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 10 Sep 2024 09:46:42 -0700 Subject: [PATCH 40/93] Fix --- .../SpymemcachedAttributesGetter.java | 2 ++ .../redis/VertxRedisClientAttributesGetter.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) 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 ab04a6a97da8..14d71bef4105 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 @@ -15,6 +15,7 @@ public String getSystem(SpymemcachedRequest spymemcachedRequest) { return "memcached"; } + @Deprecated @Override @Nullable public String getUser(SpymemcachedRequest spymemcachedRequest) { @@ -34,6 +35,7 @@ public String getNamespace(SpymemcachedRequest spymemcachedRequest) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(SpymemcachedRequest spymemcachedRequest) { diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 1d4c9f28f6e5..bc9aab772948 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -23,6 +23,7 @@ public String getSystem(VertxRedisClientRequest request) { return DbIncubatingAttributes.DbSystemValues.REDIS; } + @Deprecated @Override @Nullable public String getUser(VertxRedisClientRequest request) { @@ -42,20 +43,35 @@ public String getNamespace(VertxRedisClientRequest request) { return null; } + @Deprecated @Override @Nullable public String getConnectionString(VertxRedisClientRequest request) { return request.getConnectionString(); } + @Deprecated @Override public String getStatement(VertxRedisClientRequest request) { return sanitizer.sanitize(request.getCommand(), request.getArgs()); } + @Nullable + @Override + public String getDbQueryText(VertxRedisClientRequest request) { + return sanitizer.sanitize(request.getCommand(), request.getArgs()); + } + + @Deprecated @Nullable @Override public String getOperation(VertxRedisClientRequest request) { return request.getCommand(); } + + @Nullable + @Override + public String getOperationName(VertxRedisClientRequest request) { + return request.getCommand(); + } } From 7a99334aa8e7108e83ddadb74a0e49c1b5122818 Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 13 Sep 2024 15:02:28 -0700 Subject: [PATCH 41/93] Fix couchbase tests --- .../couchbase/AbstractCouchbaseClientTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java index d0ea69c2cc37..7732ed2ad83b 100644 --- a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java +++ b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java @@ -19,9 +19,11 @@ import com.couchbase.client.java.query.N1qlQuery; import com.couchbase.client.java.query.N1qlQueryResult; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.concurrent.atomic.AtomicReference; @@ -108,7 +110,12 @@ void upsertAndGet(BucketSettings bucketSettings) { equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket"))), + equalTo( + SemconvStability.emitStableDatabaseSemconv() + ? SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION) + : DbIncubatingAttributes.DB_OPERATION, + "Cluster.openBucket"))), trace -> trace.hasSpansSatisfyingExactly( span -> span.hasName("someTrace").hasKind(SpanKind.INTERNAL).hasNoParent(), @@ -144,7 +151,12 @@ void query() { equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket"))), + equalTo( + SemconvStability.emitStableDatabaseSemconv() + ? SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION) + : DbIncubatingAttributes.DB_OPERATION, + "Cluster.openBucket"))), trace -> trace.hasSpansSatisfyingExactly( span -> From 65ea5fb56541e1707e565a5bec9b62bc41f8d7ed Mon Sep 17 00:00:00 2001 From: heyams Date: Fri, 13 Sep 2024 15:11:54 -0700 Subject: [PATCH 42/93] Fix --- .../couchbase/AbstractCouchbaseClientTest.java | 13 ++++--------- .../couchbase/AbstractCouchbaseTest.java | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java index 7732ed2ad83b..f632683d9b63 100644 --- a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java +++ b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseClientTest.java @@ -19,7 +19,6 @@ import com.couchbase.client.java.query.N1qlQuery; import com.couchbase.client.java.query.N1qlQueryResult; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; @@ -111,10 +110,8 @@ void upsertAndGet(BucketSettings bucketSettings) { DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), equalTo( - SemconvStability.emitStableDatabaseSemconv() - ? SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_OPERATION) - : DbIncubatingAttributes.DB_OPERATION, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), "Cluster.openBucket"))), trace -> trace.hasSpansSatisfyingExactly( @@ -152,10 +149,8 @@ void query() { DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), equalTo( - SemconvStability.emitStableDatabaseSemconv() - ? SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_OPERATION) - : DbIncubatingAttributes.DB_OPERATION, + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), "Cluster.openBucket"))), trace -> trace.hasSpansSatisfyingExactly( diff --git a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseTest.java b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseTest.java index 406456ed4ef4..95cb500d8581 100644 --- a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseTest.java +++ b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseTest.java @@ -19,6 +19,7 @@ import com.couchbase.mock.httpio.HttpServer; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.test.utils.PortUtils; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.sdk.testing.assertj.SpanDataAssert; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -122,13 +123,21 @@ protected SpanDataAssert assertCouchbaseSpan( assertions.add( equalTo(DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE)); if (operation != null) { - assertions.add(equalTo(DbIncubatingAttributes.DB_OPERATION, operation)); + assertions.add( + equalTo( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + operation)); } if (bucketName != null) { - assertions.add(equalTo(DbIncubatingAttributes.DB_NAME, bucketName)); + assertions.add( + equalTo( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), bucketName)); } if (statement != null) { - assertions.add(satisfies(DbIncubatingAttributes.DB_STATEMENT, s -> s.startsWith(statement))); + assertions.add( + satisfies( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + s -> s.startsWith(statement))); } assertions.addAll(couchbaseAttributes()); From c7ec850a36178c5e7392f3586cb276e8360d620c Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 16 Sep 2024 11:44:47 -0700 Subject: [PATCH 43/93] Fix --- .../AbstractCouchbaseAsyncClientTest.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseAsyncClientTest.java b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseAsyncClientTest.java index fe917fa613ce..b84f3f78b4d4 100644 --- a/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseAsyncClientTest.java +++ b/instrumentation/couchbase/couchbase-common/testing/src/main/java/io/opentelemetry/instrumentation/couchbase/AbstractCouchbaseAsyncClientTest.java @@ -21,6 +21,7 @@ import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.concurrent.CompletableFuture; @@ -89,7 +90,10 @@ void hasBucket(BucketSettings bucketSettings) equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket")), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "Cluster.openBucket")), span -> assertCouchbaseSpan(span, "ClusterManager.hasBucket") .hasParent(trace.getSpan(0)))); @@ -130,7 +134,10 @@ void upsert(BucketSettings bucketSettings) equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket")), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "Cluster.openBucket")), span -> assertCouchbaseSpan(span, "Bucket.upsert", bucketSettings.name()) .hasParent(trace.getSpan(1)))); @@ -178,7 +185,10 @@ void upsertAndGet(BucketSettings bucketSettings) equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket")), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "Cluster.openBucket")), span -> assertCouchbaseSpan(span, "Bucket.upsert", bucketSettings.name()) .hasParent(trace.getSpan(1)), @@ -223,7 +233,10 @@ void query() throws ExecutionException, InterruptedException, TimeoutException { equalTo( DbIncubatingAttributes.DB_SYSTEM, DbIncubatingAttributes.DbSystemValues.COUCHBASE), - equalTo(DbIncubatingAttributes.DB_OPERATION, "Cluster.openBucket")), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "Cluster.openBucket")), span -> assertCouchbaseSpan( span, From 7553f8efd8062fc4f7b94d00a8a4aabad974403e Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 16 Sep 2024 14:49:56 -0700 Subject: [PATCH 44/93] Fix --- .../couchbase/v2_6/Couchbase26Util.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java b/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java index f884a4857eeb..dceaf99a199e 100644 --- a/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java +++ b/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java @@ -14,6 +14,7 @@ import com.couchbase.client.java.cluster.BucketSettings; import com.couchbase.client.java.env.DefaultCouchbaseEnvironment; import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.semconv.NetworkAttributes; import java.util.Arrays; @@ -47,14 +48,28 @@ public static DefaultCouchbaseEnvironment.Builder envBuilder( } public static List couchbaseAttributes() { - return Arrays.asList( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), - satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.local.address"), val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.operation_id"), val -> assertThat(val).isNotNull())); + if (SemconvStability.emitStableDatabaseSemconv()) { + return Arrays.asList( + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), + satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.local.address"), + val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.operation_id"), + val -> assertThat(val).isNotNull())); + } else { + return Arrays.asList( + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), + satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.local.address"), + val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.operation_id"), + val -> assertThat(val).isNotNull())); + } } private Couchbase26Util() {} From e743724eb198f246b93936a216fd4856bc7badbe Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 17 Sep 2024 16:17:43 -0700 Subject: [PATCH 45/93] Rename getOperationName to getDbOperationName --- .../api/incubator/semconv/db/DbClientAttributesExtractor.java | 2 +- .../api/incubator/semconv/db/DbClientAttributesGetter.java | 4 ++-- .../api/incubator/semconv/db/DbClientSpanNameExtractor.java | 4 ++-- .../incubator/semconv/db/DbClientAttributesExtractorTest.java | 2 +- .../incubator/semconv/db/DbClientSpanNameExtractorTest.java | 4 ++-- .../clickhouse/ClickHouseAttributesGetter.java | 2 +- .../couchbase/v2_0/CouchbaseAttributesGetter.java | 2 +- .../rest/internal/ElasticsearchDbAttributesGetter.java | 2 +- .../rest/internal/ElasticsearchSpanNameExtractor.java | 2 +- .../transport/ElasticsearchTransportAttributesGetter.java | 2 +- .../instrumentation/geode/GeodeDbAttributesGetter.java | 2 +- .../influxdb/v2_4/InfluxDbAttributesGetter.java | 2 +- .../instrumentation/jedis/v1_4/JedisDbAttributesGetter.java | 2 +- .../instrumentation/jedis/v3_0/JedisDbAttributesGetter.java | 2 +- .../instrumentation/jedis/v4_0/JedisDbAttributesGetter.java | 2 +- .../lettuce/v4_0/LettuceDbAttributesGetter.java | 2 +- .../lettuce/v5_0/LettuceDbAttributesGetter.java | 2 +- .../instrumentation/mongo/v3_1/MongoDbAttributesGetter.java | 2 +- .../instrumentation/mongo/v3_1/MongoSpanNameExtractor.java | 2 +- .../opensearch/rest/OpenSearchRestAttributesGetter.java | 2 +- .../instrumentation/rediscala/RediscalaAttributesGetter.java | 2 +- .../instrumentation/redisson/RedissonDbAttributesGetter.java | 2 +- .../spymemcached/SpymemcachedAttributesGetter.java | 2 +- .../vertx/v4_0/redis/VertxRedisClientAttributesGetter.java | 2 +- 24 files changed, 27 insertions(+), 27 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index e156124eee2c..84fb64756f5f 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -50,7 +50,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST if (SemconvStability.emitStableDatabaseSemconv()) { internalSet(attributes, DB_QUERY_TEXT, getter.getDbQueryText(request)); - internalSet(attributes, DB_OPERATION_NAME, getter.getOperationName(request)); + internalSet(attributes, DB_OPERATION_NAME, getter.getDbOperationName(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 143f3a5876d0..314ac94ff243 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -31,12 +31,12 @@ public interface DbClientAttributesGetter extends DbClientCommonAttribu String getDbQueryText(REQUEST request); /** - * @deprecated Use {@link #getOperationName(REQUEST)} instead. + * @deprecated Use {@link #getDbOperationName(REQUEST)} instead. */ @Deprecated @Nullable String getOperation(REQUEST request); @Nullable - String getOperationName(REQUEST request); + String getDbOperationName(REQUEST request); } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index 879e5a0af1bb..d4c891375606 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -13,7 +13,7 @@ public abstract class DbClientSpanNameExtractor implements SpanNameExtr * Returns a {@link SpanNameExtractor} that constructs the span name according to DB semantic * conventions: {@code }. * - * @see DbClientAttributesGetter#getOperationName(Object) used to extract {@code + * @see DbClientAttributesGetter#getDbOperationName(Object) used to extract {@code * }. * @see DbClientAttributesGetter#getNamespace(Object) used to extract {@code }. */ @@ -74,7 +74,7 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter gette @Override public String extract(REQUEST request) { String dbName = getter.getNamespace(request); - String operation = getter.getOperationName(request); + String operation = getter.getDbOperationName(request); return computeSpanName(dbName, operation, null); } } diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index fad5a7b008df..aeac442e4a38 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -73,7 +73,7 @@ public String getOperation(Map map) { @Nullable @Override - public String getOperationName(Map map) { + public String getDbOperationName(Map map) { return map.get("db.operation.name"); } } 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 e91fc7b6ff7d..9fb306fd7850 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 @@ -74,7 +74,7 @@ void shouldExtractOperationAndName() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getOperationName(dbRequest)).thenReturn("SELECT"); + when(dbAttributesGetter.getDbOperationName(dbRequest)).thenReturn("SELECT"); when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); @@ -91,7 +91,7 @@ void shouldExtractOperation() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getOperationName(dbRequest)).thenReturn("SELECT"); + when(dbAttributesGetter.getDbOperationName(dbRequest)).thenReturn("SELECT"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 4c954d3842db..18097225e18e 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -41,7 +41,7 @@ public String getOperation(ClickHouseDbRequest request) { @Nullable @Override - public String getOperationName(ClickHouseDbRequest request) { + public String getDbOperationName(ClickHouseDbRequest request) { if (request.getSqlStatementInfo() == null) { return null; } diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index 13dc3f0ac5e2..d93bcdec1d25 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -65,7 +65,7 @@ public String getOperation(CouchbaseRequestInfo couchbaseRequest) { @Nullable @Override - public String getOperationName(CouchbaseRequestInfo couchbaseRequest) { + public String getDbOperationName(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.operation(); } } 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 05828e26287e..64416a751cd2 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 @@ -127,7 +127,7 @@ public String getOperation(ElasticsearchRestRequest request) { @Nullable @Override - public String getOperationName(ElasticsearchRestRequest request) { + public String getDbOperationName(ElasticsearchRestRequest request) { ElasticsearchEndpointDefinition endpointDefinition = request.getEndpointDefinition(); return endpointDefinition != null ? endpointDefinition.getEndpointName() : null; } diff --git a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java index c31ecbdea518..1fd48256c8d5 100644 --- a/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java +++ b/instrumentation/elasticsearch/elasticsearch-rest-common/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/internal/ElasticsearchSpanNameExtractor.java @@ -21,7 +21,7 @@ public ElasticsearchSpanNameExtractor(ElasticsearchDbAttributesGetter dbAttribut @Override public String extract(ElasticsearchRestRequest elasticsearchRestRequest) { - String name = dbAttributesGetter.getOperationName(elasticsearchRestRequest); + String name = dbAttributesGetter.getDbOperationName(elasticsearchRestRequest); return name != null ? name : elasticsearchRestRequest.getMethod(); } } 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 5856829665da..7a18b47acc4a 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 @@ -64,7 +64,7 @@ public String getOperation(ElasticTransportRequest request) { } @Override - public String getOperationName(ElasticTransportRequest request) { + public String getDbOperationName(ElasticTransportRequest request) { return request.getAction().getClass().getSimpleName(); } } diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index 93f3a1209026..af7a7d4c8eed 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -71,7 +71,7 @@ public String getOperation(GeodeRequest request) { @Nullable @Override - public String getOperationName(GeodeRequest request) { + public String getDbOperationName(GeodeRequest request) { return request.getOperation(); } } diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index 1f25477d0c1a..aa53f938d682 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -35,7 +35,7 @@ public String getOperation(InfluxDbRequest request) { @Nullable @Override - public String getOperationName(InfluxDbRequest request) { + public String getDbOperationName(InfluxDbRequest request) { if (request.getOperation() != null) { return request.getOperation(); } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 12ac216054a2..ec724e0a2498 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -65,7 +65,7 @@ public String getOperation(JedisRequest request) { } @Override - public String getOperationName(JedisRequest request) { + public String getDbOperationName(JedisRequest request) { return request.getCommand().name(); } } diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index 58b6d78e91b6..eb95e1d180cc 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -61,7 +61,7 @@ public String getOperation(JedisRequest request) { @Nullable @Override - public String getOperationName(JedisRequest request) { + public String getDbOperationName(JedisRequest request) { return request.getOperation(); } } diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 2e34c055070b..40656aaac0c8 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -61,7 +61,7 @@ public String getOperation(JedisRequest request) { @Nullable @Override - public String getOperationName(JedisRequest request) { + public String getDbOperationName(JedisRequest request) { return request.getOperation(); } } diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index e22a3d46f160..ed9139eca1f3 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -64,7 +64,7 @@ public String getOperation(RedisCommand request) { @Nullable @Override - public String getOperationName(RedisCommand request) { + public String getDbOperationName(RedisCommand request) { return request.getType().name(); } } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 5259b22f7145..20f8f2ebd513 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -82,7 +82,7 @@ public String getOperation(RedisCommand request) { @Nullable @Override - public String getOperationName(RedisCommand request) { + public String getDbOperationName(RedisCommand request) { return request.getType().name(); } } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 26b7ba2d5a6f..4f8ca5e88d08 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -114,7 +114,7 @@ public String getOperation(CommandStartedEvent event) { @Nullable @Override - public String getOperationName(CommandStartedEvent event) { + public String getDbOperationName(CommandStartedEvent event) { return event.getCommandName(); } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java index 7aa302e71e6d..455ea77198f6 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java @@ -22,7 +22,7 @@ class MongoSpanNameExtractor implements SpanNameExtractor { @Override public String extract(CommandStartedEvent event) { - String operation = dbAttributesGetter.getOperationName(event); + String operation = dbAttributesGetter.getDbOperationName(event); String dbName = dbAttributesGetter.getNamespace(event); if (operation == null) { return dbName == null ? DEFAULT_SPAN_NAME : dbName; 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 a369553af6fd..4252bf1ab954 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 @@ -64,7 +64,7 @@ public String getOperation(OpenSearchRestRequest request) { @Nullable @Override - public String getOperationName(OpenSearchRestRequest request) { + public String getDbOperationName(OpenSearchRestRequest request) { return request.getMethod(); } } diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index 74a9354d7092..f5580709f33a 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -65,7 +65,7 @@ public String getOperation(RedisCommand redisCommand) { } @Override - public String getOperationName(RedisCommand redisCommand) { + public String getDbOperationName(RedisCommand redisCommand) { return redisCommand.getClass().getSimpleName().toUpperCase(Locale.ROOT); } } diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index 7dfa05a967ab..a1c0321be51b 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -62,7 +62,7 @@ public String getOperation(RedissonRequest request) { @Nullable @Override - public String getOperationName(RedissonRequest request) { + public String getDbOperationName(RedissonRequest request) { return request.getOperation(); } } 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 14d71bef4105..4f4444e2cbee 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 @@ -64,7 +64,7 @@ public String getOperation(SpymemcachedRequest spymemcachedRequest) { @Nullable @Override - public String getOperationName(SpymemcachedRequest spymemcachedRequest) { + public String getDbOperationName(SpymemcachedRequest spymemcachedRequest) { return spymemcachedRequest.dbOperation(); } } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index bc9aab772948..761bdbfa6eaf 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -71,7 +71,7 @@ public String getOperation(VertxRedisClientRequest request) { @Nullable @Override - public String getOperationName(VertxRedisClientRequest request) { + public String getDbOperationName(VertxRedisClientRequest request) { return request.getCommand(); } } From 59abf3612be9975736d52546564b9c214cfec605 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 17 Sep 2024 16:18:56 -0700 Subject: [PATCH 46/93] Rename getNamespace to getDbNamespace --- .../semconv/db/DbClientCommonAttributesExtractor.java | 2 +- .../semconv/db/DbClientCommonAttributesGetter.java | 4 ++-- .../incubator/semconv/db/DbClientSpanNameExtractor.java | 8 ++++---- .../semconv/db/DbClientAttributesExtractorTest.java | 2 +- .../semconv/db/DbClientSpanNameExtractorTest.java | 8 ++++---- .../semconv/db/SqlClientAttributesExtractorTest.java | 2 +- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 +- .../clickhouse/ClickHouseAttributesGetter.java | 2 +- .../couchbase/v2_0/CouchbaseAttributesGetter.java | 2 +- .../rest/internal/ElasticsearchDbAttributesGetter.java | 2 +- .../transport/ElasticsearchTransportAttributesGetter.java | 2 +- .../instrumentation/geode/GeodeDbAttributesGetter.java | 2 +- .../influxdb/v2_4/InfluxDbAttributesGetter.java | 2 +- .../jdbc/internal/JdbcAttributesGetter.java | 2 +- .../jedis/v1_4/JedisDbAttributesGetter.java | 2 +- .../jedis/v3_0/JedisDbAttributesGetter.java | 2 +- .../jedis/v4_0/JedisDbAttributesGetter.java | 2 +- .../lettuce/v4_0/LettuceDbAttributesGetter.java | 2 +- .../lettuce/v5_0/LettuceDbAttributesGetter.java | 2 +- .../mongo/v3_1/MongoDbAttributesGetter.java | 2 +- .../mongo/v3_1/MongoSpanNameExtractor.java | 2 +- .../opensearch/rest/OpenSearchRestAttributesGetter.java | 2 +- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 +- .../rediscala/RediscalaAttributesGetter.java | 2 +- .../redisson/RedissonDbAttributesGetter.java | 2 +- .../spymemcached/SpymemcachedAttributesGetter.java | 2 +- .../v4_0/redis/VertxRedisClientAttributesGetter.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 2 +- 30 files changed, 37 insertions(+), 37 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 844a8ffb2370..1f7317978449 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -38,7 +38,7 @@ abstract class DbClientCommonAttributesExtractor< @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { if (SemconvStability.emitStableDatabaseSemconv()) { - internalSet(attributes, DB_NAMESPACE, getter.getNamespace(request)); + internalSet(attributes, DB_NAMESPACE, getter.getDbNamespace(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { internalSet(attributes, DB_USER, getter.getUser(request)); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index 109893ded31e..add2ce2f3b92 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -18,14 +18,14 @@ public interface DbClientCommonAttributesGetter { String getUser(REQUEST request); /** - * @deprecated Use {@link #getNamespace(Object)} instead. + * @deprecated Use {@link #getDbNamespace(Object)} instead. */ @Deprecated @Nullable String getName(REQUEST request); @Nullable - String getNamespace(REQUEST request); + String getDbNamespace(REQUEST request); @Deprecated @Nullable diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index d4c891375606..fcf697697ee6 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -15,7 +15,7 @@ public abstract class DbClientSpanNameExtractor implements SpanNameExtr * * @see DbClientAttributesGetter#getDbOperationName(Object) used to extract {@code * }. - * @see DbClientAttributesGetter#getNamespace(Object) used to extract {@code }. + * @see DbClientAttributesGetter#getDbNamespace(Object) used to extract {@code }. */ public static SpanNameExtractor create( DbClientAttributesGetter getter) { @@ -27,7 +27,7 @@ public static SpanNameExtractor create( * conventions: {@code .}. * * @see SqlStatementInfo#getOperation() () used to extract {@code }. - * @see DbClientAttributesGetter#getNamespace(Object) used to extract {@code }. + * @see DbClientAttributesGetter#getDbNamespace(Object) used to extract {@code }. * @see SqlStatementInfo#getMainIdentifier() used to extract {@code } or stored * procedure name. */ @@ -73,7 +73,7 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter gette @Override public String extract(REQUEST request) { - String dbName = getter.getNamespace(request); + String dbName = getter.getDbNamespace(request); String operation = getter.getDbOperationName(request); return computeSpanName(dbName, operation, null); } @@ -93,7 +93,7 @@ private SqlClientSpanNameExtractor(SqlClientAttributesGetter getter) { @Override public String extract(REQUEST request) { - String dbName = getter.getNamespace(request); + String dbName = getter.getDbNamespace(request); SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawQueryText(request)); return computeSpanName( dbName, sanitizedStatement.getOperation(), sanitizedStatement.getMainIdentifier()); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index aeac442e4a38..d1c69dd6389c 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -43,7 +43,7 @@ public String getName(Map map) { @Nullable @Override - public String getNamespace(Map map) { + public String getDbNamespace(Map map) { return map.get("db.namespace"); } 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 9fb306fd7850..1e05cef5a37e 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 @@ -25,7 +25,7 @@ void shouldExtractFullSpanName() { DbRequest dbRequest = new DbRequest(); when(sqlAttributesGetter.getRawQueryText(dbRequest)).thenReturn("SELECT * from table"); - when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); + when(sqlAttributesGetter.getDbNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -42,7 +42,7 @@ void shouldSkipDbNameIfTableAlreadyHasDbNamePrefix() { DbRequest dbRequest = new DbRequest(); when(sqlAttributesGetter.getRawQueryText(dbRequest)).thenReturn("SELECT * from another.table"); - when(sqlAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); + when(sqlAttributesGetter.getDbNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(sqlAttributesGetter); @@ -75,7 +75,7 @@ void shouldExtractOperationAndName() { DbRequest dbRequest = new DbRequest(); when(dbAttributesGetter.getDbOperationName(dbRequest)).thenReturn("SELECT"); - when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); + when(dbAttributesGetter.getDbNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); @@ -107,7 +107,7 @@ void shouldExtractDbName() { // given DbRequest dbRequest = new DbRequest(); - when(dbAttributesGetter.getNamespace(dbRequest)).thenReturn("database"); + when(dbAttributesGetter.getDbNamespace(dbRequest)).thenReturn("database"); SpanNameExtractor underTest = DbClientSpanNameExtractor.create(dbAttributesGetter); 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 f04a80aaa90f..ca174706108f 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 @@ -57,7 +57,7 @@ public String getName(Map map) { @Nullable @Override - public String getNamespace(Map map) { + public String getDbNamespace(Map map) { return map.get("db.namespace"); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 0fe658669608..cec57b3e0077 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -32,7 +32,7 @@ public String getName(CassandraRequest request) { @Nullable @Override - public String getNamespace(CassandraRequest request) { + public String getDbNamespace(CassandraRequest request) { return request.getSession().getLoggedKeyspace(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index bc8dc4cd91af..4399efc5d617 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -33,7 +33,7 @@ public String getName(CassandraRequest request) { @Nullable @Override - public String getNamespace(CassandraRequest request) { + public String getDbNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index f44e3c014a36..0720b89e8596 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -34,7 +34,7 @@ public String getName(CassandraRequest request) { @Nullable @Override - public String getNamespace(CassandraRequest request) { + public String getDbNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index 18097225e18e..46f5c962ec8e 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -74,7 +74,7 @@ public String getName(ClickHouseDbRequest request) { @Nullable @Override - public String getNamespace(ClickHouseDbRequest request) { + public String getDbNamespace(ClickHouseDbRequest request) { return getName(request); } diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index d93bcdec1d25..7ebd64f02c1c 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -32,7 +32,7 @@ public String getName(CouchbaseRequestInfo couchbaseRequest) { @Nullable @Override - public String getNamespace(CouchbaseRequestInfo couchbaseRequest) { + public String getDbNamespace(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.bucket(); } 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 64416a751cd2..3d5c5c65f8f1 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 @@ -57,7 +57,7 @@ public String getName(ElasticsearchRestRequest request) { @Nullable @Override - public String getNamespace(ElasticsearchRestRequest request) { + public String getDbNamespace(ElasticsearchRestRequest request) { return null; } 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 7a18b47acc4a..982bb2598378 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 @@ -33,7 +33,7 @@ public String getName(ElasticTransportRequest request) { @Nullable @Override - public String getNamespace(ElasticTransportRequest request) { + public String getDbNamespace(ElasticTransportRequest request) { return null; } diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index af7a7d4c8eed..bc74254172e6 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -36,7 +36,7 @@ public String getName(GeodeRequest request) { @Nullable @Override - public String getNamespace(GeodeRequest request) { + public String getDbNamespace(GeodeRequest request) { return request.getRegion().getName(); } diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index aa53f938d682..64c4cdb270c0 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -64,7 +64,7 @@ public String getName(InfluxDbRequest request) { @Nullable @Override - public String getNamespace(InfluxDbRequest request) { + public String getDbNamespace(InfluxDbRequest request) { String dbName = request.getDbName(); return "".equals(dbName) ? null : dbName; } 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 b912677c7fa8..c020b0712aa6 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 @@ -38,7 +38,7 @@ public String getName(DbRequest request) { @Nullable @Override - public String getNamespace(DbRequest request) { + public String getDbNamespace(DbRequest request) { DbInfo dbInfo = request.getDbInfo(); return dbInfo.getName() == null ? dbInfo.getDb() : dbInfo.getName(); } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index ec724e0a2498..16e1db974c82 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -36,7 +36,7 @@ public String getName(JedisRequest request) { @Nullable @Override - public String getNamespace(JedisRequest request) { + public String getDbNamespace(JedisRequest request) { return null; } diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index eb95e1d180cc..732499bac890 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -31,7 +31,7 @@ public String getName(JedisRequest request) { @Nullable @Override - public String getNamespace(JedisRequest request) { + public String getDbNamespace(JedisRequest request) { return null; } diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 40656aaac0c8..6dfe92c40033 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -31,7 +31,7 @@ public String getName(JedisRequest request) { @Nullable @Override - public String getNamespace(JedisRequest request) { + public String getDbNamespace(JedisRequest request) { return null; } diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index ed9139eca1f3..944056ac2572 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -33,7 +33,7 @@ public String getName(RedisCommand request) { @Nullable @Override - public String getNamespace(RedisCommand request) { + public String getDbNamespace(RedisCommand request) { return null; } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 20f8f2ebd513..743699a4a3c5 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -41,7 +41,7 @@ public String getName(RedisCommand request) { @Nullable @Override - public String getNamespace(RedisCommand request) { + public String getDbNamespace(RedisCommand request) { return null; } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 4f8ca5e88d08..9db34219e030 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -70,7 +70,7 @@ public String getName(CommandStartedEvent event) { @Nullable @Override - public String getNamespace(CommandStartedEvent event) { + public String getDbNamespace(CommandStartedEvent event) { return event.getDatabaseName(); } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java index 455ea77198f6..d770fe9320b0 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoSpanNameExtractor.java @@ -23,7 +23,7 @@ class MongoSpanNameExtractor implements SpanNameExtractor { @Override public String extract(CommandStartedEvent event) { String operation = dbAttributesGetter.getDbOperationName(event); - String dbName = dbAttributesGetter.getNamespace(event); + String dbName = dbAttributesGetter.getDbNamespace(event); if (operation == null) { return dbName == null ? DEFAULT_SPAN_NAME : dbName; } 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 4252bf1ab954..205ed5220022 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 @@ -33,7 +33,7 @@ public String getName(OpenSearchRestRequest request) { @Nullable @Override - public String getNamespace(OpenSearchRestRequest openSearchRestRequest) { + public String getDbNamespace(OpenSearchRestRequest openSearchRestRequest) { return null; } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 2ec717eb9066..a912bbe02cad 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -36,7 +36,7 @@ public String getName(DbExecution request) { @Nullable @Override - public String getNamespace(DbExecution request) { + public String getDbNamespace(DbExecution request) { return request.getName(); } diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index f5580709f33a..115244f57be3 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -34,7 +34,7 @@ public String getName(RedisCommand redisCommand) { @Nullable @Override - public String getNamespace(RedisCommand redisCommand) { + public String getDbNamespace(RedisCommand redisCommand) { return null; } diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index a1c0321be51b..37712aa579ec 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -32,7 +32,7 @@ public String getName(RedissonRequest request) { @Nullable @Override - public String getNamespace(RedissonRequest request) { + public String getDbNamespace(RedissonRequest request) { return null; } 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 4f4444e2cbee..91f0c77b28e9 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 @@ -31,7 +31,7 @@ public String getName(SpymemcachedRequest spymemcachedRequest) { @Nullable @Override - public String getNamespace(SpymemcachedRequest spymemcachedRequest) { + public String getDbNamespace(SpymemcachedRequest spymemcachedRequest) { return null; } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 761bdbfa6eaf..87f4cfc9a747 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -39,7 +39,7 @@ public String getName(VertxRedisClientRequest request) { @Nullable @Override - public String getNamespace(VertxRedisClientRequest request) { + public String getDbNamespace(VertxRedisClientRequest request) { return null; } 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 4aba3083b5e7..1f04e2094260 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 @@ -33,7 +33,7 @@ public String getName(VertxSqlClientRequest request) { @Nullable @Override - public String getNamespace(VertxSqlClientRequest request) { + public String getDbNamespace(VertxSqlClientRequest request) { return request.getDatabase(); } From f9120c571700fd88b789ccfecb07089a50e53763 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 17 Sep 2024 16:37:21 -0700 Subject: [PATCH 47/93] Deprecate getSystem and introduce getDbSystem --- .../semconv/db/DbClientCommonAttributesGetter.java | 4 ++++ .../semconv/db/DbClientAttributesExtractorTest.java | 8 ++++++++ .../semconv/db/SqlClientAttributesExtractorTest.java | 7 +++++++ .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 6 ++++++ .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 6 ++++++ .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 6 ++++++ .../clickhouse/ClickHouseAttributesGetter.java | 7 ++++++- .../couchbase/v2_0/CouchbaseAttributesGetter.java | 6 ++++++ .../internal/ElasticsearchDbAttributesGetter.java | 6 ++++++ .../ElasticsearchTransportAttributesGetter.java | 11 +++++++++-- .../geode/GeodeDbAttributesGetter.java | 11 +++++++++-- .../influxdb/v2_4/InfluxDbAttributesGetter.java | 6 ++++++ .../jdbc/internal/JdbcAttributesGetter.java | 7 +++++++ .../jedis/v1_4/JedisDbAttributesGetter.java | 11 +++++++++-- .../jedis/v3_0/JedisDbAttributesGetter.java | 11 +++++++++-- .../jedis/v4_0/JedisDbAttributesGetter.java | 11 +++++++++-- .../lettuce/v4_0/LettuceDbAttributesGetter.java | 11 +++++++++-- .../lettuce/v5_0/LettuceDbAttributesGetter.java | 11 +++++++++-- .../mongo/v3_1/MongoDbAttributesGetter.java | 6 ++++++ .../rest/OpenSearchRestAttributesGetter.java | 11 +++++++++-- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 7 +++++++ .../rediscala/RediscalaAttributesGetter.java | 11 +++++++++-- .../redisson/RedissonDbAttributesGetter.java | 11 +++++++++-- .../spymemcached/SpymemcachedAttributesGetter.java | 6 ++++++ .../v4_0/redis/VertxRedisClientAttributesGetter.java | 11 +++++++++-- .../v4_0/sql/VertxSqlClientAttributesGetter.java | 7 +++++++ 26 files changed, 193 insertions(+), 23 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index add2ce2f3b92..96724ef95610 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -10,9 +10,13 @@ /** An interface for getting attributes common to database clients. */ public interface DbClientCommonAttributesGetter { + @Deprecated @Nullable String getSystem(REQUEST request); + @Nullable + String getDbSystem(REQUEST request); + @Deprecated @Nullable String getUser(REQUEST request); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index d1c69dd6389c..a3c3c579ec66 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -24,11 +24,19 @@ class DbClientAttributesExtractorTest { static final class TestAttributesGetter implements DbClientAttributesGetter> { + + @Deprecated @Override public String getSystem(Map map) { return map.get("db.system"); } + @Nullable + @Override + public String getDbSystem(Map map) { + return map.get("db.system"); + } + @Deprecated @Override public String getUser(Map map) { 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 ca174706108f..4d2722568807 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 @@ -37,11 +37,18 @@ public String getRawQueryText(Map map) { return map.get("db.query.text"); } + @Deprecated @Override public String getSystem(Map map) { return map.get("db.system"); } + @Nullable + @Override + public String getDbSystem(Map map) { + return map.get("db.system"); + } + @Deprecated @Override public String getUser(Map map) { diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index cec57b3e0077..c377ff75e4f3 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -11,11 +11,17 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { + @Deprecated @Override public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } + @Override + public String getDbSystem(CassandraRequest cassandraRequest) { + return DbIncubatingAttributes.DbSystemValues.CASSANDRA; + } + @Deprecated @Override @Nullable diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 4399efc5d617..c9fbb92ed386 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -12,11 +12,17 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { + @Deprecated @Override public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } + @Override + public String getDbSystem(CassandraRequest cassandraRequest) { + return DbIncubatingAttributes.DbSystemValues.CASSANDRA; + } + @Deprecated @Override @Nullable diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 0720b89e8596..18894f834557 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -13,11 +13,17 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { + @Deprecated @Override public String getSystem(CouchbaseRequestInfo couchbaseRequest) { return DbIncubatingAttributes.DbSystemValues.COUCHBASE; } + @Override + public String getDbSystem(CouchbaseRequestInfo couchbaseRequest) { + return DbIncubatingAttributes.DbSystemValues.COUCHBASE; + } + @Deprecated @Override @Nullable 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 3d5c5c65f8f1..4b3c129439c1 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 @@ -36,11 +36,17 @@ final class ElasticsearchDbAttributesGetter this.captureSearchQuery = captureSearchQuery; } + @Deprecated @Override public String getSystem(ElasticsearchRestRequest request) { return ELASTICSEARCH; } + @Override + public String getDbSystem(ElasticsearchRestRequest elasticsearchRestRequest) { + return ELASTICSEARCH; + } + @Deprecated @Override @Nullable 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 982bb2598378..2323b8e9cd21 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 @@ -5,16 +5,23 @@ package io.opentelemetry.javaagent.instrumentation.elasticsearch.transport; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.ELASTICSEARCH; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class ElasticsearchTransportAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(ElasticTransportRequest request) { - return DbIncubatingAttributes.DbSystemValues.ELASTICSEARCH; + return ELASTICSEARCH; + } + + @Override + public String getDbSystem(ElasticTransportRequest elasticTransportRequest) { + return ELASTICSEARCH; } @Deprecated diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index bc74254172e6..e56c5d6dc965 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -5,10 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.geode; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.GEODE; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlStatementSanitizer; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class GeodeDbAttributesGetter implements DbClientAttributesGetter { @@ -16,9 +17,15 @@ final class GeodeDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Nullable @Override public String getSystem(DbRequest request) { return request.getDbInfo().getSystem(); } + @Nullable + @Override + public String getDbSystem(DbRequest request) { + return request.getDbInfo().getSystem(); + } + @Deprecated @Nullable @Override diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 16e1db974c82..60227c0da361 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -5,10 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v1_4; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class JedisDbAttributesGetter implements DbClientAttributesGetter { @@ -16,9 +17,15 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(JedisRequest request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(JedisRequest jedisRequest) { + return REDIS; } @Deprecated diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 6dfe92c40033..a4c8c19beba8 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -5,15 +5,22 @@ package io.opentelemetry.javaagent.instrumentation.jedis.v4_0; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class JedisDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(JedisRequest request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(JedisRequest jedisRequest) { + return REDIS; } @Deprecated diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index 944056ac2572..27ffdbaf487c 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -5,16 +5,23 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v4_0; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import com.lambdaworks.redis.protocol.RedisCommand; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class LettuceDbAttributesGetter implements DbClientAttributesGetter> { + @Deprecated @Override public String getSystem(RedisCommand request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(RedisCommand redisCommand) { + return REDIS; } @Deprecated diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 743699a4a3c5..4c58f126d8ed 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -5,12 +5,13 @@ package io.opentelemetry.javaagent.instrumentation.lettuce.v5_0; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.lettuce.core.protocol.RedisCommand; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer; import io.opentelemetry.instrumentation.lettuce.common.LettuceArgSplitter; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.List; import javax.annotation.Nullable; @@ -20,9 +21,15 @@ final class LettuceDbAttributesGetter implements DbClientAttributesGetter request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(RedisCommand redisCommand) { + return REDIS; } @Deprecated diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 9db34219e030..90a4fe8c6d3d 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -49,11 +49,17 @@ class MongoDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(OpenSearchRestRequest request) { - return DbIncubatingAttributes.DbSystemValues.OPENSEARCH; + return OPENSEARCH; + } + + @Override + public String getDbSystem(OpenSearchRestRequest openSearchRestRequest) { + return OPENSEARCH; } @Deprecated diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index a912bbe02cad..9957bf2e3dba 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -15,11 +15,18 @@ public enum R2dbcSqlAttributesGetter implements SqlClientAttributesGetter { INSTANCE; + @Deprecated @Override public String getSystem(DbExecution request) { return request.getSystem(); } + @Nullable + @Override + public String getDbSystem(DbExecution request) { + return request.getSystem(); + } + @Deprecated @Override @Nullable diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index 115244f57be3..cbda66f21266 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -5,17 +5,24 @@ package io.opentelemetry.javaagent.instrumentation.rediscala; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Locale; import javax.annotation.Nullable; import redis.RedisCommand; final class RediscalaAttributesGetter implements DbClientAttributesGetter> { + @Deprecated @Override public String getSystem(RedisCommand redisCommand) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(RedisCommand redisCommand) { + return REDIS; } @Deprecated diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index 37712aa579ec..6f4bc86a0491 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -5,15 +5,22 @@ package io.opentelemetry.javaagent.instrumentation.redisson; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; final class RedissonDbAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(RedissonRequest request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(RedissonRequest redissonRequest) { + return REDIS; } @Deprecated 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 91f0c77b28e9..4d9c8921db4a 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 @@ -10,11 +10,17 @@ public class SpymemcachedAttributesGetter implements DbClientAttributesGetter { + @Deprecated @Override public String getSystem(SpymemcachedRequest spymemcachedRequest) { return "memcached"; } + @Override + public String getDbSystem(SpymemcachedRequest spymemcachedRequest) { + return "memcached"; + } + @Deprecated @Override @Nullable diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 87f4cfc9a747..bdcb18e8ad7a 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -5,10 +5,11 @@ package io.opentelemetry.javaagent.instrumentation.vertx.v4_0.redis; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemValues.REDIS; + import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import javax.annotation.Nullable; public enum VertxRedisClientAttributesGetter @@ -18,9 +19,15 @@ public enum VertxRedisClientAttributesGetter private static final RedisCommandSanitizer sanitizer = RedisCommandSanitizer.create(AgentCommonConfig.get().isStatementSanitizationEnabled()); + @Deprecated @Override public String getSystem(VertxRedisClientRequest request) { - return DbIncubatingAttributes.DbSystemValues.REDIS; + return REDIS; + } + + @Override + public String getDbSystem(VertxRedisClientRequest vertxRedisClientRequest) { + return REDIS; } @Deprecated 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 1f04e2094260..ea3e004470a6 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 @@ -12,11 +12,18 @@ public enum VertxSqlClientAttributesGetter implements SqlClientAttributesGetter { INSTANCE; + @Deprecated @Override public String getSystem(VertxSqlClientRequest request) { return null; } + @Nullable + @Override + public String getDbSystem(VertxSqlClientRequest request) { + return null; + } + @Deprecated @Override @Nullable From b4aaa8489e58747e8b537a74ea52e4247df36447 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 17 Sep 2024 16:47:22 -0700 Subject: [PATCH 48/93] Delete SemconvStability.getAttributeKey --- .../instrumentation/api/internal/SemconvStability.java | 10 ---------- .../cassandra/v3_0/CassandraSingletons.java | 7 ++++--- .../cassandra/v4_0/CassandraSingletons.java | 7 ++++--- .../cassandra/v4_4/CassandraTelemetryBuilder.java | 5 ++++- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java index f5e547bc201f..81ac63218cf1 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java @@ -7,7 +7,6 @@ import static java.util.Arrays.asList; -import io.opentelemetry.api.common.AttributeKey; import java.util.HashSet; import java.util.Set; @@ -52,14 +51,5 @@ public static boolean emitStableDatabaseSemconv() { return emitStableDatabaseSemconv; } - public static AttributeKey getAttributeKey(String oldKey) { - if (emitStableDatabaseSemconv()) { - if ("db.cassandra.table".equals(oldKey)) { - return AttributeKey.stringKey("db.collection.name"); - } - } - return AttributeKey.stringKey(oldKey); - } - private SemconvStability() {} } 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 6da587d511d9..6a1bf1d236f1 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 @@ -7,6 +7,7 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; @@ -14,7 +15,6 @@ import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-3.0"; @@ -33,8 +33,9 @@ public final class CassandraSingletons { .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) .setTableAttribute( - SemconvStability.getAttributeKey( - DbIncubatingAttributes.DB_CASSANDRA_TABLE.getKey())) + SemconvStability.emitStableDatabaseSemconv() + ? AttributeKey.stringKey("db.collection.name") + : AttributeKey.stringKey("db.cassandra.table")) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 d8d065ecd661..0c1c4bb2084d 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 @@ -7,6 +7,7 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; @@ -14,7 +15,6 @@ import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; -import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.0"; @@ -32,8 +32,9 @@ public final class CassandraSingletons { .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) .setTableAttribute( - SemconvStability.getAttributeKey( - DbIncubatingAttributes.DB_CASSANDRA_TABLE.getKey())) + SemconvStability.emitStableDatabaseSemconv() + ? AttributeKey.stringKey("db.collection.name") + : AttributeKey.stringKey("db.cassandra.table")) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 b3d063ac43d8..7b340d18ae93 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 @@ -59,7 +59,10 @@ protected Instrumenter createInstrumenter( openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute(SemconvStability.getAttributeKey(DB_CASSANDRA_TABLE.getKey())) + .setTableAttribute( + SemconvStability.emitStableDatabaseSemconv() + ? AttributeKey.stringKey("db.collection.name") + : AttributeKey.stringKey("db.cassandra.table")) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( From c737e88f1767934f362241c396a863f9f07ae872 Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 17 Sep 2024 16:56:29 -0700 Subject: [PATCH 49/93] Fix unused var --- .../cassandra/v4_4/CassandraTelemetryBuilder.java | 3 --- 1 file changed, 3 deletions(-) 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 7b340d18ae93..ad9156555dcd 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 @@ -20,9 +20,6 @@ public class CassandraTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.4"; - // copied from DbIncubatingAttributes - private static final AttributeKey DB_CASSANDRA_TABLE = - AttributeKey.stringKey("db.cassandra.table"); private final OpenTelemetry openTelemetry; From b65bf89fdba347f3603ef155d6e8963e64dd4b50 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 30 Sep 2024 12:22:19 -0700 Subject: [PATCH 50/93] Address comments --- .../db/SqlClientAttributesExtractorTest.java | 57 +++++++------------ 1 file changed, 22 insertions(+), 35 deletions(-) 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 4d2722568807..fb5ae35a9a84 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 @@ -154,21 +154,14 @@ void shouldNotExtractTableIfAttributeIsNotSet() { underTest.onStart(attributes, context, request); // then - if (SemconvStability.emitOldDatabaseSemconv()) { - assertThat(attributes.build()) - .containsOnly( - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); - } else { - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT *"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT")); - } + assertThat(attributes.build()) + .containsOnly( + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT *"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT")); } @Test @@ -177,7 +170,9 @@ void shouldExtractTableToSpecifiedKey() { Map request = new HashMap<>(); if (SemconvStability.emitOldDatabaseSemconv()) { request.put("db.statement", "SELECT * FROM table"); - } else { + } + + if (SemconvStability.emitStableDatabaseSemconv()) { request.put("db.query.text", "SELECT * FROM table"); } @@ -194,25 +189,17 @@ void shouldExtractTableToSpecifiedKey() { underTest.onStart(attributes, context, request); // then - if (SemconvStability.emitOldDatabaseSemconv()) { - assertThat(attributes.build()) - .containsOnly( - entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"), - entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), - entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table")); - } else { - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM table"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), - "table")); - } + assertThat(attributes.build()) + .containsOnly( + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), + "SELECT * FROM table"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), + "SELECT"), + entry( + SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), + "table")); } @Test From 0b635f4f42767eed5eeccb075aa612581d799101 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 30 Sep 2024 12:24:50 -0700 Subject: [PATCH 51/93] Revert --- .../instrumentation/runtimemetrics/java8/Classes.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java index d181e976ade1..0632ad5a3e4d 100644 --- a/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java +++ b/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java @@ -14,13 +14,7 @@ import java.util.List; /** - * In case you enable the preview of stable database semantic conventions (e.g. by setting the - * {@code otel.semconv-stability.opt-in} system property to {@code database}), the metrics being - * exported will follow the most - * recent database semantic conventions. - * - *

Registers measurements that generate metrics about JVM classes. The metrics generated by this + * Registers measurements that generate metrics about JVM classes. The metrics generated by this * class follow the * stable JVM metrics semantic conventions. From bcc81e24dfcbffeae321f5440d804f0600f00b10 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 30 Sep 2024 12:59:21 -0700 Subject: [PATCH 52/93] Use default method and only implement the new methods --- .../semconv/db/DbClientAttributesGetter.java | 16 +++++-- .../db/DbClientCommonAttributesExtractor.java | 2 +- .../db/DbClientCommonAttributesGetter.java | 16 +++++-- .../semconv/db/SqlClientAttributesGetter.java | 8 +++- .../db/DbClientAttributesExtractorTest.java | 6 --- .../v3_0/CassandraSqlAttributesGetter.java | 20 -------- .../v4_0/CassandraSqlAttributesGetter.java | 20 -------- .../v4_4/CassandraSqlAttributesGetter.java | 20 -------- .../ClickHouseAttributesGetter.java | 34 +------------- .../v2_0/CouchbaseAttributesGetter.java | 27 ----------- .../ElasticsearchDbAttributesGetter.java | 46 ------------------- ...lasticsearchTransportAttributesGetter.java | 26 ----------- .../geode/GeodeDbAttributesGetter.java | 27 ----------- .../v2_4/InfluxDbAttributesGetter.java | 31 ------------- .../jdbc/internal/JdbcAttributesGetter.java | 22 --------- .../jedis/v1_4/JedisDbAttributesGetter.java | 24 ---------- .../jedis/v3_0/JedisDbAttributesGetter.java | 24 ---------- .../jedis/v4_0/JedisDbAttributesGetter.java | 24 ---------- .../v4_0/LettuceDbAttributesGetter.java | 25 ---------- .../v5_0/LettuceDbAttributesGetter.java | 30 ------------ .../mongo/v3_1/MongoDbAttributesGetter.java | 26 ----------- .../rest/OpenSearchRestAttributesGetter.java | 26 ----------- .../internal/R2dbcSqlAttributesGetter.java | 20 -------- .../rediscala/RediscalaAttributesGetter.java | 26 ----------- .../redisson/RedissonDbAttributesGetter.java | 26 ----------- .../SpymemcachedAttributesGetter.java | 27 ----------- .../VertxRedisClientAttributesGetter.java | 26 ----------- .../sql/VertxSqlClientAttributesGetter.java | 20 -------- 28 files changed, 32 insertions(+), 613 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 314ac94ff243..1536d9fe71bd 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -25,18 +25,26 @@ public interface DbClientAttributesGetter extends DbClientCommonAttribu */ @Deprecated @Nullable - String getStatement(REQUEST request); + default String getStatement(REQUEST request) { + return null; + } @Nullable - String getDbQueryText(REQUEST request); + default String getDbQueryText(REQUEST request) { + return getStatement(request); + } /** * @deprecated Use {@link #getDbOperationName(REQUEST)} instead. */ @Deprecated @Nullable - String getOperation(REQUEST request); + default String getOperation(REQUEST request) { + return null; + } @Nullable - String getDbOperationName(REQUEST request); + default String getDbOperationName(REQUEST request) { + return getOperation(request); + } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 1f7317978449..8023c604787d 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -42,7 +42,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST } if (SemconvStability.emitOldDatabaseSemconv()) { internalSet(attributes, DB_USER, getter.getUser(request)); - internalSet(attributes, DB_NAME, getter.getName(request)); + internalSet(attributes, DB_NAME, getter.getDbNamespace(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index 96724ef95610..f75e56f77f77 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -12,10 +12,14 @@ public interface DbClientCommonAttributesGetter { @Deprecated @Nullable - String getSystem(REQUEST request); + default String getSystem(REQUEST request) { + return null; + } @Nullable - String getDbSystem(REQUEST request); + default String getDbSystem(REQUEST request) { + return getSystem(request); + } @Deprecated @Nullable @@ -26,10 +30,14 @@ public interface DbClientCommonAttributesGetter { */ @Deprecated @Nullable - String getName(REQUEST request); + default String getName(REQUEST request) { + return null; + } @Nullable - String getDbNamespace(REQUEST request); + default String getDbNamespace(REQUEST request) { + return getName(request); + } @Deprecated @Nullable diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java index 68bb417d294d..d00e5737c434 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java @@ -29,8 +29,12 @@ public interface SqlClientAttributesGetter */ @Deprecated @Nullable - String getRawStatement(REQUEST request); + default String getRawStatement(REQUEST request) { + return null; + } @Nullable - String getRawQueryText(REQUEST request); + default String getRawQueryText(REQUEST request) { + return getRawStatement(request); + } } diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index a3c3c579ec66..68b6fa1f64d7 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -25,12 +25,6 @@ class DbClientAttributesExtractorTest { static final class TestAttributesGetter implements DbClientAttributesGetter> { - @Deprecated - @Override - public String getSystem(Map map) { - return map.get("db.system"); - } - @Nullable @Override public String getDbSystem(Map map) { diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index c377ff75e4f3..587dab7c9b93 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -11,12 +11,6 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { - @Deprecated - @Override - public String getSystem(CassandraRequest request) { - return DbIncubatingAttributes.DbSystemValues.CASSANDRA; - } - @Override public String getDbSystem(CassandraRequest cassandraRequest) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; @@ -29,13 +23,6 @@ public String getUser(CassandraRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(CassandraRequest request) { - return request.getSession().getLoggedKeyspace(); - } - @Nullable @Override public String getDbNamespace(CassandraRequest request) { @@ -49,13 +36,6 @@ public String getConnectionString(CassandraRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getRawStatement(CassandraRequest request) { - return request.getDbQueryText(); - } - @Override public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index c9fbb92ed386..5602cb35f41a 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -12,12 +12,6 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { - @Deprecated - @Override - public String getSystem(CassandraRequest request) { - return DbIncubatingAttributes.DbSystemValues.CASSANDRA; - } - @Override public String getDbSystem(CassandraRequest cassandraRequest) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; @@ -30,13 +24,6 @@ public String getUser(CassandraRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(CassandraRequest request) { - return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); - } - @Nullable @Override public String getDbNamespace(CassandraRequest request) { @@ -50,13 +37,6 @@ public String getConnectionString(CassandraRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getRawStatement(CassandraRequest request) { - return request.getDbQueryText(); - } - @Override public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 18894f834557..0f9df94c9b36 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -13,12 +13,6 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { - @Deprecated - @Nullable - @Override - public String getStatement(ClickHouseDbRequest request) { - if (request.getSqlStatementInfo() == null) { - return null; - } - return request.getSqlStatementInfo().getFullStatement(); - } @Nullable @Override @@ -29,16 +20,6 @@ public String getDbQueryText(ClickHouseDbRequest request) { return request.getSqlStatementInfo().getFullStatement(); } - @Deprecated - @Nullable - @Override - public String getOperation(ClickHouseDbRequest request) { - if (request.getSqlStatementInfo() == null) { - return null; - } - return request.getSqlStatementInfo().getOperation(); - } - @Nullable @Override public String getDbOperationName(ClickHouseDbRequest request) { @@ -48,12 +29,6 @@ public String getDbOperationName(ClickHouseDbRequest request) { return request.getSqlStatementInfo().getOperation(); } - @Deprecated - @Override - public String getSystem(ClickHouseDbRequest request) { - return DbIncubatingAttributes.DbSystemValues.CLICKHOUSE; - } - @Override public String getDbSystem(ClickHouseDbRequest request) { return DbIncubatingAttributes.DbSystemValues.CLICKHOUSE; @@ -66,10 +41,9 @@ public String getUser(ClickHouseDbRequest request) { return null; } - @Deprecated @Nullable @Override - public String getName(ClickHouseDbRequest request) { + public String getDbNamespace(ClickHouseDbRequest request) { String dbName = request.getDbName(); if (dbName == null || dbName.isEmpty()) { return null; @@ -77,12 +51,6 @@ public String getName(ClickHouseDbRequest request) { return dbName; } - @Nullable - @Override - public String getDbNamespace(ClickHouseDbRequest request) { - return getName(request); - } - @Deprecated @Nullable @Override diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index 47e1b9c00333..1e42c857a47e 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -11,12 +11,6 @@ final class CouchbaseAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(CouchbaseRequestInfo couchbaseRequest) { - return DbIncubatingAttributes.DbSystemValues.COUCHBASE; - } - @Override public String getDbSystem(CouchbaseRequestInfo couchbaseRequest) { return DbIncubatingAttributes.DbSystemValues.COUCHBASE; @@ -29,13 +23,6 @@ public String getUser(CouchbaseRequestInfo couchbaseRequest) { return null; } - @Deprecated - @Override - @Nullable - public String getName(CouchbaseRequestInfo couchbaseRequest) { - return couchbaseRequest.bucket(); - } - @Nullable @Override public String getDbNamespace(CouchbaseRequestInfo couchbaseRequest) { @@ -49,26 +36,12 @@ public String getConnectionString(CouchbaseRequestInfo couchbaseRequest) { return null; } - @Deprecated - @Override - @Nullable - public String getStatement(CouchbaseRequestInfo couchbaseRequest) { - return couchbaseRequest.statement(); - } - @Nullable @Override public String getDbQueryText(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.statement(); } - @Deprecated - @Override - @Nullable - public String getOperation(CouchbaseRequestInfo couchbaseRequest) { - return couchbaseRequest.operation(); - } - @Nullable @Override public String getDbOperationName(CouchbaseRequestInfo couchbaseRequest) { 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 4b3c129439c1..d0ffc3db22a5 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 @@ -36,12 +36,6 @@ final class ElasticsearchDbAttributesGetter this.captureSearchQuery = captureSearchQuery; } - @Deprecated - @Override - public String getSystem(ElasticsearchRestRequest request) { - return ELASTICSEARCH; - } - @Override public String getDbSystem(ElasticsearchRestRequest elasticsearchRestRequest) { return ELASTICSEARCH; @@ -54,13 +48,6 @@ public String getUser(ElasticsearchRestRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(ElasticsearchRestRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(ElasticsearchRestRequest request) { @@ -74,31 +61,6 @@ public String getConnectionString(ElasticsearchRestRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getStatement(ElasticsearchRestRequest request) { - ElasticsearchEndpointDefinition epDefinition = request.getEndpointDefinition(); - HttpEntity httpEntity = request.getHttpEntity(); - if (captureSearchQuery - && epDefinition != null - && epDefinition.isSearchEndpoint() - && httpEntity != null - && httpEntity.isRepeatable()) { - // Retrieve HTTP body for search-type Elasticsearch requests when CAPTURE_SEARCH_QUERY is - // enabled. - try { - return new BufferedReader( - new InputStreamReader(httpEntity.getContent(), StandardCharsets.UTF_8)) - .lines() - .collect(Collectors.joining()); - } catch (IOException e) { - logger.log(FINE, "Failed reading HTTP body content.", e); - } - } - return null; - } - @Nullable @Override public String getDbQueryText(ElasticsearchRestRequest request) { @@ -123,14 +85,6 @@ public String getDbQueryText(ElasticsearchRestRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getOperation(ElasticsearchRestRequest request) { - ElasticsearchEndpointDefinition endpointDefinition = request.getEndpointDefinition(); - return endpointDefinition != null ? endpointDefinition.getEndpointName() : null; - } - @Nullable @Override public String getDbOperationName(ElasticsearchRestRequest request) { 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 2323b8e9cd21..73cfad1b1be0 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 @@ -13,12 +13,6 @@ final class ElasticsearchTransportAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(ElasticTransportRequest request) { - return ELASTICSEARCH; - } - @Override public String getDbSystem(ElasticTransportRequest elasticTransportRequest) { return ELASTICSEARCH; @@ -31,13 +25,6 @@ public String getUser(ElasticTransportRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(ElasticTransportRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(ElasticTransportRequest request) { @@ -51,25 +38,12 @@ public String getConnectionString(ElasticTransportRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getStatement(ElasticTransportRequest request) { - return null; - } - @Nullable @Override public String getDbQueryText(ElasticTransportRequest request) { return null; } - @Deprecated - @Override - public String getOperation(ElasticTransportRequest request) { - return request.getAction().getClass().getSimpleName(); - } - @Override public String getDbOperationName(ElasticTransportRequest request) { return request.getAction().getClass().getSimpleName(); diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index e56c5d6dc965..8c863c8374f2 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -17,12 +17,6 @@ final class GeodeDbAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Nullable - @Override - public String getStatement(InfluxDbRequest request) { - return request.getSqlStatementInfo().getFullStatement(); - } - @Nullable @Override public String getDbQueryText(InfluxDbRequest request) { return request.getSqlStatementInfo().getFullStatement(); } - @Deprecated - @Nullable - @Override - public String getOperation(InfluxDbRequest request) { - if (request.getOperation() != null) { - return request.getOperation(); - } - return request.getSqlStatementInfo().getOperation(); - } - @Nullable @Override public String getDbOperationName(InfluxDbRequest request) { @@ -42,12 +25,6 @@ public String getDbOperationName(InfluxDbRequest request) { return request.getSqlStatementInfo().getOperation(); } - @Deprecated - @Override - public String getSystem(InfluxDbRequest request) { - return "influxdb"; - } - @Override public String getDbSystem(InfluxDbRequest influxDbRequest) { return "influxdb"; @@ -60,14 +37,6 @@ public String getUser(InfluxDbRequest request) { return null; } - @Deprecated - @Nullable - @Override - public String getName(InfluxDbRequest request) { - String dbName = request.getDbName(); - return "".equals(dbName) ? null : dbName; - } - @Nullable @Override public String getDbNamespace(InfluxDbRequest request) { 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 99f73f122669..3589bd7f57f1 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 @@ -15,13 +15,6 @@ */ public final class JdbcAttributesGetter implements SqlClientAttributesGetter { - @Deprecated - @Nullable - @Override - public String getSystem(DbRequest request) { - return request.getDbInfo().getSystem(); - } - @Nullable @Override public String getDbSystem(DbRequest request) { @@ -35,14 +28,6 @@ public String getUser(DbRequest request) { return request.getDbInfo().getUser(); } - @Deprecated - @Nullable - @Override - public String getName(DbRequest request) { - DbInfo dbInfo = request.getDbInfo(); - return dbInfo.getName() == null ? dbInfo.getDb() : dbInfo.getName(); - } - @Nullable @Override public String getDbNamespace(DbRequest request) { @@ -57,13 +42,6 @@ public String getConnectionString(DbRequest request) { return request.getDbInfo().getShortUrl(); } - @Deprecated - @Nullable - @Override - public String getRawStatement(DbRequest request) { - return request.getDbQueryText(); - } - @Override public String getRawQueryText(DbRequest request) { return request.getDbQueryText(); diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 60227c0da361..8def0e715326 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -17,12 +17,6 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(JedisRequest request) { - return REDIS; - } - @Override public String getDbSystem(JedisRequest jedisRequest) { return REDIS; @@ -30,12 +24,6 @@ public String getUser(JedisRequest request) { return null; } - @Deprecated - @Override - public String getName(JedisRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(JedisRequest request) { @@ -48,24 +36,12 @@ public String getConnectionString(JedisRequest request) { return null; } - @Deprecated - @Override - public String getStatement(JedisRequest request) { - return request.getStatement(); - } - @Nullable @Override public String getDbQueryText(JedisRequest request) { return request.getStatement(); } - @Deprecated - @Override - public String getOperation(JedisRequest request) { - return request.getOperation(); - } - @Nullable @Override public String getDbOperationName(JedisRequest request) { diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index a4c8c19beba8..0d9f0a1edd92 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -12,12 +12,6 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(JedisRequest request) { - return REDIS; - } - @Override public String getDbSystem(JedisRequest jedisRequest) { return REDIS; @@ -30,12 +24,6 @@ public String getUser(JedisRequest request) { return null; } - @Deprecated - @Override - public String getName(JedisRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(JedisRequest request) { @@ -48,24 +36,12 @@ public String getConnectionString(JedisRequest request) { return null; } - @Deprecated - @Override - public String getStatement(JedisRequest request) { - return request.getStatement(); - } - @Nullable @Override public String getDbQueryText(JedisRequest request) { return request.getStatement(); } - @Deprecated - @Override - public String getOperation(JedisRequest request) { - return request.getOperation(); - } - @Nullable @Override public String getDbOperationName(JedisRequest request) { diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index 27ffdbaf487c..a09001b8d0ac 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -13,12 +13,6 @@ final class LettuceDbAttributesGetter implements DbClientAttributesGetter> { - @Deprecated - @Override - public String getSystem(RedisCommand request) { - return REDIS; - } - @Override public String getDbSystem(RedisCommand redisCommand) { return REDIS; @@ -31,13 +25,6 @@ public String getUser(RedisCommand request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(RedisCommand request) { - return null; - } - @Nullable @Override public String getDbNamespace(RedisCommand request) { @@ -51,24 +38,12 @@ public String getConnectionString(RedisCommand request) { return null; } - @Deprecated - @Override - public String getStatement(RedisCommand request) { - return null; - } - @Nullable @Override public String getDbQueryText(RedisCommand request) { return null; } - @Deprecated - @Override - public String getOperation(RedisCommand request) { - return request.getType().name(); - } - @Nullable @Override public String getDbOperationName(RedisCommand request) { diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index 4c58f126d8ed..a2bc5c4d7991 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -21,12 +21,6 @@ final class LettuceDbAttributesGetter implements DbClientAttributesGetter request) { - return REDIS; - } - @Override public String getDbSystem(RedisCommand redisCommand) { return REDIS; @@ -39,13 +33,6 @@ public String getUser(RedisCommand request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(RedisCommand request) { - return null; - } - @Nullable @Override public String getDbNamespace(RedisCommand request) { @@ -59,17 +46,6 @@ public String getConnectionString(RedisCommand request) { return null; } - @Deprecated - @Override - public String getStatement(RedisCommand request) { - String command = LettuceInstrumentationUtil.getCommandName(request); - List args = - request.getArgs() == null - ? Collections.emptyList() - : LettuceArgSplitter.splitArgs(request.getArgs().toCommandString()); - return sanitizer.sanitize(command, args); - } - @Nullable @Override public String getDbQueryText(RedisCommand request) { @@ -81,12 +57,6 @@ public String getDbQueryText(RedisCommand request) { return sanitizer.sanitize(command, args); } - @Deprecated - @Override - public String getOperation(RedisCommand request) { - return request.getType().name(); - } - @Nullable @Override public String getDbOperationName(RedisCommand request) { diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 90a4fe8c6d3d..3dac156b9303 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -49,12 +49,6 @@ class MongoDbAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(OpenSearchRestRequest request) { - return OPENSEARCH; - } - @Override public String getDbSystem(OpenSearchRestRequest openSearchRestRequest) { return OPENSEARCH; @@ -31,13 +25,6 @@ public String getUser(OpenSearchRestRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getName(OpenSearchRestRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(OpenSearchRestRequest openSearchRestRequest) { @@ -51,24 +38,11 @@ public String getConnectionString(OpenSearchRestRequest request) { return null; } - @Deprecated - @Override - public String getStatement(OpenSearchRestRequest request) { - return request.getMethod() + " " + request.getOperation(); - } - @Override public String getDbQueryText(OpenSearchRestRequest request) { return request.getMethod() + " " + request.getOperation(); } - @Deprecated - @Override - @Nullable - public String getOperation(OpenSearchRestRequest request) { - return request.getMethod(); - } - @Nullable @Override public String getDbOperationName(OpenSearchRestRequest request) { diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 9957bf2e3dba..188b6b8d9613 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -15,12 +15,6 @@ public enum R2dbcSqlAttributesGetter implements SqlClientAttributesGetter { INSTANCE; - @Deprecated - @Override - public String getSystem(DbExecution request) { - return request.getSystem(); - } - @Nullable @Override public String getDbSystem(DbExecution request) { @@ -34,13 +28,6 @@ public String getUser(DbExecution request) { return request.getUser(); } - @Deprecated - @Override - @Nullable - public String getName(DbExecution request) { - return request.getName(); - } - @Nullable @Override public String getDbNamespace(DbExecution request) { @@ -54,13 +41,6 @@ public String getConnectionString(DbExecution request) { return request.getConnectionString(); } - @Deprecated - @Override - @Nullable - public String getRawStatement(DbExecution request) { - return request.getRawStatement(); - } - @Override public String getRawQueryText(DbExecution request) { return request.getDbQueryText(); diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index cbda66f21266..fcc68771b5e1 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -14,12 +14,6 @@ final class RediscalaAttributesGetter implements DbClientAttributesGetter> { - @Deprecated - @Override - public String getSystem(RedisCommand redisCommand) { - return REDIS; - } - @Override public String getDbSystem(RedisCommand redisCommand) { return REDIS; @@ -32,13 +26,6 @@ public String getUser(RedisCommand redisCommand) { return null; } - @Deprecated - @Override - @Nullable - public String getName(RedisCommand redisCommand) { - return null; - } - @Nullable @Override public String getDbNamespace(RedisCommand redisCommand) { @@ -52,25 +39,12 @@ public String getConnectionString(RedisCommand redisCommand) { return null; } - @Deprecated - @Override - @Nullable - public String getStatement(RedisCommand redisCommand) { - return null; - } - @Nullable @Override public String getDbQueryText(RedisCommand redisCommand) { return null; } - @Deprecated - @Override - public String getOperation(RedisCommand redisCommand) { - return redisCommand.getClass().getSimpleName().toUpperCase(Locale.ROOT); - } - @Override public String getDbOperationName(RedisCommand redisCommand) { return redisCommand.getClass().getSimpleName().toUpperCase(Locale.ROOT); diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index 6f4bc86a0491..669cbb2d6476 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -12,12 +12,6 @@ final class RedissonDbAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(RedissonRequest request) { - return REDIS; - } - @Override public String getDbSystem(RedissonRequest redissonRequest) { return REDIS; @@ -30,13 +24,6 @@ public String getUser(RedissonRequest request) { return null; } - @Deprecated - @Nullable - @Override - public String getName(RedissonRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(RedissonRequest request) { @@ -49,24 +36,11 @@ public String getConnectionString(RedissonRequest request) { return null; } - @Deprecated - @Override - public String getStatement(RedissonRequest request) { - return request.getStatement(); - } - @Override public String getDbQueryText(RedissonRequest request) { return request.getStatement(); } - @Deprecated - @Nullable - @Override - public String getOperation(RedissonRequest request) { - return request.getOperation(); - } - @Nullable @Override public String getDbOperationName(RedissonRequest request) { 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 4d9c8921db4a..de9e1c11daf0 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 @@ -10,12 +10,6 @@ public class SpymemcachedAttributesGetter implements DbClientAttributesGetter { - @Deprecated - @Override - public String getSystem(SpymemcachedRequest spymemcachedRequest) { - return "memcached"; - } - @Override public String getDbSystem(SpymemcachedRequest spymemcachedRequest) { return "memcached"; @@ -28,13 +22,6 @@ public String getUser(SpymemcachedRequest spymemcachedRequest) { return null; } - @Deprecated - @Override - @Nullable - public String getName(SpymemcachedRequest spymemcachedRequest) { - return null; - } - @Nullable @Override public String getDbNamespace(SpymemcachedRequest spymemcachedRequest) { @@ -48,26 +35,12 @@ public String getConnectionString(SpymemcachedRequest spymemcachedRequest) { return null; } - @Deprecated - @Override - @Nullable - public String getStatement(SpymemcachedRequest spymemcachedRequest) { - return null; - } - @Nullable @Override public String getDbQueryText(SpymemcachedRequest spymemcachedRequest) { return null; } - @Deprecated - @Override - @Nullable - public String getOperation(SpymemcachedRequest spymemcachedRequest) { - return spymemcachedRequest.dbOperation(); - } - @Nullable @Override public String getDbOperationName(SpymemcachedRequest spymemcachedRequest) { diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index bdcb18e8ad7a..8411aa69c983 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -19,12 +19,6 @@ public enum VertxRedisClientAttributesGetter private static final RedisCommandSanitizer sanitizer = RedisCommandSanitizer.create(AgentCommonConfig.get().isStatementSanitizationEnabled()); - @Deprecated - @Override - public String getSystem(VertxRedisClientRequest request) { - return REDIS; - } - @Override public String getDbSystem(VertxRedisClientRequest vertxRedisClientRequest) { return REDIS; @@ -37,13 +31,6 @@ public String getUser(VertxRedisClientRequest request) { return request.getUser(); } - @Deprecated - @Override - @Nullable - public String getName(VertxRedisClientRequest request) { - return null; - } - @Nullable @Override public String getDbNamespace(VertxRedisClientRequest request) { @@ -57,25 +44,12 @@ public String getConnectionString(VertxRedisClientRequest request) { return request.getConnectionString(); } - @Deprecated - @Override - public String getStatement(VertxRedisClientRequest request) { - return sanitizer.sanitize(request.getCommand(), request.getArgs()); - } - @Nullable @Override public String getDbQueryText(VertxRedisClientRequest request) { return sanitizer.sanitize(request.getCommand(), request.getArgs()); } - @Deprecated - @Nullable - @Override - public String getOperation(VertxRedisClientRequest request) { - return request.getCommand(); - } - @Nullable @Override public String getDbOperationName(VertxRedisClientRequest request) { 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 ea3e004470a6..453aca47b92e 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 @@ -12,12 +12,6 @@ public enum VertxSqlClientAttributesGetter implements SqlClientAttributesGetter { INSTANCE; - @Deprecated - @Override - public String getSystem(VertxSqlClientRequest request) { - return null; - } - @Nullable @Override public String getDbSystem(VertxSqlClientRequest request) { @@ -31,13 +25,6 @@ public String getUser(VertxSqlClientRequest request) { return request.getUser(); } - @Deprecated - @Override - @Nullable - public String getName(VertxSqlClientRequest request) { - return request.getDatabase(); - } - @Nullable @Override public String getDbNamespace(VertxSqlClientRequest request) { @@ -51,13 +38,6 @@ public String getConnectionString(VertxSqlClientRequest request) { return null; } - @Deprecated - @Override - @Nullable - public String getRawStatement(VertxSqlClientRequest request) { - return request.getStatement(); - } - @Override public String getRawQueryText(VertxSqlClientRequest request) { return request.getDbQueryText(); From 1015c3785bcfc4fc6a5b17b97caf6a0972224cbb Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 30 Sep 2024 13:45:04 -0700 Subject: [PATCH 53/93] Fix tests --- .../db/DbClientCommonAttributesExtractor.java | 2 +- .../db/SqlClientAttributesExtractor.java | 12 +++----- .../db/DbClientAttributesExtractorTest.java | 28 +++++-------------- .../db/SqlClientAttributesExtractorTest.java | 26 ++++------------- 4 files changed, 17 insertions(+), 51 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 8023c604787d..05dbe18189a2 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -45,7 +45,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST internalSet(attributes, DB_NAME, getter.getDbNamespace(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } - internalSet(attributes, DB_SYSTEM, getter.getSystem(request)); + internalSet(attributes, DB_SYSTEM, getter.getDbSystem(request)); } @Override diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 7e26faf850d5..9288a08dec27 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -65,28 +65,24 @@ public static SqlClientAttributesExtractorBuilder map) { return map.get("db.user"); } - @Deprecated - @Override - public String getName(Map map) { - return map.get("db.name"); - } - @Nullable @Override public String getDbNamespace(Map map) { - return map.get("db.namespace"); + return map.get( + SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); } @Deprecated @@ -55,28 +51,18 @@ public String getConnectionString(Map map) { return map.get("db.connection_string"); } - @Deprecated - @Override - public String getStatement(Map map) { - return map.get("db.statement"); - } - @Nullable @Override public String getDbQueryText(Map map) { - return map.get("db.query.text"); - } - - @Deprecated - @Override - public String getOperation(Map map) { - return map.get("db.operation"); + return map.get( + SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); } @Nullable @Override public String getDbOperationName(Map map) { - return map.get("db.operation.name"); + return map.get( + SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.operation")).getKey()); } } 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 fb5ae35a9a84..25d841cbf0ca 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 @@ -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; @@ -26,21 +27,10 @@ class SqlClientAttributesExtractorTest { static final class TestAttributesGetter implements SqlClientAttributesGetter> { - @Deprecated - @Override - public String getRawStatement(Map map) { - return map.get("db.statement"); - } - @Override public String getRawQueryText(Map map) { - return map.get("db.query.text"); - } - - @Deprecated - @Override - public String getSystem(Map map) { - return map.get("db.system"); + return map.get( + SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); } @Nullable @@ -55,17 +45,11 @@ public String getUser(Map map) { return map.get("db.user"); } - @Deprecated - @Nullable - @Override - public String getName(Map map) { - return map.get("db.name"); - } - @Nullable @Override public String getDbNamespace(Map map) { - return map.get("db.namespace"); + return map.get( + SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); } @Deprecated From e5c0806404a57f698b8e48fde98aff968737ae80 Mon Sep 17 00:00:00 2001 From: heyams Date: Mon, 30 Sep 2024 16:32:43 -0700 Subject: [PATCH 54/93] Fix --- .../incubator/semconv/db/DbClientAttributesExtractor.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java index 84fb64756f5f..279f3171d192 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java @@ -43,7 +43,6 @@ public static AttributesExtractor create( super(getter); } - @SuppressWarnings("deprecation") // until old db semconv are dropped @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { super.onStart(attributes, parentContext, request); @@ -53,8 +52,8 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST internalSet(attributes, DB_OPERATION_NAME, getter.getDbOperationName(request)); } if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, DB_STATEMENT, getter.getStatement(request)); - internalSet(attributes, DB_OPERATION, getter.getOperation(request)); + internalSet(attributes, DB_STATEMENT, getter.getDbQueryText(request)); + internalSet(attributes, DB_OPERATION, getter.getDbOperationName(request)); } } } From 72c426d9633014f67ade09bce39d3f55cc67f49b Mon Sep 17 00:00:00 2001 From: heyams Date: Tue, 1 Oct 2024 13:15:09 -0700 Subject: [PATCH 55/93] Comments --- .../incubator/semconv/db/DbClientAttributesGetter.java | 2 ++ .../semconv/db/DbClientCommonAttributesExtractor.java | 2 +- .../semconv/db/DbClientCommonAttributesGetter.java | 2 ++ .../semconv/db/DbClientSpanNameExtractor.java | 10 +++++----- .../semconv/db/SqlClientAttributesExtractor.java | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java index 1536d9fe71bd..ddf9f8f07a1a 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java @@ -29,6 +29,7 @@ default String getStatement(REQUEST request) { return null; } + // TODO: make this required to implement @Nullable default String getDbQueryText(REQUEST request) { return getStatement(request); @@ -43,6 +44,7 @@ default String getOperation(REQUEST request) { return null; } + // TODO: make this required to implement @Nullable default String getDbOperationName(REQUEST request) { return getOperation(request); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java index 05dbe18189a2..9cbf4fb97895 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java @@ -37,6 +37,7 @@ abstract class DbClientCommonAttributesExtractor< @SuppressWarnings("deprecation") // until old db semconv are dropped @Override public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { + internalSet(attributes, DB_SYSTEM, getter.getDbSystem(request)); if (SemconvStability.emitStableDatabaseSemconv()) { internalSet(attributes, DB_NAMESPACE, getter.getDbNamespace(request)); } @@ -45,7 +46,6 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST internalSet(attributes, DB_NAME, getter.getDbNamespace(request)); internalSet(attributes, DB_CONNECTION_STRING, getter.getConnectionString(request)); } - internalSet(attributes, DB_SYSTEM, getter.getDbSystem(request)); } @Override diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java index f75e56f77f77..bc9a335f4e76 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesGetter.java @@ -16,6 +16,7 @@ default String getSystem(REQUEST request) { return null; } + // TODO: make this required to implement @Nullable default String getDbSystem(REQUEST request) { return getSystem(request); @@ -34,6 +35,7 @@ default String getName(REQUEST request) { return null; } + // TODO: make this required to implement @Nullable default String getDbNamespace(REQUEST request) { return getName(request); diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index fcf697697ee6..c926a051be99 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -73,9 +73,9 @@ private GenericDbClientSpanNameExtractor(DbClientAttributesGetter gette @Override public String extract(REQUEST request) { - String dbName = getter.getDbNamespace(request); - String operation = getter.getDbOperationName(request); - return computeSpanName(dbName, operation, null); + String namespace = getter.getDbNamespace(request); + String operationName = getter.getDbOperationName(request); + return computeSpanName(namespace, operationName, null); } } @@ -93,10 +93,10 @@ private SqlClientSpanNameExtractor(SqlClientAttributesGetter getter) { @Override public String extract(REQUEST request) { - String dbName = getter.getDbNamespace(request); + String namespace = getter.getDbNamespace(request); SqlStatementInfo sanitizedStatement = sanitizer.sanitize(getter.getRawQueryText(request)); return computeSpanName( - dbName, sanitizedStatement.getOperation(), sanitizedStatement.getMainIdentifier()); + namespace, sanitizedStatement.getOperation(), sanitizedStatement.getMainIdentifier()); } } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 9288a08dec27..3d47de17ad79 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -78,7 +78,8 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST DB_QUERY_TEXT, statementSanitizationEnabled ? sanitizedStatement.getFullStatement() : rawQueryText); internalSet(attributes, DB_OPERATION_NAME, operation); - } else if (SemconvStability.emitOldDatabaseSemconv()) { + } + if (SemconvStability.emitOldDatabaseSemconv()) { internalSet( attributes, DB_STATEMENT, From f8849947f3461384d329958ba438beb8322556bf Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 2 Oct 2024 10:33:43 -0700 Subject: [PATCH 56/93] Comments --- .../incubator/semconv/db/DbClientSpanNameExtractor.java | 2 +- .../incubator/semconv/db/SqlClientAttributesGetter.java | 1 + .../lettuce/v5_0/LettuceDbAttributesGetter.java | 8 ++++---- .../instrumentation/r2dbc/v1_0/internal/DbExecution.java | 8 -------- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 4 ++-- .../rediscala/RediscalaAttributesGetter.java | 4 ++-- .../v4_0/redis/VertxRedisClientAttributesGetter.java | 6 +++--- .../vertx/v4_0/sql/VertxSqlClientRequest.java | 8 -------- 8 files changed, 13 insertions(+), 28 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java index c926a051be99..58eb91b08b09 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java @@ -26,7 +26,7 @@ public static SpanNameExtractor create( * Returns a {@link SpanNameExtractor} that constructs the span name according to DB semantic * conventions: {@code .}. * - * @see SqlStatementInfo#getOperation() () used to extract {@code }. + * @see SqlStatementInfo#getOperation() used to extract {@code }. * @see DbClientAttributesGetter#getDbNamespace(Object) used to extract {@code }. * @see SqlStatementInfo#getMainIdentifier() used to extract {@code } or stored * procedure name. diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java index d00e5737c434..d0817d63e460 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java @@ -33,6 +33,7 @@ default String getRawStatement(REQUEST request) { return null; } + // TODO: make this required to implement @Nullable default String getRawQueryText(REQUEST request) { return getRawStatement(request); diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index a2bc5c4d7991..c79459c56a3e 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -22,7 +22,7 @@ final class LettuceDbAttributesGetter implements DbClientAttributesGetter redisCommand) { + public String getDbSystem(RedisCommand request) { return REDIS; } @@ -33,8 +33,8 @@ public String getUser(RedisCommand request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(RedisCommand request) { return null; } @@ -46,8 +46,8 @@ public String getConnectionString(RedisCommand request) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(RedisCommand request) { String command = LettuceInstrumentationUtil.getCommandName(request); List args = @@ -57,8 +57,8 @@ public String getDbQueryText(RedisCommand request) { return sanitizer.sanitize(command, args); } - @Nullable @Override + @Nullable public String getDbOperationName(RedisCommand request) { return request.getType().name(); } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java index 8b77dbd0510b..c78a33e1dc80 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java @@ -94,14 +94,6 @@ public String getConnectionString() { return connectionString; } - /** - * @deprecated use {@link #getDbQueryText()} instead - */ - @Deprecated - public String getRawStatement() { - return rawStatement; - } - public String getDbQueryText() { return rawStatement; } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 188b6b8d9613..afc143261b89 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -15,8 +15,8 @@ public enum R2dbcSqlAttributesGetter implements SqlClientAttributesGetter { INSTANCE; - @Nullable @Override + @Nullable public String getDbSystem(DbExecution request) { return request.getSystem(); } @@ -28,8 +28,8 @@ public String getUser(DbExecution request) { return request.getUser(); } - @Nullable @Override + @Nullable public String getDbNamespace(DbExecution request) { return request.getName(); } diff --git a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java index fcc68771b5e1..d437c400eb41 100644 --- a/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java +++ b/instrumentation/rediscala-1.8/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rediscala/RediscalaAttributesGetter.java @@ -26,8 +26,8 @@ public String getUser(RedisCommand redisCommand) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(RedisCommand redisCommand) { return null; } @@ -39,8 +39,8 @@ public String getConnectionString(RedisCommand redisCommand) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(RedisCommand redisCommand) { return null; } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 8411aa69c983..265cd159a7de 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -31,8 +31,8 @@ public String getUser(VertxRedisClientRequest request) { return request.getUser(); } - @Nullable @Override + @Nullable public String getDbNamespace(VertxRedisClientRequest request) { return null; } @@ -44,14 +44,14 @@ public String getConnectionString(VertxRedisClientRequest request) { return request.getConnectionString(); } - @Nullable @Override + @Nullable public String getDbQueryText(VertxRedisClientRequest request) { return sanitizer.sanitize(request.getCommand(), request.getArgs()); } - @Nullable @Override + @Nullable public String getDbOperationName(VertxRedisClientRequest request) { return request.getCommand(); } diff --git a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java index 10866f2cb3ac..9ae5d6019aff 100644 --- a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java +++ b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java @@ -16,14 +16,6 @@ public VertxSqlClientRequest(String statement, SqlConnectOptions sqlConnectOptio this.sqlConnectOptions = sqlConnectOptions; } - /** - * @deprecated Use {@link #getDbQueryText()} instead. - */ - @Deprecated - public String getStatement() { - return statement; - } - public String getDbQueryText() { return statement; } From e527073aa0224ebf9867bcd22e72fc08237e1fbd Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 2 Oct 2024 10:43:17 -0700 Subject: [PATCH 57/93] Reorder annotation --- .../redisson/RedissonDbAttributesGetter.java | 8 ++++---- .../spymemcached/SpymemcachedAttributesGetter.java | 6 +++--- .../v4_0/redis/VertxRedisClientAttributesGetter.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java index 669cbb2d6476..39bd7cd9c602 100644 --- a/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java +++ b/instrumentation/redisson/redisson-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/RedissonDbAttributesGetter.java @@ -13,19 +13,19 @@ final class RedissonDbAttributesGetter implements DbClientAttributesGetter { @Override - public String getDbSystem(RedissonRequest redissonRequest) { + public String getDbSystem(RedissonRequest request) { return REDIS; } @Deprecated - @Nullable @Override + @Nullable public String getUser(RedissonRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(RedissonRequest request) { return null; } @@ -41,8 +41,8 @@ public String getDbQueryText(RedissonRequest request) { return request.getStatement(); } - @Nullable @Override + @Nullable public String getDbOperationName(RedissonRequest request) { return request.getOperation(); } 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 de9e1c11daf0..086c2dc65693 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 @@ -22,8 +22,8 @@ public String getUser(SpymemcachedRequest spymemcachedRequest) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(SpymemcachedRequest spymemcachedRequest) { return null; } @@ -35,14 +35,14 @@ public String getConnectionString(SpymemcachedRequest spymemcachedRequest) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(SpymemcachedRequest spymemcachedRequest) { return null; } - @Nullable @Override + @Nullable public String getDbOperationName(SpymemcachedRequest spymemcachedRequest) { return spymemcachedRequest.dbOperation(); } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 265cd159a7de..1e05dbe6d18a 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -20,7 +20,7 @@ public enum VertxRedisClientAttributesGetter RedisCommandSanitizer.create(AgentCommonConfig.get().isStatementSanitizationEnabled()); @Override - public String getDbSystem(VertxRedisClientRequest vertxRedisClientRequest) { + public String getDbSystem(VertxRedisClientRequest request) { return REDIS; } From 43745f99aa8ec72e15a845665ff51302fd3fd238 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 2 Oct 2024 11:07:11 -0700 Subject: [PATCH 58/93] Be consistent --- .../semconv/db/DbClientAttributesExtractorTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index e6a7e51ae50a..5bea5d906abe 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -38,8 +38,8 @@ public String getUser(Map map) { return map.get("db.user"); } - @Nullable @Override + @Nullable public String getDbNamespace(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); @@ -51,15 +51,15 @@ public String getConnectionString(Map map) { return map.get("db.connection_string"); } - @Nullable @Override + @Nullable public String getDbQueryText(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); } - @Nullable @Override + @Nullable public String getDbOperationName(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.operation")).getKey()); From aba9d32e57359158df69b729ee56151bd45261ff Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 2 Oct 2024 13:44:31 -0700 Subject: [PATCH 59/93] Reduce the number of unnecessary diffs --- .../semconv/db/DbClientAttributesExtractorTest.java | 5 ----- .../semconv/db/SqlClientAttributesExtractorTest.java | 2 -- .../cassandra/v3_0/CassandraSingletons.java | 1 + .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 5 +++-- .../instrumentation/cassandra/v4_0/CassandraRequest.java | 4 ++-- .../cassandra/v4_0/CassandraSingletons.java | 1 + .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 5 +++-- .../instrumentation/cassandra/v4_4/CassandraRequest.java | 4 ++-- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 3 ++- .../clickhouse/ClickHouseAttributesGetter.java | 1 + .../couchbase/v2_0/CouchbaseAttributesGetter.java | 6 +++--- .../rest/internal/ElasticsearchDbAttributesGetter.java | 8 ++++---- .../transport/ElasticsearchTransportAttributesGetter.java | 4 ++-- .../instrumentation/geode/GeodeDbAttributesGetter.java | 6 +++--- .../influxdb/v2_4/InfluxDbAttributesGetter.java | 2 +- .../instrumentation/jdbc/internal/DbRequest.java | 4 ++-- .../jdbc/internal/JdbcAttributesGetter.java | 1 + .../jedis/v1_4/JedisDbAttributesGetter.java | 2 -- .../jedis/v3_0/JedisDbAttributesGetter.java | 3 --- .../jedis/v4_0/JedisDbAttributesGetter.java | 5 +---- .../lettuce/v4_0/LettuceDbAttributesGetter.java | 8 ++++---- .../lettuce/v5_0/LettuceDbAttributesGetter.java | 2 -- .../mongo/v3_1/MongoDbAttributesGetter.java | 5 ++--- .../opensearch/rest/OpenSearchRestAttributesGetter.java | 7 ++++--- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 +- .../redisson/RedissonDbAttributesGetter.java | 6 +++--- .../v4_0/redis/VertxRedisClientAttributesGetter.java | 3 +-- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 4 ++-- 28 files changed, 49 insertions(+), 60 deletions(-) diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index 5bea5d906abe..1038b4431802 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -25,8 +25,6 @@ class DbClientAttributesExtractorTest { static final class TestAttributesGetter implements DbClientAttributesGetter> { - - @Nullable @Override public String getDbSystem(Map map) { return map.get("db.system"); @@ -39,7 +37,6 @@ public String getUser(Map map) { } @Override - @Nullable public String getDbNamespace(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); @@ -52,14 +49,12 @@ public String getConnectionString(Map map) { } @Override - @Nullable public String getDbQueryText(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); } @Override - @Nullable public String getDbOperationName(Map map) { return map.get( SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.operation")).getKey()); 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 25d841cbf0ca..23371052453e 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 @@ -33,7 +33,6 @@ public String getRawQueryText(Map map) { SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); } - @Nullable @Override public String getDbSystem(Map map) { return map.get("db.system"); @@ -45,7 +44,6 @@ public String getUser(Map map) { return map.get("db.user"); } - @Nullable @Override public String getDbNamespace(Map map) { return map.get( 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 6a1bf1d236f1..30195c29eb08 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 @@ -25,6 +25,7 @@ public final class CassandraSingletons { static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); + INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 587dab7c9b93..29dae436b93b 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -12,7 +12,7 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { @Override - public String getDbSystem(CassandraRequest cassandraRequest) { + public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } @@ -23,8 +23,8 @@ public String getUser(CassandraRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(CassandraRequest request) { return request.getSession().getLoggedKeyspace(); } @@ -37,6 +37,7 @@ public String getConnectionString(CassandraRequest request) { } @Override + @Nullable public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index 508015dbdf5c..757fddae55fc 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -11,8 +11,8 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String dbQueryText) { - return new AutoValue_CassandraRequest(session, dbQueryText); + public static CassandraRequest create(Session session, String queryText) { + return new AutoValue_CassandraRequest(session, queryText); } public abstract Session getSession(); 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 0c1c4bb2084d..4be45307ba18 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 @@ -24,6 +24,7 @@ public final class CassandraSingletons { static { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); + INSTRUMENTER = Instrumenter.builder( GlobalOpenTelemetry.get(), diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 5602cb35f41a..b177c5e679bd 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -13,7 +13,7 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { @Override - public String getDbSystem(CassandraRequest cassandraRequest) { + public String getSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } @@ -24,8 +24,8 @@ public String getUser(CassandraRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } @@ -38,6 +38,7 @@ public String getConnectionString(CassandraRequest request) { } @Override + @Nullable public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index 5b58311b917a..591f3bce9996 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -11,8 +11,8 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String dbQueryText) { - return new AutoValue_CassandraRequest(session, dbQueryText); + public static CassandraRequest create(Session session, String queryText) { + return new AutoValue_CassandraRequest(session, queryText); } public abstract Session getSession(); diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 0f9df94c9b36..8813c8b66043 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -25,8 +25,8 @@ public String getUser(CassandraRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(CassandraRequest request) { return request.getSession().getKeyspace().map(CqlIdentifier::toString).orElse(null); } @@ -39,6 +39,7 @@ public String getConnectionString(CassandraRequest request) { } @Override + @Nullable public String getRawQueryText(CassandraRequest request) { return request.getDbQueryText(); } diff --git a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java index ff0f487cd7b5..61d48d89020e 100644 --- a/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java +++ b/instrumentation/clickhouse-client-0.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/clickhouse/ClickHouseAttributesGetter.java @@ -29,6 +29,7 @@ public String getDbOperationName(ClickHouseDbRequest request) { return request.getSqlStatementInfo().getOperation(); } + @Nullable @Override public String getDbSystem(ClickHouseDbRequest request) { return DbIncubatingAttributes.DbSystemValues.CLICKHOUSE; diff --git a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java index 1e42c857a47e..c9415e2b84fa 100644 --- a/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java +++ b/instrumentation/couchbase/couchbase-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_0/CouchbaseAttributesGetter.java @@ -23,8 +23,8 @@ public String getUser(CouchbaseRequestInfo couchbaseRequest) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.bucket(); } @@ -36,14 +36,14 @@ public String getConnectionString(CouchbaseRequestInfo couchbaseRequest) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.statement(); } - @Nullable @Override + @Nullable public String getDbOperationName(CouchbaseRequestInfo couchbaseRequest) { return couchbaseRequest.operation(); } 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 d0ffc3db22a5..3bef587f1fe0 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 @@ -37,7 +37,7 @@ final class ElasticsearchDbAttributesGetter } @Override - public String getDbSystem(ElasticsearchRestRequest elasticsearchRestRequest) { + public String getDbSystem(ElasticsearchRestRequest request) { return ELASTICSEARCH; } @@ -48,8 +48,8 @@ public String getUser(ElasticsearchRestRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(ElasticsearchRestRequest request) { return null; } @@ -61,8 +61,8 @@ public String getConnectionString(ElasticsearchRestRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(ElasticsearchRestRequest request) { ElasticsearchEndpointDefinition epDefinition = request.getEndpointDefinition(); HttpEntity httpEntity = request.getHttpEntity(); @@ -85,8 +85,8 @@ public String getDbQueryText(ElasticsearchRestRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbOperationName(ElasticsearchRestRequest request) { ElasticsearchEndpointDefinition endpointDefinition = request.getEndpointDefinition(); return endpointDefinition != null ? endpointDefinition.getEndpointName() : null; 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 73cfad1b1be0..ae3568b17064 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 @@ -25,8 +25,8 @@ public String getUser(ElasticTransportRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(ElasticTransportRequest request) { return null; } @@ -38,8 +38,8 @@ public String getConnectionString(ElasticTransportRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(ElasticTransportRequest request) { return null; } diff --git a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java index 8c863c8374f2..fe689b4e5866 100644 --- a/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java +++ b/instrumentation/geode-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/geode/GeodeDbAttributesGetter.java @@ -29,8 +29,8 @@ public String getUser(GeodeRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(GeodeRequest request) { return request.getRegion().getName(); } @@ -42,15 +42,15 @@ public String getConnectionString(GeodeRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(GeodeRequest request) { // sanitized statement is cached return sanitizer.sanitize(request.getQuery()).getFullStatement(); } - @Nullable @Override + @Nullable public String getDbOperationName(GeodeRequest request) { return request.getOperation(); } diff --git a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java index d084bfbbc0d1..39460c14a135 100644 --- a/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java +++ b/instrumentation/influxdb-2.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/influxdb/v2_4/InfluxDbAttributesGetter.java @@ -26,7 +26,7 @@ public String getDbOperationName(InfluxDbRequest request) { } @Override - public String getDbSystem(InfluxDbRequest influxDbRequest) { + public String getDbSystem(InfluxDbRequest request) { return "influxdb"; } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index cc9c3b0b9b9b..9f5cdeab098d 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -37,8 +37,8 @@ public static DbRequest create(Statement statement, String dbStatementString) { return create(extractDbInfo(connection), dbStatementString); } - public static DbRequest create(DbInfo dbInfo, String dbQueryText) { - return new AutoValue_DbRequest(dbInfo, dbQueryText); + public static DbRequest create(DbInfo dbInfo, String queryText) { + return new AutoValue_DbRequest(dbInfo, queryText); } public abstract DbInfo getDbInfo(); 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 3589bd7f57f1..1e7b2ad500dd 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 @@ -42,6 +42,7 @@ public String getConnectionString(DbRequest request) { return request.getDbInfo().getShortUrl(); } + @Nullable @Override public String getRawQueryText(DbRequest request) { return request.getDbQueryText(); diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 8def0e715326..2bf03774ada2 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -29,7 +29,6 @@ public String getUser(JedisRequest request) { return null; } - @Nullable @Override public String getDbNamespace(JedisRequest request) { return null; @@ -41,7 +40,6 @@ public String getConnectionString(JedisRequest request) { return null; } - @Nullable @Override public String getDbQueryText(JedisRequest request) { return sanitizer.sanitize(request.getCommand().name(), request.getArgs()); diff --git a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java index f69bb9edd3aa..4c5d797ffcd7 100644 --- a/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v3_0/JedisDbAttributesGetter.java @@ -24,7 +24,6 @@ public String getUser(JedisRequest request) { return null; } - @Nullable @Override public String getDbNamespace(JedisRequest request) { return null; @@ -36,13 +35,11 @@ public String getConnectionString(JedisRequest request) { return null; } - @Nullable @Override public String getDbQueryText(JedisRequest request) { return request.getStatement(); } - @Nullable @Override public String getDbOperationName(JedisRequest request) { return request.getOperation(); diff --git a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java index 0d9f0a1edd92..ea55630f4703 100644 --- a/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v4_0/JedisDbAttributesGetter.java @@ -13,7 +13,7 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter { @Override - public String getDbSystem(JedisRequest jedisRequest) { + public String getDbSystem(JedisRequest request) { return REDIS; } @@ -24,7 +24,6 @@ public String getUser(JedisRequest request) { return null; } - @Nullable @Override public String getDbNamespace(JedisRequest request) { return null; @@ -36,13 +35,11 @@ public String getConnectionString(JedisRequest request) { return null; } - @Nullable @Override public String getDbQueryText(JedisRequest request) { return request.getStatement(); } - @Nullable @Override public String getDbOperationName(JedisRequest request) { return request.getOperation(); diff --git a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java index a09001b8d0ac..67366fd15d0a 100644 --- a/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceDbAttributesGetter.java @@ -14,7 +14,7 @@ final class LettuceDbAttributesGetter implements DbClientAttributesGetter> { @Override - public String getDbSystem(RedisCommand redisCommand) { + public String getDbSystem(RedisCommand request) { return REDIS; } @@ -25,8 +25,8 @@ public String getUser(RedisCommand request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(RedisCommand request) { return null; } @@ -38,14 +38,14 @@ public String getConnectionString(RedisCommand request) { return null; } - @Nullable @Override + @Nullable public String getDbQueryText(RedisCommand request) { return null; } - @Nullable @Override + @Nullable public String getDbOperationName(RedisCommand request) { return request.getType().name(); } diff --git a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java index c79459c56a3e..9c77abe32330 100644 --- a/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java +++ b/instrumentation/lettuce/lettuce-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/lettuce/v5_0/LettuceDbAttributesGetter.java @@ -47,7 +47,6 @@ public String getConnectionString(RedisCommand request) { } @Override - @Nullable public String getDbQueryText(RedisCommand request) { String command = LettuceInstrumentationUtil.getCommandName(request); List args = @@ -58,7 +57,6 @@ public String getDbQueryText(RedisCommand request) { } @Override - @Nullable public String getDbOperationName(RedisCommand request) { return request.getType().name(); } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 3dac156b9303..4c6f25062f35 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -61,8 +61,8 @@ public String getUser(CommandStartedEvent event) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(CommandStartedEvent event) { return event.getDatabaseName(); } @@ -86,14 +86,13 @@ public String getConnectionString(CommandStartedEvent event) { return null; } - @Nullable @Override public String getDbQueryText(CommandStartedEvent event) { return sanitizeStatement(event.getCommand()); } - @Nullable @Override + @Nullable public String getDbOperationName(CommandStartedEvent event) { return event.getCommandName(); } 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 05c5dfe387b4..6ab1fa3d0f6b 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 @@ -14,7 +14,7 @@ final class OpenSearchRestAttributesGetter implements DbClientAttributesGetter { @Override - public String getDbSystem(OpenSearchRestRequest openSearchRestRequest) { + public String getDbSystem(OpenSearchRestRequest request) { return OPENSEARCH; } @@ -25,8 +25,8 @@ public String getUser(OpenSearchRestRequest request) { return null; } - @Nullable @Override + @Nullable public String getDbNamespace(OpenSearchRestRequest openSearchRestRequest) { return null; } @@ -39,12 +39,13 @@ public String getConnectionString(OpenSearchRestRequest request) { } @Override + @Nullable public String getDbQueryText(OpenSearchRestRequest request) { return request.getMethod() + " " + request.getOperation(); } - @Nullable @Override + @Nullable public String getDbOperationName(OpenSearchRestRequest request) { return request.getMethod(); } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index afc143261b89..640dd3f17f2c 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -16,7 +16,6 @@ public enum R2dbcSqlAttributesGetter implements SqlClientAttributesGetter { INSTANCE; - @Nullable @Override public String getDbSystem(VertxSqlClientRequest request) { return null; @@ -25,8 +24,8 @@ public String getUser(VertxSqlClientRequest request) { return request.getUser(); } - @Nullable @Override + @Nullable public String getDbNamespace(VertxSqlClientRequest request) { return request.getDatabase(); } @@ -39,6 +38,7 @@ public String getConnectionString(VertxSqlClientRequest request) { } @Override + @Nullable public String getRawQueryText(VertxSqlClientRequest request) { return request.getDbQueryText(); } From da55c3b5f7e40ad70039902b024e89a526ed44ca Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 2 Oct 2024 13:54:14 -0700 Subject: [PATCH 60/93] spotless --- .../incubator/semconv/db/DbClientAttributesExtractorTest.java | 1 - .../incubator/semconv/db/SqlClientAttributesExtractorTest.java | 1 - 2 files changed, 2 deletions(-) diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index 1038b4431802..214a7f67c31d 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nullable; import org.junit.jupiter.api.Test; class DbClientAttributesExtractorTest { 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 23371052453e..272395f86c68 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 @@ -19,7 +19,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.annotation.Nullable; import org.junit.jupiter.api.Test; class SqlClientAttributesExtractorTest { From 3b2da5b8f2cec8d006c522e6405e6fa7fd0dbb4d Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Wed, 2 Oct 2024 14:35:31 -0700 Subject: [PATCH 61/93] oops --- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 29dae436b93b..07d3ea2075b9 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -12,7 +12,7 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { @Override - public String getSystem(CassandraRequest request) { + public String getDbSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index b177c5e679bd..8b3167e084c8 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -13,7 +13,7 @@ final class CassandraSqlAttributesGetter implements SqlClientAttributesGetter { @Override - public String getSystem(CassandraRequest request) { + public String getDbSystem(CassandraRequest request) { return DbIncubatingAttributes.DbSystemValues.CASSANDRA; } From 41eded3513e89a1bf431cc0ed6b9568e3f7d8e88 Mon Sep 17 00:00:00 2001 From: heyams Date: Wed, 2 Oct 2024 15:55:15 -0700 Subject: [PATCH 62/93] Rename --- .../instrumentation/cassandra/v3_0/CassandraRequest.java | 2 +- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 +- .../instrumentation/cassandra/v4_0/CassandraRequest.java | 2 +- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 +- .../instrumentation/cassandra/v4_4/CassandraRequest.java | 2 +- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 +- .../opentelemetry/instrumentation/jdbc/internal/DbRequest.java | 2 +- .../instrumentation/jdbc/internal/JdbcAttributesGetter.java | 2 +- .../instrumentation/r2dbc/v1_0/internal/DbExecution.java | 2 +- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 +- .../instrumentation/r2dbc/v1_0/DbExecutionTest.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 2 +- .../instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index d2fb21a77de4..48a3f5102711 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String dbQueryText) { public abstract Session getSession(); - public abstract String getDbQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 07d3ea2075b9..77471abd7148 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -39,6 +39,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index 757fddae55fc..e4160bb80495 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getDbQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 8b3167e084c8..044e0be23600 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -40,6 +40,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index 591f3bce9996..426321e146df 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getDbQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 8813c8b66043..02efa5c5b426 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -41,6 +41,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index 9f5cdeab098d..f1360d9b1cac 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -43,5 +43,5 @@ public static DbRequest create(DbInfo dbInfo, String queryText) { public abstract DbInfo getDbInfo(); - public abstract String getDbQueryText(); + public abstract String getQueryText(); } 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 1e7b2ad500dd..b5623f4d99ce 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 @@ -45,6 +45,6 @@ public String getConnectionString(DbRequest request) { @Nullable @Override public String getRawQueryText(DbRequest request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java index c78a33e1dc80..0b5d4578d92a 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/DbExecution.java @@ -94,7 +94,7 @@ public String getConnectionString() { return connectionString; } - public String getDbQueryText() { + public String getQueryText() { return rawStatement; } diff --git a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java index 640dd3f17f2c..8fcc3a015479 100644 --- a/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java +++ b/instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java @@ -43,6 +43,6 @@ public String getConnectionString(DbExecution request) { @Override @Nullable public String getRawQueryText(DbExecution request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java b/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java index 8bbe82db7f16..6e3cbf977220 100644 --- a/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java +++ b/instrumentation/r2dbc-1.0/library/src/test/java/io/opentelemetry/instrumentation/r2dbc/v1_0/DbExecutionTest.java @@ -45,6 +45,6 @@ void dbExecution() { assertEquals("localhost", dbExecution.getHost()); assertEquals(3306, dbExecution.getPort()); assertEquals("mariadb://localhost:3306", dbExecution.getConnectionString()); - assertEquals("SELECT * from person where last_name = 'tom'", dbExecution.getDbQueryText()); + assertEquals("SELECT * from person where last_name = 'tom'", dbExecution.getQueryText()); } } 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 975dec54a4c8..92c27b4ddb19 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 @@ -40,6 +40,6 @@ public String getConnectionString(VertxSqlClientRequest request) { @Override @Nullable public String getRawQueryText(VertxSqlClientRequest request) { - return request.getDbQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java index 9ae5d6019aff..d316219c6763 100644 --- a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java +++ b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java @@ -16,7 +16,7 @@ public VertxSqlClientRequest(String statement, SqlConnectOptions sqlConnectOptio this.sqlConnectOptions = sqlConnectOptions; } - public String getDbQueryText() { + public String getQueryText() { return statement; } From 618b7ae12152748f06ff842fba7af3a9bc43dc10 Mon Sep 17 00:00:00 2001 From: heyams Date: Thu, 3 Oct 2024 10:37:09 -0700 Subject: [PATCH 63/93] Comments --- .../cassandra/v3_0/CassandraRequest.java | 2 +- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4/common/AbstractCassandraTest.java | 4 ++++ .../cassandra/v4_0/CassandraRequest.java | 2 +- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_4/CassandraRequest.java | 2 +- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_4/CassandraTelemetryBuilder.java | 9 +++++++-- .../cassandra/v4_4/AbstractCassandra44Test.java | 2 ++ .../ElasticsearchTransportAttributesGetter.java | 2 +- .../instrumentation/jdbc/internal/DbRequest.java | 2 +- .../jdbc/internal/JdbcAttributesGetter.java | 2 +- .../jedis/v1_4/JedisDbAttributesGetter.java | 2 +- .../jedis/v3_0/JedisDbAttributesGetter.java | 2 +- .../mongo/v3_1/MongoDbAttributesGetter.java | 2 +- .../rest/OpenSearchRestAttributesGetter.java | 2 +- .../r2dbc/v1_0/internal/DbExecution.java | 10 +++++----- .../r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java | 2 +- .../instrumentation/r2dbc/v1_0/DbExecutionTest.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientRequest.java | 10 +++++----- 21 files changed, 39 insertions(+), 28 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index 48a3f5102711..1f1d2fe7aca6 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String dbQueryText) { public abstract Session getSession(); - public abstract String getQueryText(); + public abstract String getRawQueryText(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index 77471abd7148..cb807d8e7865 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -39,6 +39,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getQueryText(); + return request.getRawQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index e7739b873af9..dcd8812328cc 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -108,6 +108,8 @@ void syncTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); + } else { + assertThat(val).isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), @@ -173,6 +175,8 @@ void asyncTest(Parameter parameter) throws Exception { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); + } else { + assertThat(val).isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index e4160bb80495..a23d755a3a06 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getQueryText(); + public abstract String getRawQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index 044e0be23600..f29d9c649ab9 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -40,6 +40,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getQueryText(); + return request.getRawQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index 426321e146df..bc7e35b69134 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getQueryText(); + public abstract String getRawQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 02efa5c5b426..625dfb4f0ea1 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -41,6 +41,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getQueryText(); + return request.getRawQueryText(); } } 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 ad9156555dcd..12b9f02bf29f 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 @@ -20,6 +20,11 @@ public class CassandraTelemetryBuilder { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.4"; + // copied from DbIncubatingAttributes + private static final AttributeKey DB_CASSANDRA_TABLE = + AttributeKey.stringKey("db.cassandra.table"); + private static final AttributeKey DB_COLLECTION_NAME = + AttributeKey.stringKey("db.collection.name"); private final OpenTelemetry openTelemetry; @@ -58,8 +63,8 @@ protected Instrumenter createInstrumenter( SqlClientAttributesExtractor.builder(attributesGetter) .setTableAttribute( SemconvStability.emitStableDatabaseSemconv() - ? AttributeKey.stringKey("db.collection.name") - : AttributeKey.stringKey("db.cassandra.table")) + ? DB_COLLECTION_NAME + : DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index c08b809f7492..0f7f21d1f198 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -68,6 +68,8 @@ void reactiveTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); + } else { + assertThat(val).isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), 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 ae3568b17064..0f5d6a71834d 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 @@ -14,7 +14,7 @@ final class ElasticsearchTransportAttributesGetter implements DbClientAttributesGetter { @Override - public String getDbSystem(ElasticTransportRequest elasticTransportRequest) { + public String getDbSystem(ElasticTransportRequest request) { return ELASTICSEARCH; } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index f1360d9b1cac..cace791f3387 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -43,5 +43,5 @@ public static DbRequest create(DbInfo dbInfo, String queryText) { public abstract DbInfo getDbInfo(); - public abstract String getQueryText(); + public abstract String getRawQueryText(); } 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..2e64485b0410 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 @@ -45,6 +45,6 @@ public String getConnectionString(DbRequest request) { @Nullable @Override public String getRawQueryText(DbRequest request) { - return request.getQueryText(); + return request.getRawQueryText(); } } diff --git a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java index 2bf03774ada2..9bb47d51e8cb 100644 --- a/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java +++ b/instrumentation/jedis/jedis-1.4/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/jedis/v1_4/JedisDbAttributesGetter.java @@ -18,7 +18,7 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter { @Override - public String getDbSystem(JedisRequest jedisRequest) { + public String getDbSystem(JedisRequest request) { return REDIS; } diff --git a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java index 4c6f25062f35..58d9f4fcba45 100644 --- a/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java +++ b/instrumentation/mongo/mongo-3.1/library/src/main/java/io/opentelemetry/instrumentation/mongo/v3_1/MongoDbAttributesGetter.java @@ -50,7 +50,7 @@ class MongoDbAttributesGetter implements DbClientAttributesGetter Date: Thu, 3 Oct 2024 13:35:30 -0700 Subject: [PATCH 64/93] Fix --- .../cassandra/v4/common/AbstractCassandraTest.java | 6 ++++-- .../testing/cassandra/v4_4/AbstractCassandra44Test.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index dcd8812328cc..c5681ab7cad0 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -108,7 +108,8 @@ void syncTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } else { + } + if (SemconvStability.emitStableDatabaseSemconv()) { assertThat(val).isNull(); } }), @@ -175,7 +176,8 @@ void asyncTest(Parameter parameter) throws Exception { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } else { + } + if (SemconvStability.emitStableDatabaseSemconv()) { assertThat(val).isNull(); } }), diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 0f7f21d1f198..3914669308ce 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -68,7 +68,8 @@ void reactiveTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } else { + } + if (SemconvStability.emitStableDatabaseSemconv()) { assertThat(val).isNull(); } }), From 1005ef91a9cc94f8bbfbb0a98c2ad8d824d3771e Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:25:49 -0700 Subject: [PATCH 65/93] Update instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java --- .../instrumentation/cassandra/v3_0/CassandraRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index 1f1d2fe7aca6..000c396bd758 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -11,8 +11,8 @@ @AutoValue public abstract class CassandraRequest { - public static CassandraRequest create(Session session, String dbQueryText) { - return new AutoValue_CassandraRequest(session, dbQueryText); + public static CassandraRequest create(Session session, String queryText) { + return new AutoValue_CassandraRequest(session, queryText); } public abstract Session getSession(); From 23511d774ecc4f5b19c199448eddf9a2042dc02a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:31:20 -0700 Subject: [PATCH 66/93] Reduce unnecessary diffs --- .../cassandra/v3_0/CassandraRequest.java | 2 +- .../cassandra/v3_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_0/CassandraRequest.java | 2 +- .../cassandra/v4_0/CassandraSqlAttributesGetter.java | 2 +- .../cassandra/v4_4/CassandraRequest.java | 2 +- .../cassandra/v4_4/CassandraSqlAttributesGetter.java | 2 +- .../instrumentation/jdbc/internal/DbRequest.java | 2 +- .../jdbc/internal/JdbcAttributesGetter.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientAttributesGetter.java | 2 +- .../vertx/v4_0/sql/VertxSqlClientRequest.java | 10 +++++----- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java index 000c396bd758..0463ce3aa3f5 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getRawQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java index cb807d8e7865..77471abd7148 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java @@ -39,6 +39,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getRawQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java index a23d755a3a06..e4160bb80495 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getRawQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java index f29d9c649ab9..044e0be23600 100644 --- a/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java @@ -40,6 +40,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getRawQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java index bc7e35b69134..426321e146df 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java @@ -17,5 +17,5 @@ public static CassandraRequest create(Session session, String queryText) { public abstract Session getSession(); - public abstract String getRawQueryText(); + public abstract String getQueryText(); } diff --git a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java index 625dfb4f0ea1..02efa5c5b426 100644 --- a/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java +++ b/instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java @@ -41,6 +41,6 @@ public String getConnectionString(CassandraRequest request) { @Override @Nullable public String getRawQueryText(CassandraRequest request) { - return request.getRawQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java index cace791f3387..f1360d9b1cac 100644 --- a/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java +++ b/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/DbRequest.java @@ -43,5 +43,5 @@ public static DbRequest create(DbInfo dbInfo, String queryText) { public abstract DbInfo getDbInfo(); - public abstract String getRawQueryText(); + public abstract String getQueryText(); } 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 2e64485b0410..b5623f4d99ce 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 @@ -45,6 +45,6 @@ public String getConnectionString(DbRequest request) { @Nullable @Override public String getRawQueryText(DbRequest request) { - return request.getRawQueryText(); + return request.getQueryText(); } } 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 6e2d6dbe670f..92c27b4ddb19 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 @@ -40,6 +40,6 @@ public String getConnectionString(VertxSqlClientRequest request) { @Override @Nullable public String getRawQueryText(VertxSqlClientRequest request) { - return request.getRawQueryText(); + return request.getQueryText(); } } diff --git a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java index e47b08ad84f5..6355fd3f6e24 100644 --- a/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java +++ b/instrumentation/vertx/vertx-sql-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/sql/VertxSqlClientRequest.java @@ -8,16 +8,16 @@ import io.vertx.sqlclient.SqlConnectOptions; public final class VertxSqlClientRequest { - private final String rawQueryText; + private final String queryText; private final SqlConnectOptions sqlConnectOptions; - public VertxSqlClientRequest(String rawQueryText, SqlConnectOptions sqlConnectOptions) { - this.rawQueryText = rawQueryText; + public VertxSqlClientRequest(String queryText, SqlConnectOptions sqlConnectOptions) { + this.queryText = queryText; this.sqlConnectOptions = sqlConnectOptions; } - public String getRawQueryText() { - return rawQueryText; + public String getQueryText() { + return queryText; } public String getUser() { From a17b1d214eed2360ae4d29f592591a7ad2297530 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:39:55 -0700 Subject: [PATCH 67/93] Capture db.namespace in the db attributes getter --- .../v4_0/redis/VertxRedisClientAttributesExtractor.java | 6 ------ .../vertx/v4_0/redis/VertxRedisClientAttributesGetter.java | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java index 7553309750d0..882799efa7da 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java @@ -19,15 +19,9 @@ enum VertxRedisClientAttributesExtractor implements AttributesExtractor { INSTANCE; - private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); - @Override public void onStart( AttributesBuilder attributes, Context parentContext, VertxRedisClientRequest request) { - if (SemconvStability.emitStableDatabaseSemconv()) { - attributes.put(DB_NAMESPACE, String.valueOf(request.getDatabaseIndex())); - } - if (SemconvStability.emitOldDatabaseSemconv()) { internalSet( attributes, DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, request.getDatabaseIndex()); diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 9b156226819b..5804901a81e2 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -34,7 +34,7 @@ public String getUser(VertxRedisClientRequest request) { @Override @Nullable public String getDbNamespace(VertxRedisClientRequest request) { - return null; + return String.valueOf(request.getDatabaseIndex()); } @Deprecated From 76e277be1c5d5789c034ee487c05a002368e5b1a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:53:30 -0700 Subject: [PATCH 68/93] Reduce diffs --- .../db/DbClientAttributesExtractorTest.java | 28 +++++---------- .../db/SqlClientAttributesExtractorTest.java | 34 +++++-------------- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index 214a7f67c31d..e5185964e432 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -8,12 +8,10 @@ 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.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; @@ -37,8 +35,7 @@ public String getUser(Map map) { @Override public String getDbNamespace(Map map) { - return map.get( - SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); + return map.get("db.name"); } @Deprecated @@ -49,14 +46,12 @@ public String getConnectionString(Map map) { @Override public String getDbQueryText(Map map) { - return map.get( - SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); + return map.get("db.statement"); } @Override public String getDbOperationName(Map map) { - return map.get( - SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.operation")).getKey()); + return map.get("db.operation"); } } @@ -66,18 +61,11 @@ void shouldExtractAllAvailableAttributes() { // given Map request = new HashMap<>(); request.put("db.system", "myDb"); - if (SemconvStability.emitOldDatabaseSemconv()) { - request.put("db.user", "username"); - request.put("db.connection_string", "mydb:///potatoes"); - } - request.put( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME).getKey(), "potatoes"); - request.put( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT).getKey(), - "SELECT * FROM potato"); - request.put( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION).getKey(), - "SELECT"); + request.put("db.user", "username"); + request.put("db.name", "potatoes"); + request.put("db.connection_string", "mydb:///potatoes"); + request.put("db.statement", "SELECT * FROM potato"); + request.put("db.operation", "SELECT"); Context context = Context.root(); 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 272395f86c68..2ca674692de0 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 @@ -8,7 +8,6 @@ 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; @@ -28,8 +27,7 @@ static final class TestAttributesGetter @Override public String getRawQueryText(Map map) { - return map.get( - SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.statement")).getKey()); + return map.get("db.statement"); } @Override @@ -45,8 +43,7 @@ public String getUser(Map map) { @Override public String getDbNamespace(Map map) { - return map.get( - SemconvStabilityUtil.getAttributeKey(AttributeKey.stringKey("db.name")).getKey()); + return map.get("db.name"); } @Deprecated @@ -62,15 +59,10 @@ void shouldExtractAllAttributes() { // given Map request = new HashMap<>(); request.put("db.system", "myDb"); - if (SemconvStability.emitOldDatabaseSemconv()) { - request.put("db.user", "username"); - request.put("db.connection_string", "mydb:///potatoes"); - request.put("db.name", "potatoes"); - request.put("db.statement", "SELECT * FROM potato WHERE id=12345"); - } else if (SemconvStability.emitStableDatabaseSemconv()) { - request.put("db.namespace", "potatoes"); - request.put("db.query.text", "SELECT * FROM potato WHERE id=12345"); - } + request.put("db.user", "username"); + request.put("db.name", "potatoes"); + request.put("db.connection_string", "mydb:///potatoes"); + request.put("db.statement", "SELECT * FROM potato WHERE id=12345"); Context context = Context.root(); @@ -119,11 +111,7 @@ void shouldExtractAllAttributes() { void shouldNotExtractTableIfAttributeIsNotSet() { // given Map request = new HashMap<>(); - if (SemconvStability.emitOldDatabaseSemconv()) { - request.put("db.statement", "SELECT *"); - } else { - request.put("db.query.text", "SELECT *"); - } + request.put("db.statement", "SELECT *"); Context context = Context.root(); @@ -149,13 +137,7 @@ void shouldNotExtractTableIfAttributeIsNotSet() { void shouldExtractTableToSpecifiedKey() { // given Map request = new HashMap<>(); - if (SemconvStability.emitOldDatabaseSemconv()) { - request.put("db.statement", "SELECT * FROM table"); - } - - if (SemconvStability.emitStableDatabaseSemconv()) { - request.put("db.query.text", "SELECT * FROM table"); - } + request.put("db.statement", "SELECT * FROM table"); Context context = Context.root(); From 98d20fc105078babce5f14fe2247590a83d5021a Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:55:44 -0700 Subject: [PATCH 69/93] Remove incorrect mapping --- .../instrumentation/testing/junit/db/SemconvStabilityUtil.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index 4dc3d62f1e2a..5a8b0650c5a1 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -10,7 +10,6 @@ import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_MONGODB_COLLECTION; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_NAME; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION; -import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SQL_TABLE; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT; @@ -23,7 +22,6 @@ public class SemconvStabilityUtil { private static final Map, AttributeKey> oldToNewMap = new HashMap<>(); private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); - private static final AttributeKey DB_NAMESPACE_LONG = AttributeKey.longKey("db.namespace"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); private static final AttributeKey DB_OPERATION_NAME = AttributeKey.stringKey("db.operation.name"); @@ -32,7 +30,6 @@ public class SemconvStabilityUtil { static { addKey(oldToNewMap, DB_NAME, DB_NAMESPACE); - addKey(oldToNewMap, DB_REDIS_DATABASE_INDEX, DB_NAMESPACE_LONG); addKey(oldToNewMap, DB_STATEMENT, DB_QUERY_TEXT); addKey(oldToNewMap, DB_OPERATION, DB_OPERATION_NAME); addKey(oldToNewMap, DB_SQL_TABLE, DB_COLLECTION_NAME); From 535b06f0102acf5c2ce2adb64dc35ee7ea5facb7 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 14:59:20 -0700 Subject: [PATCH 70/93] spotless --- .../vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java index 882799efa7da..27ad3fe69b1f 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesExtractor.java @@ -7,7 +7,6 @@ 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; From b7a2f1de5e0dcce4e61a064349ae26886cdbfe00 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 15:33:37 -0700 Subject: [PATCH 71/93] fixup! Capture db.namespace in the db attributes getter --- .../vertx/v4_0/redis/VertxRedisClientAttributesGetter.java | 6 +++++- .../vertx/v4_0/redis/VertxRedisClientSingletons.java | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java index 5804901a81e2..aa80a65d20fa 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientAttributesGetter.java @@ -9,6 +9,7 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesGetter; import io.opentelemetry.instrumentation.api.incubator.semconv.db.RedisCommandSanitizer; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import javax.annotation.Nullable; @@ -34,7 +35,10 @@ public String getUser(VertxRedisClientRequest request) { @Override @Nullable public String getDbNamespace(VertxRedisClientRequest request) { - return String.valueOf(request.getDatabaseIndex()); + if (SemconvStability.emitStableDatabaseSemconv()) { + return String.valueOf(request.getDatabaseIndex()); + } + return null; } @Deprecated diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java index b5164522897c..c2ecc7b8fd9c 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java @@ -9,7 +9,6 @@ import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientAttributesExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.net.PeerServiceAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; @@ -37,7 +36,7 @@ public final class VertxRedisClientSingletons { static { SpanNameExtractor spanNameExtractor = - DbClientSpanNameExtractor.create(VertxRedisClientAttributesGetter.INSTANCE); + VertxRedisClientRequest::getCommand; InstrumenterBuilder builder = Instrumenter.builder( From e610e5af2127bfaae3a442080177c431e4113dfb Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 15:44:52 -0700 Subject: [PATCH 72/93] test stable semconv --- .../javaagent/build.gradle.kts | 8 +++++ .../v4_0/redis/VertxRedisClientTest.java | 35 +++++++++++++------ 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts index 748df2ab83cf..0199413110d6 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts @@ -24,4 +24,12 @@ tasks { withType().configureEach { usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service) } + + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + check { + dependsOn(testStableSemconv) + } } diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java index 69add7333329..cf09494088a2 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java @@ -8,9 +8,11 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; import static org.assertj.core.api.Assertions.assertThat; +import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; @@ -200,15 +202,28 @@ void commandWithNoArguments() throws Exception { } private static AttributeAssertion[] redisSpanAttributes(String operation, String statement) { - return new AttributeAssertion[] { - equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, statement), - equalTo(DbIncubatingAttributes.DB_OPERATION, operation), - equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1), - equalTo(ServerAttributes.SERVER_ADDRESS, host), - equalTo(ServerAttributes.SERVER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) - }; + if (SemconvStabilityUtil.isStable()) { + return new AttributeAssertion[] { + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo(AttributeKey.stringKey("db.query.text"), statement), + equalTo(AttributeKey.stringKey("db.operation.name"), operation), + equalTo(AttributeKey.stringKey("db.namespace"), "1"), + equalTo(ServerAttributes.SERVER_ADDRESS, host), + equalTo(ServerAttributes.SERVER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) + }; + } else { + return new AttributeAssertion[] { + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo(DbIncubatingAttributes.DB_STATEMENT, statement), + equalTo(DbIncubatingAttributes.DB_OPERATION, operation), + equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1), + equalTo(ServerAttributes.SERVER_ADDRESS, host), + equalTo(ServerAttributes.SERVER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) + }; + } } } From 96904fcafc2d28ef7f0b8f62771fd21e5992f960 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 15:57:01 -0700 Subject: [PATCH 73/93] spotless --- .../v4_0/redis/VertxRedisClientTest.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java index cf09494088a2..c0275eda1917 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java @@ -204,25 +204,25 @@ void commandWithNoArguments() throws Exception { private static AttributeAssertion[] redisSpanAttributes(String operation, String statement) { if (SemconvStabilityUtil.isStable()) { return new AttributeAssertion[] { - equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(AttributeKey.stringKey("db.query.text"), statement), - equalTo(AttributeKey.stringKey("db.operation.name"), operation), - equalTo(AttributeKey.stringKey("db.namespace"), "1"), - equalTo(ServerAttributes.SERVER_ADDRESS, host), - equalTo(ServerAttributes.SERVER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo(AttributeKey.stringKey("db.query.text"), statement), + equalTo(AttributeKey.stringKey("db.operation.name"), operation), + equalTo(AttributeKey.stringKey("db.namespace"), "1"), + equalTo(ServerAttributes.SERVER_ADDRESS, host), + equalTo(ServerAttributes.SERVER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) }; } else { return new AttributeAssertion[] { - equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo(DbIncubatingAttributes.DB_STATEMENT, statement), - equalTo(DbIncubatingAttributes.DB_OPERATION, operation), - equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1), - equalTo(ServerAttributes.SERVER_ADDRESS, host), - equalTo(ServerAttributes.SERVER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo(DbIncubatingAttributes.DB_STATEMENT, statement), + equalTo(DbIncubatingAttributes.DB_OPERATION, operation), + equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1), + equalTo(ServerAttributes.SERVER_ADDRESS, host), + equalTo(ServerAttributes.SERVER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, port), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip) }; } } From 30bb3100a528c2113a241788f5b07f4c355d1490 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Thu, 3 Oct 2024 18:05:44 -0700 Subject: [PATCH 74/93] Emit both db.collection.name and db.sql.table under database/dup --- .../db/SqlClientAttributesExtractor.java | 15 +++++++++++---- .../SqlClientAttributesExtractorBuilder.java | 18 +++++++----------- .../db/SqlClientAttributesExtractorTest.java | 4 ++-- .../cassandra/v3_0/CassandraSingletons.java | 9 +++------ .../cassandra/v4_0/CassandraSingletons.java | 9 +++------ .../v4_4/CassandraTelemetryBuilder.java | 9 ++------- 6 files changed, 28 insertions(+), 36 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java index 3d47de17ad79..fc5f29efe81b 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java @@ -33,6 +33,8 @@ public final class SqlClientAttributesExtractor AttributeKey.stringKey("db.operation.name"); private static final AttributeKey DB_STATEMENT = AttributeKey.stringKey("db.statement"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); + private static final AttributeKey DB_COLLECTION_NAME = + AttributeKey.stringKey("db.collection.name"); /** Creates the SQL client attributes extractor with default configuration. */ public static AttributesExtractor create( @@ -53,15 +55,15 @@ public static SqlClientAttributesExtractorBuilder dbTableAttribute; + private final AttributeKey oldSemconvTableAttribute; private final boolean statementSanitizationEnabled; SqlClientAttributesExtractor( SqlClientAttributesGetter getter, - AttributeKey dbTableAttribute, + AttributeKey oldSemconvTableAttribute, boolean statementSanitizationEnabled) { super(getter); - this.dbTableAttribute = dbTableAttribute; + this.oldSemconvTableAttribute = oldSemconvTableAttribute; this.statementSanitizationEnabled = statementSanitizationEnabled; } @@ -87,7 +89,12 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST internalSet(attributes, DB_OPERATION, operation); } if (!SQL_CALL.equals(operation)) { - internalSet(attributes, dbTableAttribute, sanitizedStatement.getMainIdentifier()); + if (SemconvStability.emitStableDatabaseSemconv()) { + internalSet(attributes, DB_COLLECTION_NAME, sanitizedStatement.getMainIdentifier()); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + internalSet(attributes, oldSemconvTableAttribute, sanitizedStatement.getMainIdentifier()); + } } } } diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java index 3e172e3d288e..e8ec48084345 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java @@ -18,7 +18,7 @@ public final class SqlClientAttributesExtractorBuilder { private static final AttributeKey DB_SQL_TABLE = AttributeKey.stringKey("db.sql.table"); final SqlClientAttributesGetter getter; - AttributeKey dbTableAttribute = DB_SQL_TABLE; + AttributeKey oldSemconvTableAttribute = DB_SQL_TABLE; boolean statementSanitizationEnabled = true; SqlClientAttributesExtractorBuilder(SqlClientAttributesGetter getter) { @@ -26,17 +26,13 @@ public final class SqlClientAttributesExtractorBuilder { } /** - * Configures the extractor to set the table value extracted by the {@link - * SqlClientAttributesExtractor} under the {@code dbTableAttribute} key. By default, the - * db.sql.table attribute is used. - * - * @param dbTableAttribute The {@link AttributeKey} under which the table extracted by the {@link - * SqlClientAttributesExtractor} will be stored. + * @deprecated not needed anymore since the new semantic conventions always use db.collection.name */ @CanIgnoreReturnValue - public SqlClientAttributesExtractorBuilder setTableAttribute( - AttributeKey dbTableAttribute) { - this.dbTableAttribute = requireNonNull(dbTableAttribute); + @Deprecated + public SqlClientAttributesExtractorBuilder setOldSemconvTableAttribute( + AttributeKey oldSemconvTableAttribute) { + this.oldSemconvTableAttribute = requireNonNull(oldSemconvTableAttribute); return this; } @@ -58,6 +54,6 @@ public SqlClientAttributesExtractorBuilder setStatementSaniti */ public AttributesExtractor build() { return new SqlClientAttributesExtractor<>( - getter, dbTableAttribute, statementSanitizationEnabled); + getter, oldSemconvTableAttribute, statementSanitizationEnabled); } } 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 2ca674692de0..d9323feef864 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 @@ -134,6 +134,7 @@ void shouldNotExtractTableIfAttributeIsNotSet() { } @Test + @SuppressWarnings("deprecation") // to support old database semantic conventions void shouldExtractTableToSpecifiedKey() { // given Map request = new HashMap<>(); @@ -143,8 +144,7 @@ void shouldExtractTableToSpecifiedKey() { AttributesExtractor, Void> underTest = SqlClientAttributesExtractor., Void>builder(new TestAttributesGetter()) - .setTableAttribute( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE)) + .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .build(); // when 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 30195c29eb08..ccea6f13087a 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 @@ -7,15 +7,15 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; +import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; +@SuppressWarnings("deprecation") // to support old database semantic conventions public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-3.0"; @@ -33,10 +33,7 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute( - SemconvStability.emitStableDatabaseSemconv() - ? AttributeKey.stringKey("db.collection.name") - : AttributeKey.stringKey("db.cassandra.table")) + .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 4be45307ba18..188a02c20d83 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 @@ -7,15 +7,15 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; -import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; +import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; +@SuppressWarnings("deprecation") // to support old database semantic conventions public final class CassandraSingletons { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.cassandra-4.0"; @@ -32,10 +32,7 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute( - SemconvStability.emitStableDatabaseSemconv() - ? AttributeKey.stringKey("db.collection.name") - : AttributeKey.stringKey("db.cassandra.table")) + .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 12b9f02bf29f..cb9ab979d26e 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 @@ -13,7 +13,6 @@ import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; /** A builder of {@link CassandraTelemetry}. */ @@ -23,8 +22,6 @@ public class CassandraTelemetryBuilder { // copied from DbIncubatingAttributes private static final AttributeKey DB_CASSANDRA_TABLE = AttributeKey.stringKey("db.cassandra.table"); - private static final AttributeKey DB_COLLECTION_NAME = - AttributeKey.stringKey("db.collection.name"); private final OpenTelemetry openTelemetry; @@ -53,6 +50,7 @@ public CassandraTelemetry build() { return new CassandraTelemetry(createInstrumenter(openTelemetry, statementSanitizationEnabled)); } + @SuppressWarnings("deprecation") // to support old database semantic conventions protected Instrumenter createInstrumenter( OpenTelemetry openTelemetry, boolean statementSanitizationEnabled) { CassandraSqlAttributesGetter attributesGetter = new CassandraSqlAttributesGetter(); @@ -61,10 +59,7 @@ protected Instrumenter createInstrumenter( openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setTableAttribute( - SemconvStability.emitStableDatabaseSemconv() - ? DB_COLLECTION_NAME - : DB_CASSANDRA_TABLE) + .setOldSemconvTableAttribute(DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( From e691bd28f3605fc3bbed92f0d6fe91c255b0fea2 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 4 Oct 2024 11:25:57 -0700 Subject: [PATCH 75/93] database/dup tests aren't running and fixes --- .../build.gradle.kts | 46 ++------- .../db/DbClientAttributesExtractorTest.java | 44 ++++++--- .../db/SqlClientAttributesExtractorTest.java | 94 ++++++++++++------- 3 files changed, 102 insertions(+), 82 deletions(-) diff --git a/instrumentation-api-incubator/build.gradle.kts b/instrumentation-api-incubator/build.gradle.kts index 846dd96908c5..81c90c90748d 100644 --- a/instrumentation-api-incubator/build.gradle.kts +++ b/instrumentation-api-incubator/build.gradle.kts @@ -24,41 +24,6 @@ dependencies { testImplementation("io.opentelemetry.semconv:opentelemetry-semconv-incubating") } -testing { - suites { - val testStableDatabaseSemconv by registering(JvmTestSuite::class) { - dependencies { - implementation(project()) - implementation(project(":testing-common")) - implementation("io.opentelemetry:opentelemetry-sdk") - implementation("io.opentelemetry:opentelemetry-sdk-testing") - } - targets { - all { - testTask.configure { - jvmArgs("-Dotel.semconv-stability.opt-in=database") - } - } - } - } - val testBothDatabaseSemconv by registering(JvmTestSuite::class) { - dependencies { - implementation(project()) - implementation(project(":testing-common")) - implementation("io.opentelemetry:opentelemetry-sdk") - implementation("io.opentelemetry:opentelemetry-sdk-testing") - } - targets { - all { - testTask.configure { - jvmArgs("-Dotel.semconv-stability.opt-in=database/dup") - } - } - } - } - } -} - tasks { // exclude auto-generated code named("checkstyleMain") { @@ -76,7 +41,16 @@ tasks { dependsOn("generateJflex") } + val testStableSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database") + } + + val testBothSemconv by registering(Test::class) { + jvmArgs("-Dotel.semconv-stability.opt-in=database/dup") + } + check { - dependsOn(testing.suites) + dependsOn(testStableSemconv) + dependsOn(testBothSemconv) } } diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java index e5185964e432..4836a85e359c 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java @@ -8,11 +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.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.HashMap; @@ -80,18 +81,35 @@ void shouldExtractAllAvailableAttributes() { underTest.onEnd(endAttributes, context, request, null, null); // then - assertThat(startAttributes.build()) - .containsOnly( - entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), - entry(DbIncubatingAttributes.DB_USER, "username"), - entry(SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), - entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM potato"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT")); + if (SemconvStability.emitStableDatabaseSemconv() && SemconvStability.emitOldDatabaseSemconv()) { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry(DbIncubatingAttributes.DB_USER, "username"), + entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(AttributeKey.stringKey("db.namespace"), "potatoes"), + entry(AttributeKey.stringKey("db.query.text"), "SELECT * FROM potato"), + entry(AttributeKey.stringKey("db.operation.name"), "SELECT")); + } else if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry(DbIncubatingAttributes.DB_USER, "username"), + entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); + } else if (SemconvStability.emitStableDatabaseSemconv()) { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry(AttributeKey.stringKey("db.namespace"), "potatoes"), + entry(AttributeKey.stringKey("db.query.text"), "SELECT * FROM potato"), + entry(AttributeKey.stringKey("db.operation.name"), "SELECT")); + } assertThat(endAttributes.build().isEmpty()).isTrue(); } 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 d9323feef864..d343d92c9b64 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 @@ -5,6 +5,7 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.db; +import static io.opentelemetry.api.common.AttributeKey.stringKey; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static org.assertj.core.api.Assertions.entry; @@ -13,7 +14,6 @@ import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; import io.opentelemetry.instrumentation.api.internal.SemconvStability; -import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; import java.util.Collections; import java.util.HashMap; @@ -77,7 +77,21 @@ void shouldExtractAllAttributes() { underTest.onEnd(endAttributes, context, request, null, null); // then - if (SemconvStability.emitOldDatabaseSemconv()) { + if (SemconvStability.emitStableDatabaseSemconv() && SemconvStability.emitOldDatabaseSemconv()) { + assertThat(startAttributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), + entry(DbIncubatingAttributes.DB_USER, "username"), + entry(DbIncubatingAttributes.DB_NAME, "potatoes"), + entry(DbIncubatingAttributes.DB_CONNECTION_STRING, "mydb:///potatoes"), + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(DbIncubatingAttributes.DB_SQL_TABLE, "potato"), + entry(stringKey("db.namespace"), "potatoes"), + entry(stringKey("db.query.text"), "SELECT * FROM potato WHERE id=?"), + entry(stringKey("db.operation.name"), "SELECT"), + entry(stringKey("db.collection.name"), "potato")); + } else if (SemconvStability.emitOldDatabaseSemconv()) { assertThat(startAttributes.build()) .containsOnly( entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), @@ -87,21 +101,14 @@ void shouldExtractAllAttributes() { entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM potato WHERE id=?"), entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), entry(DbIncubatingAttributes.DB_SQL_TABLE, "potato")); - } else { + } else if (SemconvStability.emitStableDatabaseSemconv()) { assertThat(startAttributes.build()) .containsOnly( entry(DbIncubatingAttributes.DB_SYSTEM, "myDb"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_NAME), "potatoes"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM potato WHERE id=?"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_SQL_TABLE), - "potato")); + entry(stringKey("db.namespace"), "potatoes"), + entry(stringKey("db.query.text"), "SELECT * FROM potato WHERE id=?"), + entry(stringKey("db.operation.name"), "SELECT"), + entry(stringKey("db.collection.name"), "potato")); } assertThat(endAttributes.build().isEmpty()).isTrue(); @@ -123,14 +130,24 @@ void shouldNotExtractTableIfAttributeIsNotSet() { underTest.onStart(attributes, context, request); // then - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT *"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT")); + if (SemconvStability.emitStableDatabaseSemconv() && SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(stringKey("db.query.text"), "SELECT *"), + entry(stringKey("db.operation.name"), "SELECT")); + } else if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT *"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT")); + } else if (SemconvStability.emitStableDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(stringKey("db.query.text"), "SELECT *"), + entry(stringKey("db.operation.name"), "SELECT")); + } } @Test @@ -152,17 +169,28 @@ void shouldExtractTableToSpecifiedKey() { underTest.onStart(attributes, context, request); // then - assertThat(attributes.build()) - .containsOnly( - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_STATEMENT), - "SELECT * FROM table"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_OPERATION), - "SELECT"), - entry( - SemconvStabilityUtil.getAttributeKey(DbIncubatingAttributes.DB_CASSANDRA_TABLE), - "table")); + if (SemconvStability.emitStableDatabaseSemconv() && SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table"), + entry(stringKey("db.query.text"), "SELECT * FROM table"), + entry(stringKey("db.operation.name"), "SELECT"), + entry(stringKey("db.collection.name"), "table")); + } else if (SemconvStability.emitOldDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(DbIncubatingAttributes.DB_STATEMENT, "SELECT * FROM table"), + entry(DbIncubatingAttributes.DB_OPERATION, "SELECT"), + entry(DbIncubatingAttributes.DB_CASSANDRA_TABLE, "table")); + } else if (SemconvStability.emitStableDatabaseSemconv()) { + assertThat(attributes.build()) + .containsOnly( + entry(stringKey("db.query.text"), "SELECT * FROM table"), + entry(stringKey("db.operation.name"), "SELECT"), + entry(stringKey("db.collection.name"), "table")); + } } @Test From 10ca2ea76170b7210d604ed4af735d84d8df8e7f Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 4 Oct 2024 11:29:30 -0700 Subject: [PATCH 76/93] comment --- .../vertx/v4_0/redis/VertxRedisClientSingletons.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java index c2ecc7b8fd9c..64d1942e99e8 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientSingletons.java @@ -35,6 +35,8 @@ public final class VertxRedisClientSingletons { VirtualField.find(RedisStandaloneConnection.class, RedisURI.class); static { + // Redis semantic conventions don't follow the regular pattern of adding the db.namespace to + // the span name SpanNameExtractor spanNameExtractor = VertxRedisClientRequest::getCommand; From b774178377d033d598b725623645aac04d263a4c Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Fri, 4 Oct 2024 11:34:49 -0700 Subject: [PATCH 77/93] simplify --- .../vertx/v4_0/redis/VertxRedisClientTest.java | 4 +++- .../testing/junit/db/SemconvStabilityUtil.java | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java index c0275eda1917..95b62039d1e4 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java @@ -10,6 +10,7 @@ import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -202,7 +203,8 @@ void commandWithNoArguments() throws Exception { } private static AttributeAssertion[] redisSpanAttributes(String operation, String statement) { - if (SemconvStabilityUtil.isStable()) { + // not testing database/dup + if (SemconvStability.emitStableDatabaseSemconv()) { return new AttributeAssertion[] { equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), equalTo(AttributeKey.stringKey("db.query.text"), statement), diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index 5a8b0650c5a1..c6a0c613d92b 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -47,13 +47,10 @@ private static void addKey( @SuppressWarnings("unchecked") public static AttributeKey getAttributeKey(AttributeKey oldKey) { - if (isStable()) { + // not testing database/dup + if (SemconvStability.emitStableDatabaseSemconv()) { return (AttributeKey) oldToNewMap.get(oldKey); } return oldKey; } - - public static boolean isStable() { - return SemconvStability.emitStableDatabaseSemconv(); - } } From 6eea8fe71ccb914cc4e19fcaa1d6f568f5a46a13 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:04:15 -0700 Subject: [PATCH 78/93] spotless --- .../instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java index 95b62039d1e4..2139666e16ee 100644 --- a/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java +++ b/instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java @@ -13,7 +13,6 @@ import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; -import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.semconv.NetworkAttributes; import io.opentelemetry.semconv.ServerAttributes; From c08e617814bff7a394874cc313e92719b6c68d43 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:16:38 -0700 Subject: [PATCH 79/93] Remove network attributes not present in stable semconv --- .../db/DbNetworkAttributesExtractor.java | 71 +++++++++++++++ .../semconv/db/DbNetworkAttributesGetter.java | 89 +++++++++++++++++++ .../CassandraNetworkAttributesGetter.java | 4 +- .../cassandra/v3_0/CassandraSingletons.java | 4 +- .../CassandraNetworkAttributesGetter.java | 4 +- .../cassandra/v4_0/CassandraSingletons.java | 4 +- .../CassandraNetworkAttributesGetter.java | 4 +- .../v4_4/CassandraTelemetryBuilder.java | 4 +- 8 files changed, 172 insertions(+), 12 deletions(-) create mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java create mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java new file mode 100644 index 000000000000..22c6e73f780c --- /dev/null +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java @@ -0,0 +1,71 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.incubator.semconv.db; + +import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; + +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.context.Context; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import io.opentelemetry.semconv.NetworkAttributes; +import javax.annotation.Nullable; + +/** + * Extractor of network + * attributes. + */ +public final class DbNetworkAttributesExtractor + implements AttributesExtractor { + + /** + * Creates the network attributes extractor. + * + * @see InstrumenterBuilder#addAttributesExtractor(AttributesExtractor) + */ + public static DbNetworkAttributesExtractor create( + DbNetworkAttributesGetter getter) { + return new DbNetworkAttributesExtractor<>(getter); + } + + private final DbNetworkAttributesGetter getter; + + DbNetworkAttributesExtractor(DbNetworkAttributesGetter getter) { + this.getter = getter; + } + + @Override + public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {} + + @Override + @SuppressWarnings("deprecation") // to support old database semantic conventions + public void onEnd( + AttributesBuilder attributes, + Context context, + REQUEST request, + @Nullable RESPONSE response, + @Nullable Throwable error) { + + if (SemconvStability.emitOldDatabaseSemconv()) { + String networkType = getter.getNetworkType(request, response); + if (networkType != null) { + internalSet(attributes, NetworkAttributes.NETWORK_TYPE, networkType); + } + } + + String peerAddress = getter.getNetworkPeerAddress(request, response); + if (peerAddress != null) { + internalSet(attributes, NetworkAttributes.NETWORK_PEER_ADDRESS, peerAddress); + + Integer peerPort = getter.getNetworkPeerPort(request, response); + if (peerPort != null && peerPort > 0) { + internalSet(attributes, NetworkAttributes.NETWORK_PEER_PORT, (long) peerPort); + } + } + } +} diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java new file mode 100644 index 000000000000..ea887b47efdf --- /dev/null +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java @@ -0,0 +1,89 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.api.incubator.semconv.db; + +import io.opentelemetry.instrumentation.api.semconv.network.internal.InetSocketAddressUtil; +import java.net.Inet4Address; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import javax.annotation.Nullable; + +/** + * An interface for getting database network attributes. + * + *

Instrumentation authors will create implementations of this interface for their specific + * library/framework. It will be used by the {@link DbNetworkAttributesExtractor} (or other convention + * specific extractors) to obtain the various database network attributes in a type-generic way. + */ +public interface DbNetworkAttributesGetter { + + /** + * Returns the OSI network layer or non-OSI + * equivalent. + * + *

Examples: {@code ipv4}, {@code ipv6} + */ + @Deprecated + @Nullable + default String getNetworkType(REQUEST request, @Nullable RESPONSE response) { + InetSocketAddress address = getNetworkPeerInetSocketAddress(request, response); + if (address == null) { + return null; + } + InetAddress remoteAddress = address.getAddress(); + if (remoteAddress instanceof Inet4Address) { + return "ipv4"; + } else if (remoteAddress instanceof Inet6Address) { + return "ipv6"; + } + return null; + } + + /** + * Returns an {@link InetSocketAddress} object representing the peer socket address. + * + *

Implementing this method is equivalent to implementing both {@link + * #getNetworkPeerAddress(Object, Object)} and {@link #getNetworkPeerPort(Object, Object)}. + */ + @Nullable + default InetSocketAddress getNetworkPeerInetSocketAddress( + REQUEST request, @Nullable RESPONSE response) { + return null; + } + + /** + * Returns the peer address of the network connection - IP address or Unix domain socket name. + * + *

Examples: {@code 10.1.2.80}, {@code /tmp/my.sock} + * + *

By default, this method attempts to retrieve the peer address using the {@link + * #getNetworkPeerInetSocketAddress(Object, Object)} method. If that method is not implemented, it + * will simply return {@code null}. If the instrumented library does not expose {@link + * InetSocketAddress} in its API, you might want to implement this method instead of {@link + * #getNetworkPeerInetSocketAddress(Object, Object)}. + */ + @Nullable + default String getNetworkPeerAddress(REQUEST request, @Nullable RESPONSE response) { + return InetSocketAddressUtil.getIpAddress(getNetworkPeerInetSocketAddress(request, response)); + } + + /** + * Returns the peer port number of the network connection. + * + *

Examples: {@code 65123} + * + *

By default, this method attempts to retrieve the peer port using the {@link + * #getNetworkPeerInetSocketAddress(Object, Object)} method. If that method is not implemented, it + * will simply return {@code null}. If the instrumented library does not expose {@link + * InetSocketAddress} in its API, you might want to implement this method instead of {@link + * #getNetworkPeerInetSocketAddress(Object, Object)}. + */ + @Nullable + default Integer getNetworkPeerPort(REQUEST request, @Nullable RESPONSE response) { + return InetSocketAddressUtil.getPort(getNetworkPeerInetSocketAddress(request, response)); + } +} 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 5e6f41fecdee..8afa015c13ad 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,12 +6,12 @@ package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0; import com.datastax.driver.core.ExecutionInfo; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements NetworkAttributesGetter { + implements DbNetworkAttributesGetter { @Override @Nullable 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 ccea6f13087a..03cf6315da32 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 @@ -8,10 +8,10 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -38,7 +38,7 @@ public final class CassandraSingletons { AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + DbNetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .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 44ed4e1e851d..2d9350753fae 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,13 +7,13 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import com.datastax.oss.driver.api.core.metadata.Node; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements NetworkAttributesGetter { + implements DbNetworkAttributesGetter { @Override @Nullable 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 188a02c20d83..7304fa4413ce 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 @@ -8,10 +8,10 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -37,7 +37,7 @@ public final class CassandraSingletons { AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + DbNetworkAttributesExtractor.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 532dcb0646f6..1d54cd8966c4 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 @@ -9,12 +9,12 @@ import com.datastax.oss.driver.api.core.metadata.EndPoint; import com.datastax.oss.driver.api.core.metadata.Node; import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements NetworkAttributesGetter { + implements DbNetworkAttributesGetter { @Override @Nullable 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 cb9ab979d26e..6cac237d4858 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 @@ -10,10 +10,10 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; -import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; /** A builder of {@link CassandraTelemetry}. */ public class CassandraTelemetryBuilder { @@ -63,7 +63,7 @@ protected Instrumenter createInstrumenter( .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( - NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + DbNetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } From 043f4f9f754eddeba645d4b34c0d83f036745226 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:32:26 -0700 Subject: [PATCH 80/93] Simplify test --- .../src/test/java/CassandraClientTest.java | 37 ++++--------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 664d668d8e50..261a0a0a9964 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -10,6 +10,7 @@ import com.datastax.driver.core.ResultSetFuture; import com.datastax.driver.core.Session; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -96,11 +97,7 @@ void syncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -119,11 +116,7 @@ void syncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -156,11 +149,7 @@ void syncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -210,11 +199,7 @@ void asyncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -234,11 +219,7 @@ void asyncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -276,11 +257,7 @@ void asyncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), From 48fd7ef5b08a52b7f01386ec309ee04a698c70cf Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:33:26 -0700 Subject: [PATCH 81/93] Handle database/dup --- .../cassandra/v4/common/AbstractCassandraTest.java | 6 ++---- .../testing/cassandra/v4_4/AbstractCassandra44Test.java | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index c5681ab7cad0..dcd8812328cc 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -108,8 +108,7 @@ void syncTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } - if (SemconvStability.emitStableDatabaseSemconv()) { + } else { assertThat(val).isNull(); } }), @@ -176,8 +175,7 @@ void asyncTest(Parameter parameter) throws Exception { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } - if (SemconvStability.emitStableDatabaseSemconv()) { + } else { assertThat(val).isNull(); } }), diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 3914669308ce..0f7f21d1f198 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -68,8 +68,7 @@ void reactiveTest(Parameter parameter) { val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); - } - if (SemconvStability.emitStableDatabaseSemconv()) { + } else { assertThat(val).isNull(); } }), From d327900b7bd7e3f78689ee3895de54217f8e8df6 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:41:22 -0700 Subject: [PATCH 82/93] Simplify test --- .../AbstractRedissonAsyncClientTest.java | 32 +++------ .../redisson/AbstractRedissonClientTest.java | 71 ++++--------------- 2 files changed, 25 insertions(+), 78 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 78a207a087bf..366d59a75a7f 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -14,6 +14,7 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -118,10 +119,7 @@ void futureSet() throws ExecutionException, InterruptedException, TimeoutExcepti .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -146,7 +144,8 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo return future.whenComplete( (res, throwable) -> { assertThat(Span.current().getSpanContext().isValid()).isTrue(); - testing.runWithSpan("callback", () -> {}); + testing.runWithSpan("callback", () -> { + }); }); }); result.toCompletableFuture().get(30, TimeUnit.SECONDS); @@ -162,10 +161,7 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -231,7 +227,8 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo return batchResultFuture.whenComplete( (res, throwable) -> { assertThat(Span.current().getSpanContext().isValid()).isTrue(); - testing.runWithSpan("callback", () -> {}); + testing.runWithSpan("callback", () -> { + }); }); }); result.toCompletableFuture().get(30, TimeUnit.SECONDS); @@ -247,10 +244,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -265,10 +259,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -287,10 +278,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index ad945760a4be..1f9f1e4205cb 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -14,6 +14,7 @@ import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -121,10 +122,7 @@ void stringCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -144,10 +142,7 @@ void stringCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -181,10 +176,7 @@ void batchCommand() .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -229,10 +221,7 @@ void atomicBatchCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -247,10 +236,7 @@ void atomicBatchCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -269,10 +255,7 @@ void atomicBatchCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -302,10 +285,7 @@ void listCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -338,10 +318,7 @@ void hashCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -361,10 +338,7 @@ void hashCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -393,10 +367,7 @@ void setCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -433,10 +404,7 @@ void sortedSetCommand() .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -470,10 +438,7 @@ void atomicLongCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -507,10 +472,7 @@ void lockCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -531,10 +493,7 @@ void lockCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey(NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), From 996d150685cc09d950618e4d70876b36ea002817 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:43:33 -0700 Subject: [PATCH 83/93] spotless --- .../api/incubator/semconv/db/DbNetworkAttributesGetter.java | 5 +++-- .../redisson/AbstractRedissonAsyncClientTest.java | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java index ea887b47efdf..a1e60d8e9356 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java @@ -16,8 +16,9 @@ * An interface for getting database network attributes. * *

Instrumentation authors will create implementations of this interface for their specific - * library/framework. It will be used by the {@link DbNetworkAttributesExtractor} (or other convention - * specific extractors) to obtain the various database network attributes in a type-generic way. + * library/framework. It will be used by the {@link DbNetworkAttributesExtractor} (or other + * convention specific extractors) to obtain the various database network attributes in a + * type-generic way. */ public interface DbNetworkAttributesGetter { diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 366d59a75a7f..4e7ad08a54ee 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -144,8 +144,7 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo return future.whenComplete( (res, throwable) -> { assertThat(Span.current().getSpanContext().isValid()).isTrue(); - testing.runWithSpan("callback", () -> { - }); + testing.runWithSpan("callback", () -> {}); }); }); result.toCompletableFuture().get(30, TimeUnit.SECONDS); @@ -227,8 +226,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo return batchResultFuture.whenComplete( (res, throwable) -> { assertThat(Span.current().getSpanContext().isValid()).isTrue(); - testing.runWithSpan("callback", () -> { - }); + testing.runWithSpan("callback", () -> {}); }); }); result.toCompletableFuture().get(30, TimeUnit.SECONDS); From 151019b160c194996ffb10f135147f617c592eca Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:50:29 -0700 Subject: [PATCH 84/93] Remove unnecessary diff --- .../redisson/AbstractRedissonClientTest.java | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 1f9f1e4205cb..7fc212e4edce 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -361,25 +361,24 @@ void setCommand() { orderByRootSpanKind(SpanKind.INTERNAL, SpanKind.CLIENT), trace -> trace.hasSpansSatisfyingExactly( - span -> { - span.hasName("SADD") - .hasKind(CLIENT) - .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), - equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), - equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), - equalTo( - SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_STATEMENT), - "SADD set1 ?"), - equalTo( - SemconvStabilityUtil.getAttributeKey( - DbIncubatingAttributes.DB_OPERATION), - "SADD")); - })); + span -> + span.hasName("SADD") + .hasKind(CLIENT) + .hasAttributesSatisfyingExactly( + equalTo( + NetworkAttributes.NETWORK_TYPE, + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), + equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), + equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_STATEMENT), + "SADD set1 ?"), + equalTo( + SemconvStabilityUtil.getAttributeKey( + DbIncubatingAttributes.DB_OPERATION), + "SADD")))); } @Test From 8717d51f5bffa2aa50ea727d79f4c834369b2537 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 6 Oct 2024 09:51:43 -0700 Subject: [PATCH 85/93] simplify --- .../redisson/AbstractRedissonClientTest.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 7fc212e4edce..08b812294481 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -514,11 +514,7 @@ void lockCommand() { .hasAttributesSatisfyingExactly( equalTo( NetworkAttributes.NETWORK_TYPE, - SemconvStabilityUtil.getAttributeKey( - NetworkAttributes.NETWORK_TYPE) - == null - ? null - : "ipv4"), + SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), From ed8133f26cf8225cd78ec76ff57de707e32f01bd Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 7 Oct 2024 08:32:01 -0700 Subject: [PATCH 86/93] Fix stable semconv assertion --- .../cassandra/v4/common/AbstractCassandraTest.java | 4 ++-- .../testing/cassandra/v4_4/AbstractCassandra44Test.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index dcd8812328cc..a01bcff5890d 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -109,7 +109,7 @@ void syncTest(Parameter parameter) { v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); } else { - assertThat(val).isNull(); + val.isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), @@ -176,7 +176,7 @@ void asyncTest(Parameter parameter) throws Exception { v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); } else { - assertThat(val).isNull(); + val.isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 0f7f21d1f198..1ee13c6836b4 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -69,7 +69,7 @@ void reactiveTest(Parameter parameter) { v -> assertThat(v).isEqualTo("ipv4"), v -> assertThat(v).isEqualTo("ipv6")); } else { - assertThat(val).isNull(); + val.isNull(); } }), equalTo(SERVER_ADDRESS, cassandraHost), From 038fbeca3ab33789d43e8ede2b37a0e08c4138a2 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 27 Oct 2024 11:13:54 -0700 Subject: [PATCH 87/93] Remove jvm arg from module with no tests --- .../cassandra-4-common/testing/build.gradle.kts | 10 ---------- .../couchbase-2-common/javaagent/build.gradle.kts | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts b/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts index 342baa7fd736..8147a0167158 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts +++ b/instrumentation/cassandra/cassandra-4-common/testing/build.gradle.kts @@ -8,13 +8,3 @@ dependencies { implementation("org.testcontainers:testcontainers") implementation("com.datastax.oss:java-driver-core:4.0.0") } - -tasks { - val testStableSemconv by registering(Test::class) { - jvmArgs("-Dotel.semconv-stability.opt-in=database") - } - - check { - dependsOn(testStableSemconv) - } -} diff --git a/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts b/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts index 864031dbd062..afe601decbdc 100644 --- a/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts +++ b/instrumentation/couchbase/couchbase-2-common/javaagent/build.gradle.kts @@ -6,13 +6,3 @@ dependencies { compileOnly("com.google.auto.value:auto-value-annotations") annotationProcessor("com.google.auto.value:auto-value") } - -tasks { - val testStableSemconv by registering(Test::class) { - jvmArgs("-Dotel.semconv-stability.opt-in=database") - } - - check { - dependsOn(testStableSemconv) - } -} From d580bbad0814bca35f230a1e1dab9643979ff621 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 27 Oct 2024 20:03:21 -0700 Subject: [PATCH 88/93] not general network conventions --- .../InternalNetworkAttributesExtractor.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java index 08ae9f47db22..7d0cb9eea012 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/semconv/network/internal/InternalNetworkAttributesExtractor.java @@ -8,7 +8,6 @@ import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; import io.opentelemetry.semconv.NetworkAttributes; import java.util.Locale; @@ -39,13 +38,11 @@ public void onEnd(AttributesBuilder attributes, REQUEST request, @Nullable RESPO if (captureProtocolAttributes) { String transport = lowercase(getter.getNetworkTransport(request, response)); - if (SemconvStability.emitOldDatabaseSemconv()) { - internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport); - internalSet( - attributes, - NetworkAttributes.NETWORK_TYPE, - lowercase(getter.getNetworkType(request, response))); - } + internalSet(attributes, NetworkAttributes.NETWORK_TRANSPORT, transport); + internalSet( + attributes, + NetworkAttributes.NETWORK_TYPE, + lowercase(getter.getNetworkType(request, response))); internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_NAME, protocolName); internalSet(attributes, NetworkAttributes.NETWORK_PROTOCOL_VERSION, protocolVersion); } From 9e34fe1efd4af75df6ce645b080f3cbfd2e8d0a3 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 27 Oct 2024 20:31:45 -0700 Subject: [PATCH 89/93] revert a bit, will implement differently later --- .../db/DbNetworkAttributesExtractor.java | 71 --------------- .../semconv/db/DbNetworkAttributesGetter.java | 90 ------------------- .../CassandraNetworkAttributesGetter.java | 4 +- .../cassandra/v3_0/CassandraSingletons.java | 4 +- .../src/test/java/CassandraClientTest.java | 25 ++---- .../CassandraNetworkAttributesGetter.java | 4 +- .../cassandra/v4_0/CassandraSingletons.java | 4 +- .../CassandraNetworkAttributesGetter.java | 4 +- .../v4_4/CassandraTelemetryBuilder.java | 4 +- .../AbstractRedissonAsyncClientTest.java | 21 ++--- .../redisson/AbstractRedissonClientTest.java | 61 ++++--------- 11 files changed, 38 insertions(+), 254 deletions(-) delete mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java delete mode 100644 instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java deleted file mode 100644 index 22c6e73f780c..000000000000 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesExtractor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.incubator.semconv.db; - -import static io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil.internalSet; - -import io.opentelemetry.api.common.AttributesBuilder; -import io.opentelemetry.context.Context; -import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; -import io.opentelemetry.instrumentation.api.instrumenter.InstrumenterBuilder; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; -import io.opentelemetry.semconv.NetworkAttributes; -import javax.annotation.Nullable; - -/** - * Extractor of network - * attributes. - */ -public final class DbNetworkAttributesExtractor - implements AttributesExtractor { - - /** - * Creates the network attributes extractor. - * - * @see InstrumenterBuilder#addAttributesExtractor(AttributesExtractor) - */ - public static DbNetworkAttributesExtractor create( - DbNetworkAttributesGetter getter) { - return new DbNetworkAttributesExtractor<>(getter); - } - - private final DbNetworkAttributesGetter getter; - - DbNetworkAttributesExtractor(DbNetworkAttributesGetter getter) { - this.getter = getter; - } - - @Override - public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {} - - @Override - @SuppressWarnings("deprecation") // to support old database semantic conventions - public void onEnd( - AttributesBuilder attributes, - Context context, - REQUEST request, - @Nullable RESPONSE response, - @Nullable Throwable error) { - - if (SemconvStability.emitOldDatabaseSemconv()) { - String networkType = getter.getNetworkType(request, response); - if (networkType != null) { - internalSet(attributes, NetworkAttributes.NETWORK_TYPE, networkType); - } - } - - String peerAddress = getter.getNetworkPeerAddress(request, response); - if (peerAddress != null) { - internalSet(attributes, NetworkAttributes.NETWORK_PEER_ADDRESS, peerAddress); - - Integer peerPort = getter.getNetworkPeerPort(request, response); - if (peerPort != null && peerPort > 0) { - internalSet(attributes, NetworkAttributes.NETWORK_PEER_PORT, (long) peerPort); - } - } - } -} diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java deleted file mode 100644 index a1e60d8e9356..000000000000 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbNetworkAttributesGetter.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright The OpenTelemetry Authors - * SPDX-License-Identifier: Apache-2.0 - */ - -package io.opentelemetry.instrumentation.api.incubator.semconv.db; - -import io.opentelemetry.instrumentation.api.semconv.network.internal.InetSocketAddressUtil; -import java.net.Inet4Address; -import java.net.Inet6Address; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import javax.annotation.Nullable; - -/** - * An interface for getting database network attributes. - * - *

Instrumentation authors will create implementations of this interface for their specific - * library/framework. It will be used by the {@link DbNetworkAttributesExtractor} (or other - * convention specific extractors) to obtain the various database network attributes in a - * type-generic way. - */ -public interface DbNetworkAttributesGetter { - - /** - * Returns the OSI network layer or non-OSI - * equivalent. - * - *

Examples: {@code ipv4}, {@code ipv6} - */ - @Deprecated - @Nullable - default String getNetworkType(REQUEST request, @Nullable RESPONSE response) { - InetSocketAddress address = getNetworkPeerInetSocketAddress(request, response); - if (address == null) { - return null; - } - InetAddress remoteAddress = address.getAddress(); - if (remoteAddress instanceof Inet4Address) { - return "ipv4"; - } else if (remoteAddress instanceof Inet6Address) { - return "ipv6"; - } - return null; - } - - /** - * Returns an {@link InetSocketAddress} object representing the peer socket address. - * - *

Implementing this method is equivalent to implementing both {@link - * #getNetworkPeerAddress(Object, Object)} and {@link #getNetworkPeerPort(Object, Object)}. - */ - @Nullable - default InetSocketAddress getNetworkPeerInetSocketAddress( - REQUEST request, @Nullable RESPONSE response) { - return null; - } - - /** - * Returns the peer address of the network connection - IP address or Unix domain socket name. - * - *

Examples: {@code 10.1.2.80}, {@code /tmp/my.sock} - * - *

By default, this method attempts to retrieve the peer address using the {@link - * #getNetworkPeerInetSocketAddress(Object, Object)} method. If that method is not implemented, it - * will simply return {@code null}. If the instrumented library does not expose {@link - * InetSocketAddress} in its API, you might want to implement this method instead of {@link - * #getNetworkPeerInetSocketAddress(Object, Object)}. - */ - @Nullable - default String getNetworkPeerAddress(REQUEST request, @Nullable RESPONSE response) { - return InetSocketAddressUtil.getIpAddress(getNetworkPeerInetSocketAddress(request, response)); - } - - /** - * Returns the peer port number of the network connection. - * - *

Examples: {@code 65123} - * - *

By default, this method attempts to retrieve the peer port using the {@link - * #getNetworkPeerInetSocketAddress(Object, Object)} method. If that method is not implemented, it - * will simply return {@code null}. If the instrumented library does not expose {@link - * InetSocketAddress} in its API, you might want to implement this method instead of {@link - * #getNetworkPeerInetSocketAddress(Object, Object)}. - */ - @Nullable - default Integer getNetworkPeerPort(REQUEST request, @Nullable RESPONSE response) { - return InetSocketAddressUtil.getPort(getNetworkPeerInetSocketAddress(request, response)); - } -} 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 8afa015c13ad..5e6f41fecdee 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,12 +6,12 @@ package io.opentelemetry.javaagent.instrumentation.cassandra.v3_0; import com.datastax.driver.core.ExecutionInfo; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements DbNetworkAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable 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 03cf6315da32..ccea6f13087a 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 @@ -8,10 +8,10 @@ import com.datastax.driver.core.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -38,7 +38,7 @@ public final class CassandraSingletons { AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - DbNetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java index 261a0a0a9964..4bdbe0b64cc9 100644 --- a/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java +++ b/instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/CassandraClientTest.java @@ -10,7 +10,6 @@ import com.datastax.driver.core.ResultSetFuture; import com.datastax.driver.core.Session; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -95,9 +94,7 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -114,9 +111,7 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -147,9 +142,7 @@ void syncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -197,9 +190,7 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasNoParent() .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -217,9 +208,7 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -255,9 +244,7 @@ void asyncTest(Parameter parameter) { .hasKind(SpanKind.CLIENT) .hasParent(trace.getSpan(0)) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(ServerAttributes.SERVER_ADDRESS, cassandraHost), equalTo(ServerAttributes.SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), 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 2d9350753fae..44ed4e1e851d 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,13 +7,13 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import com.datastax.oss.driver.api.core.metadata.Node; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import java.net.SocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements DbNetworkAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable 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 7304fa4413ce..188a02c20d83 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 @@ -8,10 +8,10 @@ import com.datastax.oss.driver.api.core.cql.ExecutionInfo; import io.opentelemetry.api.GlobalOpenTelemetry; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig; import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; @@ -37,7 +37,7 @@ public final class CassandraSingletons { AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) .addAttributesExtractor( - DbNetworkAttributesExtractor.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 1d54cd8966c4..532dcb0646f6 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 @@ -9,12 +9,12 @@ import com.datastax.oss.driver.api.core.metadata.EndPoint; import com.datastax.oss.driver.api.core.metadata.Node; import com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesGetter; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesGetter; import java.net.InetSocketAddress; import javax.annotation.Nullable; final class CassandraNetworkAttributesGetter - implements DbNetworkAttributesGetter { + implements NetworkAttributesGetter { @Override @Nullable 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 6cac237d4858..cb9ab979d26e 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 @@ -10,10 +10,10 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientSpanNameExtractor; -import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbNetworkAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlClientAttributesExtractor; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; import io.opentelemetry.instrumentation.api.instrumenter.SpanKindExtractor; +import io.opentelemetry.instrumentation.api.semconv.network.NetworkAttributesExtractor; /** A builder of {@link CassandraTelemetry}. */ public class CassandraTelemetryBuilder { @@ -63,7 +63,7 @@ protected Instrumenter createInstrumenter( .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( - DbNetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) + NetworkAttributesExtractor.create(new CassandraNetworkAttributesGetter())) .addAttributesExtractor(new CassandraAttributesExtractor()) .buildInstrumenter(SpanKindExtractor.alwaysClient()); } diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java index 4e7ad08a54ee..3c6a07f6dca6 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java @@ -14,7 +14,6 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -117,9 +116,7 @@ void futureSet() throws ExecutionException, InterruptedException, TimeoutExcepti span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -158,9 +155,7 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo span.hasName("SADD") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -240,9 +235,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -255,9 +248,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -274,9 +265,7 @@ void atomicBatchCommand() throws ExecutionException, InterruptedException, Timeo span.hasName("EXEC") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), diff --git a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java index 08b812294481..700c065c2137 100644 --- a/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java +++ b/instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java @@ -14,7 +14,6 @@ import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; @@ -120,9 +119,7 @@ void stringCommand() { span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -140,9 +137,7 @@ void stringCommand() { span.hasName("GET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -174,9 +169,7 @@ void batchCommand() span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -219,9 +212,7 @@ void atomicBatchCommand() { span.hasName("DB Query") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -234,9 +225,7 @@ void atomicBatchCommand() { span.hasName("SET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -253,9 +242,7 @@ void atomicBatchCommand() { span.hasName("EXEC") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -283,9 +270,7 @@ void listCommand() { span.hasName("RPUSH") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -316,9 +301,7 @@ void hashCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -336,9 +319,7 @@ void hashCommand() { span.hasName("HGET") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -365,9 +346,7 @@ void setCommand() { span.hasName("SADD") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -401,9 +380,7 @@ void sortedSetCommand() span.hasName("ZADD") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -435,9 +412,7 @@ void atomicLongCommand() { span.hasName("INCR") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -469,9 +444,7 @@ void lockCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -490,9 +463,7 @@ void lockCommand() { span.hasName("EVAL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), @@ -512,9 +483,7 @@ void lockCommand() { span.hasName("DEL") .hasKind(CLIENT) .hasAttributesSatisfyingExactly( - equalTo( - NetworkAttributes.NETWORK_TYPE, - SemconvStability.emitOldDatabaseSemconv() ? "ipv4" : null), + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip), equalTo(NetworkAttributes.NETWORK_PEER_PORT, (long) port), equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"), From 51b318ce6698d3abd68793cc03cee9a9121f41b2 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Sun, 27 Oct 2024 21:27:29 -0700 Subject: [PATCH 90/93] fixup! revert a bit, will implement differently later --- .../v4/common/AbstractCassandraTest.java | 19 +++--------- .../v4_4/AbstractCassandra44Test.java | 10 ++---- .../couchbase/v2_6/Couchbase26Util.java | 31 +++++-------------- 3 files changed, 14 insertions(+), 46 deletions(-) diff --git a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java index a01bcff5890d..7a2087a3a3b7 100644 --- a/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java +++ b/instrumentation/cassandra/cassandra-4-common/testing/src/main/java/io/opentelemetry/cassandra/v4/common/AbstractCassandraTest.java @@ -30,7 +30,6 @@ import com.datastax.oss.driver.api.core.config.DriverConfigLoader; import com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader; import io.opentelemetry.api.trace.SpanKind; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; @@ -103,15 +102,10 @@ void syncTest(Parameter parameter) { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> { - if (SemconvStability.emitOldDatabaseSemconv()) { + val -> val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6")); - } else { - val.isNull(); - } - }), + v -> assertThat(v).isEqualTo("ipv6"))), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), @@ -170,15 +164,10 @@ void asyncTest(Parameter parameter) throws Exception { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> { - if (SemconvStability.emitOldDatabaseSemconv()) { + val -> val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6")); - } else { - val.isNull(); - } - }), + v -> assertThat(v).isEqualTo("ipv6"))), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), diff --git a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java index 1ee13c6836b4..01a015f75398 100644 --- a/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java +++ b/instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java @@ -27,7 +27,6 @@ import com.datastax.oss.driver.api.core.CqlSession; import io.opentelemetry.api.trace.SpanKind; import io.opentelemetry.cassandra.v4.common.AbstractCassandraTest; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil; import io.opentelemetry.semconv.NetworkAttributes; import java.util.stream.Stream; @@ -63,15 +62,10 @@ void reactiveTest(Parameter parameter) { .hasAttributesSatisfyingExactly( satisfies( NETWORK_TYPE, - val -> { - if (SemconvStability.emitOldDatabaseSemconv()) { + val -> val.satisfiesAnyOf( v -> assertThat(v).isEqualTo("ipv4"), - v -> assertThat(v).isEqualTo("ipv6")); - } else { - val.isNull(); - } - }), + v -> assertThat(v).isEqualTo("ipv6"))), equalTo(SERVER_ADDRESS, cassandraHost), equalTo(SERVER_PORT, cassandraPort), equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, cassandraIp), diff --git a/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java b/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java index dceaf99a199e..f884a4857eeb 100644 --- a/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java +++ b/instrumentation/couchbase/couchbase-2.6/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/couchbase/v2_6/Couchbase26Util.java @@ -14,7 +14,6 @@ import com.couchbase.client.java.cluster.BucketSettings; import com.couchbase.client.java.env.DefaultCouchbaseEnvironment; import io.opentelemetry.api.common.AttributeKey; -import io.opentelemetry.instrumentation.api.internal.SemconvStability; import io.opentelemetry.sdk.testing.assertj.AttributeAssertion; import io.opentelemetry.semconv.NetworkAttributes; import java.util.Arrays; @@ -48,28 +47,14 @@ public static DefaultCouchbaseEnvironment.Builder envBuilder( } public static List couchbaseAttributes() { - if (SemconvStability.emitStableDatabaseSemconv()) { - return Arrays.asList( - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), - satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.local.address"), - val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.operation_id"), - val -> assertThat(val).isNotNull())); - } else { - return Arrays.asList( - equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), - equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), - satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.local.address"), - val -> assertThat(val).isNotNull()), - satisfies( - AttributeKey.stringKey("couchbase.operation_id"), - val -> assertThat(val).isNotNull())); - } + return Arrays.asList( + equalTo(NetworkAttributes.NETWORK_TYPE, "ipv4"), + equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, "127.0.0.1"), + satisfies(NetworkAttributes.NETWORK_PEER_PORT, val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.local.address"), val -> assertThat(val).isNotNull()), + satisfies( + AttributeKey.stringKey("couchbase.operation_id"), val -> assertThat(val).isNotNull())); } private Couchbase26Util() {} From b6b115055b59092c445c2013c02eb182d7a5d341 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 28 Oct 2024 12:29:55 -0700 Subject: [PATCH 91/93] feedback --- .../semconv/db/SqlClientAttributesExtractorBuilder.java | 2 +- .../incubator/semconv/db/SqlClientAttributesExtractorTest.java | 2 +- .../instrumentation/api/internal/SemconvStability.java | 3 +-- .../instrumentation/cassandra/v3_0/CassandraSingletons.java | 2 +- .../instrumentation/cassandra/v4_0/CassandraSingletons.java | 2 +- .../cassandra/v4_4/CassandraTelemetryBuilder.java | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java index e8ec48084345..4e7672e94285 100644 --- a/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java +++ b/instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java @@ -30,7 +30,7 @@ public final class SqlClientAttributesExtractorBuilder { */ @CanIgnoreReturnValue @Deprecated - public SqlClientAttributesExtractorBuilder setOldSemconvTableAttribute( + public SqlClientAttributesExtractorBuilder setTableAttribute( AttributeKey oldSemconvTableAttribute) { this.oldSemconvTableAttribute = requireNonNull(oldSemconvTableAttribute); return this; 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 0b032e46bbbe..f0b31197a3e2 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 @@ -162,7 +162,7 @@ void shouldExtractTableToSpecifiedKey() { AttributesExtractor, Void> underTest = SqlClientAttributesExtractor., Void>builder(new TestAttributesGetter()) - .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .build(); // when diff --git a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java index 81ac63218cf1..bbf7706c5a43 100644 --- a/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java +++ b/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java @@ -31,8 +31,7 @@ public final class SemconvStability { stableDatabase = true; } // no else -- technically it's possible to set "database,database/dup", in which case we - // should emit - // both sets of attributes + // should emit both sets of attributes if (values.contains("database/dup")) { oldDatabase = true; stableDatabase = true; 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 9d6ca5caf988..5598d2fcb994 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 @@ -33,7 +33,7 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 b3ffe89b1daa..668cf2f50974 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 @@ -32,7 +32,7 @@ public final class CassandraSingletons { DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setOldSemconvTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) + .setTableAttribute(DbIncubatingAttributes.DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled( AgentCommonConfig.get().isStatementSanitizationEnabled()) .build()) 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 cb9ab979d26e..d5a92eb7d936 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 @@ -59,7 +59,7 @@ protected Instrumenter createInstrumenter( openTelemetry, INSTRUMENTATION_NAME, DbClientSpanNameExtractor.create(attributesGetter)) .addAttributesExtractor( SqlClientAttributesExtractor.builder(attributesGetter) - .setOldSemconvTableAttribute(DB_CASSANDRA_TABLE) + .setTableAttribute(DB_CASSANDRA_TABLE) .setStatementSanitizationEnabled(statementSanitizationEnabled) .build()) .addAttributesExtractor( From 49a67c4318d88fceefb5fcf9403cea2dde238956 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 28 Oct 2024 12:50:21 -0700 Subject: [PATCH 92/93] Fix CI --- .../junit/db/SemconvStabilityUtil.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index c6a0c613d92b..36f299acafea 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -20,7 +20,8 @@ // until old database semconv are dropped in 3.0 public class SemconvStabilityUtil { - private static final Map, AttributeKey> oldToNewMap = new HashMap<>(); + private static final Map, AttributeKey> oldToNewMap = buildMap(); + private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); private static final AttributeKey DB_OPERATION_NAME = @@ -28,23 +29,21 @@ public class SemconvStabilityUtil { private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); - static { - addKey(oldToNewMap, DB_NAME, DB_NAMESPACE); - addKey(oldToNewMap, DB_STATEMENT, DB_QUERY_TEXT); - addKey(oldToNewMap, DB_OPERATION, DB_OPERATION_NAME); - addKey(oldToNewMap, DB_SQL_TABLE, DB_COLLECTION_NAME); - addKey(oldToNewMap, DB_CASSANDRA_TABLE, DB_COLLECTION_NAME); - addKey(oldToNewMap, DB_MONGODB_COLLECTION, DB_COLLECTION_NAME); - addKey(oldToNewMap, DB_COSMOSDB_CONTAINER, DB_COLLECTION_NAME); + @SuppressWarnings("deprecation") // using deprecated semconv + private static Map, AttributeKey> buildMap() { + Map, AttributeKey> map = new HashMap<>(); + map.put(DB_NAME, DB_NAMESPACE); + map.put(DB_STATEMENT, DB_QUERY_TEXT); + map.put(DB_OPERATION, DB_OPERATION_NAME); + map.put(DB_SQL_TABLE, DB_COLLECTION_NAME); + map.put(DB_CASSANDRA_TABLE, DB_COLLECTION_NAME); + map.put(DB_MONGODB_COLLECTION, DB_COLLECTION_NAME); + map.put(DB_COSMOSDB_CONTAINER, DB_COLLECTION_NAME); + return map; } private SemconvStabilityUtil() {} - private static void addKey( - Map, AttributeKey> map, AttributeKey oldKey, AttributeKey newKey) { - map.put(oldKey, newKey); - } - @SuppressWarnings("unchecked") public static AttributeKey getAttributeKey(AttributeKey oldKey) { // not testing database/dup From 468ec83b06a1644ce60c2f3ba116ff3e79155843 Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Mon, 28 Oct 2024 13:40:01 -0700 Subject: [PATCH 93/93] Fix --- .../instrumentation/testing/junit/db/SemconvStabilityUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java index 36f299acafea..06d25bd9ec79 100644 --- a/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java +++ b/testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java @@ -20,7 +20,6 @@ // until old database semconv are dropped in 3.0 public class SemconvStabilityUtil { - private static final Map, AttributeKey> oldToNewMap = buildMap(); private static final AttributeKey DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); private static final AttributeKey DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); @@ -29,6 +28,8 @@ public class SemconvStabilityUtil { private static final AttributeKey DB_COLLECTION_NAME = AttributeKey.stringKey("db.collection.name"); + private static final Map, AttributeKey> oldToNewMap = buildMap(); + @SuppressWarnings("deprecation") // using deprecated semconv private static Map, AttributeKey> buildMap() { Map, AttributeKey> map = new HashMap<>();