Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static <REQUEST, RESPONSE> void onStartCommon(
internalSet(
attributes,
DB_SYSTEM_NAME,
SemconvStability.stableDbSystemName(getter.getDbSystem(request)));
SemconvStability.stableDbSystemName(getter.getDbSystemName(request)));
internalSet(attributes, DB_NAMESPACE, getter.getDbNamespace(request));
internalSet(attributes, DB_QUERY_TEXT, getter.getDbQueryText(request));
internalSet(attributes, DB_OPERATION_NAME, getter.getDbOperationName(request));
Expand Down Expand Up @@ -114,7 +114,8 @@ static <REQUEST, RESPONSE> void onEndCommon(
internalSet(attributes, ERROR_TYPE, error.getClass().getName());
}
if (error != null || response != null) {
internalSet(attributes, DB_RESPONSE_STATUS_CODE, getter.getResponseStatus(response, error));
internalSet(
attributes, DB_RESPONSE_STATUS_CODE, getter.getResponseStatusCode(response, error));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,31 @@ default String getOperation(REQUEST request) {
default String getDbOperationName(REQUEST request) {
return getOperation(request);
}

// TODO: make this required to implement
default String getDbSystemName(REQUEST request) {
String dbSystem = getDbSystem(request);
if (dbSystem == null) {
throw new UnsupportedOperationException(
"Must override getDbSystemName() or getDbSystem() (deprecated)");
}
return dbSystem;
}

/**
* @deprecated Use {@link #getDbSystemName} instead.
*/
@Deprecated
@Nullable
default String getDbSystem(REQUEST request) {
// overriding in order to provide a default implementation temporarily,
// so subclasses don't need to override this method
return null;
}

// TODO: make this required to implement
@Nullable
default String getResponseStatusCode(@Nullable RESPONSE response, @Nullable Throwable error) {
return getResponseStatus(response, error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,40 @@
@Deprecated
public interface DbClientCommonAttributesGetter<REQUEST, RESPONSE> {

/**
* @deprecated Use {@link DbClientAttributesGetter#getDbSystemName} instead.
*/
@Deprecated
@Nullable
String getDbSystem(REQUEST request);

/**
* @deprecated There is no replacement at this time.
*/
@Deprecated
@Nullable
default String getUser(REQUEST request) {
return null;
}

@Nullable
String getDbNamespace(REQUEST request);
default String getDbNamespace(REQUEST request) {
return null;
}

/**
* @deprecated There is no replacement at this time.
*/
@Deprecated
@Nullable
default String getConnectionString(REQUEST request) {
return null;
}

/**
* @deprecated Use {@link DbClientAttributesGetter#getResponseStatusCode} instead.
*/
@Deprecated
@Nullable
default String getResponseStatus(@Nullable RESPONSE response, @Nullable Throwable error) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DbClientAttributesExtractorTest {
static final class TestAttributesGetter
implements DbClientAttributesGetter<Map<String, String>, Void> {
@Override
public String getDbSystem(Map<String, String> map) {
public String getDbSystemName(Map<String, String> map) {
return map.get("db.system");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public Collection<String> getRawQueryTexts(Map<String, Object> map) {
}

@Override
public String getDbSystem(Map<String, Object> map) {
public String getDbSystemName(Map<String, Object> map) {
return read(map, "db.system");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void testSqlSanitizer() {
SqlClientAttributesGetter<Object, Void> getter =
new SqlClientAttributesGetter<Object, Void>() {
@Override
public String getDbSystem(Object o) {
public String getDbSystemName(Object o) {
return "testdb";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class CassandraSqlAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(CassandraRequest request) {
public String getDbSystemName(CassandraRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.CASSANDRA;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class CassandraSqlAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(CassandraRequest request) {
public String getDbSystemName(CassandraRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.CASSANDRA;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class CassandraSqlAttributesGetter
private static final String CASSANDRA = "cassandra";

@Override
public String getDbSystem(CassandraRequest request) {
public String getDbSystemName(CassandraRequest request) {
return CASSANDRA;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String getDbOperationName(ClickHouseDbRequest request) {

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(ClickHouseDbRequest request) {
public String getDbSystemName(ClickHouseDbRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.CLICKHOUSE;
}

Expand All @@ -55,7 +55,7 @@ public String getDbNamespace(ClickHouseDbRequest request) {

@Nullable
@Override
public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Void response, @Nullable Throwable error) {
return errorCodeExtractor.apply(error);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class CouchbaseAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(CouchbaseRequestInfo couchbaseRequest) {
public String getDbSystemName(CouchbaseRequestInfo couchbaseRequest) {
return DbIncubatingAttributes.DbSystemIncubatingValues.COUCHBASE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ final class ElasticsearchDbAttributesGetter
}

@Override
public String getDbSystem(ElasticsearchRestRequest request) {
public String getDbSystemName(ElasticsearchRestRequest request) {
return ELASTICSEARCH;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public String getDbOperationName(ElasticsearchRestRequest request) {

@Nullable
@Override
public String getResponseStatus(@Nullable Response response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Response response, @Nullable Throwable error) {
return response != null ? dbResponseStatusCode(response.getStatusLine().getStatusCode()) : null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ElasticsearchTransportAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(ElasticTransportRequest request) {
public String getDbSystemName(ElasticTransportRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.ELASTICSEARCH;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class GeodeDbAttributesGetter implements DbClientAttributesGetter<GeodeReq

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(GeodeRequest request) {
public String getDbSystemName(GeodeRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.GEODE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public String getDbOperationName(InfluxDbRequest request) {
}

@Override
public String getDbSystem(InfluxDbRequest request) {
public String getDbSystemName(InfluxDbRequest request) {
return "influxdb";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class JdbcAttributesGetter implements SqlClientAttributesGetter<DbR

@Nullable
@Override
public String getDbSystem(DbRequest request) {
public String getDbSystemName(DbRequest request) {
return request.getDbInfo().getSystem();
}

Expand Down Expand Up @@ -59,7 +59,7 @@ public Long getBatchSize(DbRequest request) {

@Nullable
@Override
public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Void response, @Nullable Throwable error) {
if (error instanceof SQLException) {
return Integer.toString(((SQLException) error).getErrorCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter<JedisReq
RedisCommandSanitizer.create(AgentCommonConfig.get().isStatementSanitizationEnabled());

@Override
public String getDbSystem(JedisRequest request) {
public String getDbSystemName(JedisRequest request) {
return DbIncubatingAttributes.DbSystemNameIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter<JedisReq

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(JedisRequest request) {
public String getDbSystemName(JedisRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class JedisDbAttributesGetter implements DbClientAttributesGetter<JedisReq

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(JedisRequest request) {
public String getDbSystemName(JedisRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class LettuceDbAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(RedisCommand<?, ?, ?> request) {
public String getDbSystemName(RedisCommand<?, ?, ?> request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class LettuceDbAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(RedisCommand<?, ?, ?> request) {
public String getDbSystemName(RedisCommand<?, ?, ?> request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MongoDbAttributesGetter implements DbClientAttributesGetter<CommandStarted
}

@Override
public String getDbSystem(CommandStartedEvent event) {
public String getDbSystemName(CommandStartedEvent event) {
return MONGODB;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ public String getDbOperationName(CommandStartedEvent event) {

@Nullable
@Override
public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Void response, @Nullable Throwable error) {
if (error instanceof MongoException) {
return Integer.toString(((MongoException) error).getCode());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class OpenSearchAttributesGetter
implements DbClientAttributesGetter<OpenSearchRequest, Void> {

@Override
public String getDbSystem(OpenSearchRequest request) {
public String getDbSystemName(OpenSearchRequest request) {
return DbIncubatingAttributes.DbSystemNameIncubatingValues.OPENSEARCH;
}

Expand All @@ -37,7 +37,7 @@ public String getDbOperationName(OpenSearchRequest request) {

@Nullable
@Override
public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Void response, @Nullable Throwable error) {
return null; // Response status is handled by HTTP instrumentation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class OpenSearchRestAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(OpenSearchRestRequest request) {
public String getDbSystemName(OpenSearchRestRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.OPENSEARCH;
}

Expand All @@ -40,7 +40,7 @@ public String getDbOperationName(OpenSearchRestRequest request) {

@Nullable
@Override
public String getResponseStatus(
public String getResponseStatusCode(
@Nullable OpenSearchRestResponse response, @Nullable Throwable error) {
return response != null ? dbResponseStatusCode(response.getStatusCode()) : null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public enum R2dbcSqlAttributesGetter implements SqlClientAttributesGetter<DbExec
INSTANCE;

@Override
public String getDbSystem(DbExecution request) {
public String getDbSystemName(DbExecution request) {
return request.getSystem();
}

Expand Down Expand Up @@ -51,7 +51,7 @@ public Collection<String> getRawQueryTexts(DbExecution request) {

@Nullable
@Override
public String getResponseStatus(@Nullable Void response, @Nullable Throwable error) {
public String getResponseStatusCode(@Nullable Void response, @Nullable Throwable error) {
if (error instanceof R2dbcException) {
return ((R2dbcException) error).getSqlState();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class RediscalaAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(RedisCommand<?, ?> redisCommand) {
public String getDbSystemName(RedisCommand<?, ?> redisCommand) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class RedissonDbAttributesGetter implements DbClientAttributesGetter<Redis

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(RedissonRequest request) {
public String getDbSystemName(RedissonRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SpymemcachedAttributesGetter
implements DbClientAttributesGetter<SpymemcachedRequest, Object> {

@Override
public String getDbSystem(SpymemcachedRequest spymemcachedRequest) {
public String getDbSystemName(SpymemcachedRequest spymemcachedRequest) {
return "memcached";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public enum VertxRedisClientAttributesGetter

@SuppressWarnings("deprecation") // using deprecated DbSystemIncubatingValues
@Override
public String getDbSystem(VertxRedisClientRequest request) {
public String getDbSystemName(VertxRedisClientRequest request) {
return DbIncubatingAttributes.DbSystemIncubatingValues.REDIS;
}

Expand Down
Loading
Loading