Skip to content

Commit 49a67c4

Browse files
committed
Fix CI
1 parent b6b1150 commit 49a67c4

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/db/SemconvStabilityUtil.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,30 @@
2020

2121
// until old database semconv are dropped in 3.0
2222
public class SemconvStabilityUtil {
23-
private static final Map<AttributeKey<?>, AttributeKey<?>> oldToNewMap = new HashMap<>();
23+
private static final Map<AttributeKey<?>, AttributeKey<?>> oldToNewMap = buildMap();
24+
2425
private static final AttributeKey<String> DB_NAMESPACE = AttributeKey.stringKey("db.namespace");
2526
private static final AttributeKey<String> DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text");
2627
private static final AttributeKey<String> DB_OPERATION_NAME =
2728
AttributeKey.stringKey("db.operation.name");
2829
private static final AttributeKey<String> DB_COLLECTION_NAME =
2930
AttributeKey.stringKey("db.collection.name");
3031

31-
static {
32-
addKey(oldToNewMap, DB_NAME, DB_NAMESPACE);
33-
addKey(oldToNewMap, DB_STATEMENT, DB_QUERY_TEXT);
34-
addKey(oldToNewMap, DB_OPERATION, DB_OPERATION_NAME);
35-
addKey(oldToNewMap, DB_SQL_TABLE, DB_COLLECTION_NAME);
36-
addKey(oldToNewMap, DB_CASSANDRA_TABLE, DB_COLLECTION_NAME);
37-
addKey(oldToNewMap, DB_MONGODB_COLLECTION, DB_COLLECTION_NAME);
38-
addKey(oldToNewMap, DB_COSMOSDB_CONTAINER, DB_COLLECTION_NAME);
32+
@SuppressWarnings("deprecation") // using deprecated semconv
33+
private static Map<AttributeKey<?>, AttributeKey<?>> buildMap() {
34+
Map<AttributeKey<?>, AttributeKey<?>> map = new HashMap<>();
35+
map.put(DB_NAME, DB_NAMESPACE);
36+
map.put(DB_STATEMENT, DB_QUERY_TEXT);
37+
map.put(DB_OPERATION, DB_OPERATION_NAME);
38+
map.put(DB_SQL_TABLE, DB_COLLECTION_NAME);
39+
map.put(DB_CASSANDRA_TABLE, DB_COLLECTION_NAME);
40+
map.put(DB_MONGODB_COLLECTION, DB_COLLECTION_NAME);
41+
map.put(DB_COSMOSDB_CONTAINER, DB_COLLECTION_NAME);
42+
return map;
3943
}
4044

4145
private SemconvStabilityUtil() {}
4246

43-
private static <T> void addKey(
44-
Map<AttributeKey<?>, AttributeKey<?>> map, AttributeKey<T> oldKey, AttributeKey<T> newKey) {
45-
map.put(oldKey, newKey);
46-
}
47-
4847
@SuppressWarnings("unchecked")
4948
public static <T> AttributeKey<T> getAttributeKey(AttributeKey<T> oldKey) {
5049
// not testing database/dup

0 commit comments

Comments
 (0)