Skip to content

Commit e610e5a

Browse files
committed
test stable semconv
1 parent b7a2f1d commit e610e5a

File tree

2 files changed

+33
-10
lines changed

2 files changed

+33
-10
lines changed

instrumentation/vertx/vertx-redis-client-4.0/javaagent/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ tasks {
2424
withType<Test>().configureEach {
2525
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
2626
}
27+
28+
val testStableSemconv by registering(Test::class) {
29+
jvmArgs("-Dotel.semconv-stability.opt-in=database")
30+
}
31+
32+
check {
33+
dependsOn(testStableSemconv)
34+
}
2735
}

instrumentation/vertx/vertx-redis-client-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/vertx/v4_0/redis/VertxRedisClientTest.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
99
import static org.assertj.core.api.Assertions.assertThat;
1010

11+
import io.opentelemetry.api.common.AttributeKey;
1112
import io.opentelemetry.api.trace.SpanKind;
1213
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
1314
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
15+
import io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil;
1416
import io.opentelemetry.sdk.testing.assertj.AttributeAssertion;
1517
import io.opentelemetry.semconv.NetworkAttributes;
1618
import io.opentelemetry.semconv.ServerAttributes;
@@ -200,15 +202,28 @@ void commandWithNoArguments() throws Exception {
200202
}
201203

202204
private static AttributeAssertion[] redisSpanAttributes(String operation, String statement) {
203-
return new AttributeAssertion[] {
204-
equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"),
205-
equalTo(DbIncubatingAttributes.DB_STATEMENT, statement),
206-
equalTo(DbIncubatingAttributes.DB_OPERATION, operation),
207-
equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1),
208-
equalTo(ServerAttributes.SERVER_ADDRESS, host),
209-
equalTo(ServerAttributes.SERVER_PORT, port),
210-
equalTo(NetworkAttributes.NETWORK_PEER_PORT, port),
211-
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip)
212-
};
205+
if (SemconvStabilityUtil.isStable()) {
206+
return new AttributeAssertion[] {
207+
equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"),
208+
equalTo(AttributeKey.stringKey("db.query.text"), statement),
209+
equalTo(AttributeKey.stringKey("db.operation.name"), operation),
210+
equalTo(AttributeKey.stringKey("db.namespace"), "1"),
211+
equalTo(ServerAttributes.SERVER_ADDRESS, host),
212+
equalTo(ServerAttributes.SERVER_PORT, port),
213+
equalTo(NetworkAttributes.NETWORK_PEER_PORT, port),
214+
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip)
215+
};
216+
} else {
217+
return new AttributeAssertion[] {
218+
equalTo(DbIncubatingAttributes.DB_SYSTEM, "redis"),
219+
equalTo(DbIncubatingAttributes.DB_STATEMENT, statement),
220+
equalTo(DbIncubatingAttributes.DB_OPERATION, operation),
221+
equalTo(DbIncubatingAttributes.DB_REDIS_DATABASE_INDEX, 1),
222+
equalTo(ServerAttributes.SERVER_ADDRESS, host),
223+
equalTo(ServerAttributes.SERVER_PORT, port),
224+
equalTo(NetworkAttributes.NETWORK_PEER_PORT, port),
225+
equalTo(NetworkAttributes.NETWORK_PEER_ADDRESS, ip)
226+
};
227+
}
213228
}
214229
}

0 commit comments

Comments
 (0)