Skip to content

Commit a4b0d0e

Browse files
committed
updates
1 parent f2743a5 commit a4b0d0e

3 files changed

Lines changed: 39 additions & 23 deletions

File tree

instrumentation/armeria/armeria-grpc-1.14/javaagent/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ afterEvaluate {
5959
}
6060
}
6161

62-
tasks.test {
63-
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
64-
}
65-
6662
tasks {
63+
withType<Test>().configureEach {
64+
systemProperty("collectMetadata", findProperty("collectMetadata")?.toString() ?: "false")
65+
}
66+
6767
val testStableSemconv by registering(Test::class) {
6868
testClassesDirs = sourceSets.test.get().output.classesDirs
6969
classpath = sourceSets.test.get().runtimeClasspath

instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,14 +1605,14 @@ public void sayHello(
16051605
void setCapturedRequestMetadata() throws Exception {
16061606
String oldMetadataAttributePrefix = "rpc.grpc.request.metadata.";
16071607
String stableMetadataAttributePrefix = "rpc.request.metadata.";
1608-
AttributeKey<List<String>> clientAttributeKey =
1609-
AttributeKey.stringArrayKey(
1610-
(emitStableRpcSemconv() ? stableMetadataAttributePrefix : oldMetadataAttributePrefix)
1611-
+ CLIENT_REQUEST_METADATA_KEY);
1612-
AttributeKey<List<String>> serverAttributeKey =
1613-
AttributeKey.stringArrayKey(
1614-
(emitStableRpcSemconv() ? stableMetadataAttributePrefix : oldMetadataAttributePrefix)
1615-
+ SERVER_REQUEST_METADATA_KEY);
1608+
AttributeKey<List<String>> oldClientAttributeKey =
1609+
AttributeKey.stringArrayKey(oldMetadataAttributePrefix + CLIENT_REQUEST_METADATA_KEY);
1610+
AttributeKey<List<String>> stableClientAttributeKey =
1611+
AttributeKey.stringArrayKey(stableMetadataAttributePrefix + CLIENT_REQUEST_METADATA_KEY);
1612+
AttributeKey<List<String>> oldServerAttributeKey =
1613+
AttributeKey.stringArrayKey(oldMetadataAttributePrefix + SERVER_REQUEST_METADATA_KEY);
1614+
AttributeKey<List<String>> stableServerAttributeKey =
1615+
AttributeKey.stringArrayKey(stableMetadataAttributePrefix + SERVER_REQUEST_METADATA_KEY);
16161616
String serverMetadataValue = "server-value";
16171617
String clientMetadataValue = "client-value";
16181618

@@ -1657,16 +1657,32 @@ public void sayHello(
16571657
trace ->
16581658
trace.hasSpansSatisfyingExactly(
16591659
span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(),
1660-
span ->
1661-
span.hasName("example.Greeter/SayHello")
1662-
.hasKind(SpanKind.CLIENT)
1663-
.hasParent(trace.getSpan(0))
1664-
.hasAttribute(clientAttributeKey, singletonList(clientMetadataValue)),
1665-
span ->
1666-
span.hasName("example.Greeter/SayHello")
1667-
.hasKind(SpanKind.SERVER)
1668-
.hasParent(trace.getSpan(1))
1669-
.hasAttribute(serverAttributeKey, singletonList(serverMetadataValue))));
1660+
span -> {
1661+
span.hasName("example.Greeter/SayHello")
1662+
.hasKind(SpanKind.CLIENT)
1663+
.hasParent(trace.getSpan(0));
1664+
if (emitOldRpcSemconv()) {
1665+
span.hasAttribute(
1666+
oldClientAttributeKey, singletonList(clientMetadataValue));
1667+
}
1668+
if (emitStableRpcSemconv()) {
1669+
span.hasAttribute(
1670+
stableClientAttributeKey, singletonList(clientMetadataValue));
1671+
}
1672+
},
1673+
span -> {
1674+
span.hasName("example.Greeter/SayHello")
1675+
.hasKind(SpanKind.SERVER)
1676+
.hasParent(trace.getSpan(1));
1677+
if (emitOldRpcSemconv()) {
1678+
span.hasAttribute(
1679+
oldServerAttributeKey, singletonList(serverMetadataValue));
1680+
}
1681+
if (emitStableRpcSemconv()) {
1682+
span.hasAttribute(
1683+
stableServerAttributeKey, singletonList(serverMetadataValue));
1684+
}
1685+
}));
16701686
}
16711687

16721688
private ManagedChannel createChannel(Server server) throws Exception {

testing-common/src/main/java/io/opentelemetry/instrumentation/testing/junit/rpc/SemconvRpcStabilityUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// until old rpc semconv are dropped in 3.0
1616
@SuppressWarnings("deprecation") // using deprecated semconv
17-
public class SemconvRpcStabilityUtil {
17+
public final class SemconvRpcStabilityUtil {
1818

1919
private static final AttributeKey<String> RPC_SYSTEM_NAME =
2020
AttributeKey.stringKey("rpc.system.name");

0 commit comments

Comments
 (0)