-
Notifications
You must be signed in to change notification settings - Fork 933
/
Copy pathSemconvStability.java
81 lines (67 loc) · 2.5 KB
/
SemconvStability.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* 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.HashMap;
import java.util.HashSet;
import java.util.Map;
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<String> 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 static final Map<String, String> dbSystemNameMap = new HashMap<>();
static {
dbSystemNameMap.put("adabas", "softwareag.adabas");
dbSystemNameMap.put("intersystems_cache", "intersystems.cache");
dbSystemNameMap.put("cosmosdb", "azure.cosmosdb");
dbSystemNameMap.put("db2", "ibm.db2");
dbSystemNameMap.put("dynamodb", "aws.dynamodb");
dbSystemNameMap.put("h2", "h2database");
dbSystemNameMap.put("hanadb", "sap.hana");
dbSystemNameMap.put("informix", "ibm.informix");
dbSystemNameMap.put("ingres", "actian.ingres");
dbSystemNameMap.put("maxdb", "sap.maxdb");
dbSystemNameMap.put("mssql", "microsoft.sql_server");
dbSystemNameMap.put("netezza", "ibm.netezza");
dbSystemNameMap.put("oracle", "oracle.db");
dbSystemNameMap.put("redshift", "aws.redshift");
dbSystemNameMap.put("spanner", "gcp.spanner");
}
public static String stableDbSystemName(String oldDbSystem) {
String dbSystemName = dbSystemNameMap.get(oldDbSystem);
return dbSystemName != null ? dbSystemName : oldDbSystem;
}
private SemconvStability() {}
}