Skip to content

Commit d9e61af

Browse files
zeitlingertrask
andauthored
Add RPC semantic convention stability infrastructure (open-telemetry#16112)
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
1 parent 1d3d8dd commit d9e61af

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

instrumentation-api-incubator/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ tasks {
9191
val testStableSemconv by registering(Test::class) {
9292
testClassesDirs = sourceSets.test.get().output.classesDirs
9393
classpath = sourceSets.test.get().runtimeClasspath
94-
jvmArgs("-Dotel.semconv-stability.opt-in=database,code,service.peer")
94+
jvmArgs("-Dotel.semconv-stability.opt-in=database,code,service.peer,rpc")
9595
inputs.dir(jflexOutputDir)
9696
}
9797

9898
val testBothSemconv by registering(Test::class) {
9999
testClassesDirs = sourceSets.test.get().output.classesDirs
100100
classpath = sourceSets.test.get().runtimeClasspath
101-
jvmArgs("-Dotel.semconv-stability.opt-in=database/dup,code/dup,service.peer/dup")
101+
jvmArgs("-Dotel.semconv-stability.opt-in=database/dup,code/dup,service.peer/dup,rpc/dup")
102102
inputs.dir(jflexOutputDir)
103103
}
104104

instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/internal/SemconvStability.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public final class SemconvStability {
2727
private static final boolean emitOldServicePeerSemconv;
2828
private static final boolean emitStableServicePeerSemconv;
2929

30+
private static final boolean emitOldRpcSemconv;
31+
private static final boolean emitStableRpcSemconv;
32+
3033
static {
3134
boolean oldDatabase = true;
3235
boolean stableDatabase = false;
@@ -37,6 +40,9 @@ public final class SemconvStability {
3740
boolean oldServicePeer = true;
3841
boolean stableServicePeer = false;
3942

43+
boolean oldRpc = true;
44+
boolean stableRpc = false;
45+
4046
String value = System.getProperty("otel.semconv-stability.opt-in");
4147
if (value == null) {
4248
value = System.getenv("OTEL_SEMCONV_STABILITY_OPT_IN");
@@ -73,6 +79,15 @@ public final class SemconvStability {
7379
oldServicePeer = true;
7480
stableServicePeer = true;
7581
}
82+
83+
if (values.contains("rpc")) {
84+
oldRpc = false;
85+
stableRpc = true;
86+
}
87+
if (values.contains("rpc/dup")) {
88+
oldRpc = true;
89+
stableRpc = true;
90+
}
7691
}
7792

7893
emitOldDatabaseSemconv = oldDatabase;
@@ -83,6 +98,9 @@ public final class SemconvStability {
8398

8499
emitOldServicePeerSemconv = oldServicePeer;
85100
emitStableServicePeerSemconv = stableServicePeer;
101+
102+
emitOldRpcSemconv = oldRpc;
103+
emitStableRpcSemconv = stableRpc;
86104
}
87105

88106
public static boolean emitOldDatabaseSemconv() {
@@ -134,5 +152,25 @@ public static boolean isEmitStableCodeSemconv() {
134152
return emitStableCodeSemconv;
135153
}
136154

155+
public static boolean emitOldRpcSemconv() {
156+
return emitOldRpcSemconv;
157+
}
158+
159+
public static boolean emitStableRpcSemconv() {
160+
return emitStableRpcSemconv;
161+
}
162+
163+
private static final Map<String, String> rpcSystemNameMap = new HashMap<>();
164+
165+
static {
166+
rpcSystemNameMap.put("apache_dubbo", "dubbo");
167+
rpcSystemNameMap.put("connect_rpc", "connectrpc");
168+
}
169+
170+
public static String stableRpcSystemName(String oldRpcSystem) {
171+
String rpcSystemName = rpcSystemNameMap.get(oldRpcSystem);
172+
return rpcSystemName != null ? rpcSystemName : oldRpcSystem;
173+
}
174+
137175
private SemconvStability() {}
138176
}

0 commit comments

Comments
 (0)