|
20 | 20 |
|
21 | 21 | // until old database semconv are dropped in 3.0 |
22 | 22 | public class SemconvStabilityUtil { |
23 | | - private static final Map<AttributeKey<?>, AttributeKey<?>> oldToNewMap = new HashMap<>(); |
| 23 | + private static final Map<AttributeKey<?>, AttributeKey<?>> oldToNewMap = buildMap(); |
| 24 | + |
24 | 25 | private static final AttributeKey<String> DB_NAMESPACE = AttributeKey.stringKey("db.namespace"); |
25 | 26 | private static final AttributeKey<String> DB_QUERY_TEXT = AttributeKey.stringKey("db.query.text"); |
26 | 27 | private static final AttributeKey<String> DB_OPERATION_NAME = |
27 | 28 | AttributeKey.stringKey("db.operation.name"); |
28 | 29 | private static final AttributeKey<String> DB_COLLECTION_NAME = |
29 | 30 | AttributeKey.stringKey("db.collection.name"); |
30 | 31 |
|
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; |
39 | 43 | } |
40 | 44 |
|
41 | 45 | private SemconvStabilityUtil() {} |
42 | 46 |
|
43 | | - private static <T> void addKey( |
44 | | - Map<AttributeKey<?>, AttributeKey<?>> map, AttributeKey<T> oldKey, AttributeKey<T> newKey) { |
45 | | - map.put(oldKey, newKey); |
46 | | - } |
47 | | - |
48 | 47 | @SuppressWarnings("unchecked") |
49 | 48 | public static <T> AttributeKey<T> getAttributeKey(AttributeKey<T> oldKey) { |
50 | 49 | // not testing database/dup |
|
0 commit comments