Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,16 @@ tasks {
include("software/amazon/awssdk/global/handlers/execution.interceptors")
}
}

val testStableSemconv by registering(Test::class) {
filter {
excludeTestsMatching("Aws2SqsSuppressReceiveSpansTest")
}
systemProperty("otel.instrumentation.messaging.experimental.receive-telemetry.enabled", "true")
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true)
systemProperty("otel.instrumentation.aws-sdk.experimental-record-individual-http-error", true)
systemProperty("otel.instrumentation.messaging.experimental.capture-headers", "test-message-header")
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
10 changes: 9 additions & 1 deletion instrumentation/aws-sdk/aws-sdk-2.2/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,18 @@ testing {
}

tasks {
withType<Test> {
withType<Test>().configureEach {
// NB: If you'd like to change these, there is some cleanup work to be done, as most tests ignore this and
// set the value directly (the "library" does not normally query it, only library-autoconfigure)
systemProperty("otel.instrumentation.aws-sdk.experimental-span-attributes", true)
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.contrib.awsxray.propagator.AwsXrayPropagator;
import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter;
import io.opentelemetry.instrumentation.api.internal.InstrumenterUtil;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.instrumentation.api.internal.Timer;
import io.opentelemetry.semconv.HttpAttributes;
import java.io.BufferedReader;
Expand Down Expand Up @@ -50,6 +51,8 @@ public final class TracingExecutionInterceptor implements ExecutionInterceptor {

// copied from DbIncubatingAttributes
private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation");
private static final AttributeKey<String> DB_OPERATION_NAME =
AttributeKey.stringKey("db.operation.name");
private static final AttributeKey<String> DB_SYSTEM = AttributeKey.stringKey("db.system");
// copied from DbIncubatingAttributes.DbSystemIncubatingValues
private static final String DB_SYSTEM_DYNAMODB = "dynamodb";
Expand Down Expand Up @@ -331,7 +334,12 @@ private void populateRequestAttributes(
span.setAttribute(DB_SYSTEM, DB_SYSTEM_DYNAMODB);
String operation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME);
if (operation != null) {
span.setAttribute(DB_OPERATION, operation);
if (SemconvStability.emitStableDatabaseSemconv()) {
span.setAttribute(DB_OPERATION_NAME, operation);
}
if (SemconvStability.emitOldDatabaseSemconv()) {
span.setAttribute(DB_OPERATION, operation);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ package io.opentelemetry.instrumentation.awssdk.v2_2

import io.opentelemetry.instrumentation.api.internal.ConfigPropertiesUtil
import io.opentelemetry.instrumentation.test.InstrumentationSpecification
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes
import io.opentelemetry.semconv.incubating.AwsIncubatingAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.HttpAttributes
import io.opentelemetry.semconv.ServerAttributes
import io.opentelemetry.semconv.UrlAttributes
import io.opentelemetry.semconv.incubating.AwsIncubatingAttributes
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes
import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes
import io.opentelemetry.testing.internal.armeria.common.HttpResponse
import io.opentelemetry.testing.internal.armeria.common.HttpStatus
import io.opentelemetry.testing.internal.armeria.common.MediaType
import io.opentelemetry.testing.internal.armeria.testing.junit5.server.mock.MockWebServerExtension
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider
import software.amazon.awssdk.core.client.builder.SdkClientBuilder
Expand All @@ -24,15 +25,14 @@ import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient
import software.amazon.awssdk.services.dynamodb.DynamoDbClient
import software.amazon.awssdk.services.dynamodb.model.*
import io.opentelemetry.testing.internal.armeria.testing.junit5.server.mock.MockWebServerExtension
import spock.lang.Shared
import spock.lang.Unroll

import java.util.concurrent.Future

import static com.google.common.collect.ImmutableMap.of
import static io.opentelemetry.api.trace.SpanKind.CLIENT

import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable

@Unroll
abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
Expand Down Expand Up @@ -150,7 +150,7 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
"$AwsIncubatingAttributes.AWS_REQUEST_ID" "$requestId"
"aws.table.name" "sometable"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "CreateTable"
"${maybeStable(DbIncubatingAttributes.DB_OPERATION)}" "CreateTable"
"aws.dynamodb.global_secondary_indexes" "[{\"IndexName\":\"globalIndex\",\"KeySchema\":[{\"AttributeName\":\"attribute\"}],\"ProvisionedThroughput\":{\"ReadCapacityUnits\":10,\"WriteCapacityUnits\":12}},{\"IndexName\":\"globalIndexSecondary\",\"KeySchema\":[{\"AttributeName\":\"attributeSecondary\"}],\"ProvisionedThroughput\":{\"ReadCapacityUnits\":7,\"WriteCapacityUnits\":8}}]"
"aws.dynamodb.provisioned_throughput.read_capacity_units" "1"
"aws.dynamodb.provisioned_throughput.write_capacity_units" "1"
Expand Down Expand Up @@ -183,7 +183,7 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
"$AwsIncubatingAttributes.AWS_REQUEST_ID" "$requestId"
"aws.table.name" "sometable"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "Query"
"${maybeStable(DbIncubatingAttributes.DB_OPERATION)}" "Query"
"aws.dynamodb.limit" "10"
"aws.dynamodb.select" "ALL_ATTRIBUTES"
}
Expand Down Expand Up @@ -215,7 +215,7 @@ abstract class AbstractAws2ClientCoreTest extends InstrumentationSpecification {
"$AwsIncubatingAttributes.AWS_REQUEST_ID" "$requestId"
"aws.table.name" "sometable"
"$DbIncubatingAttributes.DB_SYSTEM" "dynamodb"
"$DbIncubatingAttributes.DB_OPERATION" "${operation}"
"${maybeStable(DbIncubatingAttributes.DB_OPERATION)}" "${operation}"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.instrumentation.awssdk.v2_2;

import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD;
Expand Down Expand Up @@ -184,7 +185,7 @@ public void testSendDynamoDbRequestWithRetries() {
equalTo(AwsIncubatingAttributes.AWS_REQUEST_ID, requestId),
equalTo(stringKey("aws.table.name"), "sometable"),
equalTo(DB_SYSTEM, "dynamodb"),
equalTo(DB_OPERATION, operation));
equalTo(maybeStable(DB_OPERATION), operation));
if (isRecordIndividualHttpErrorEnabled()) {
span.hasEventsSatisfyingExactly(
event ->
Expand Down
8 changes: 8 additions & 0 deletions instrumentation/camel-2.20/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ tasks {

jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}

configurations.testRuntimeClasspath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import io.opentelemetry.api.common.AttributesBuilder;
import io.opentelemetry.instrumentation.api.incubator.semconv.db.SqlStatementSanitizer;
import io.opentelemetry.instrumentation.api.internal.SemconvStability;
import io.opentelemetry.javaagent.bootstrap.internal.AgentCommonConfig;
import io.opentelemetry.javaagent.instrumentation.apachecamel.CamelDirection;
import io.opentelemetry.semconv.incubating.DbIncubatingAttributes;
Expand Down Expand Up @@ -126,11 +127,21 @@ public void pre(
attributes.put(DbIncubatingAttributes.DB_SYSTEM, system);
String statement = getStatement(exchange, endpoint);
if (statement != null) {
attributes.put(DbIncubatingAttributes.DB_STATEMENT, statement);
if (SemconvStability.emitStableDatabaseSemconv()) {
attributes.put(DbIncubatingAttributes.DB_QUERY_TEXT, statement);
}
if (SemconvStability.emitOldDatabaseSemconv()) {
attributes.put(DbIncubatingAttributes.DB_STATEMENT, statement);
}
}
String dbName = getDbName(endpoint);
if (dbName != null) {
attributes.put(DbIncubatingAttributes.DB_NAME, dbName);
if (SemconvStability.emitStableDatabaseSemconv()) {
attributes.put(DbIncubatingAttributes.DB_NAMESPACE, dbName);
}
if (SemconvStability.emitOldDatabaseSemconv()) {
attributes.put(DbIncubatingAttributes.DB_NAME, dbName);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package io.opentelemetry.javaagent.instrumentation.apachecamel.decorators;

import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_NAME;
import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_STATEMENT;
Expand Down Expand Up @@ -119,9 +120,9 @@ void testCassandra() {
equalTo(
stringKey("camel.uri"),
"cql://" + host + ":" + cassandraPort + "/test"),
equalTo(DB_NAME, "test"),
equalTo(maybeStable(DB_NAME), "test"),
equalTo(
DB_STATEMENT,
maybeStable(DB_STATEMENT),
"select * from test.users where id=? ALLOW FILTERING"),
equalTo(DB_SYSTEM, "cassandra"))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ dependencies {
configurations.testRuntimeClasspath.get().resolutionStrategy.force("com.google.guava:guava:19.0")

tasks {
val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ dependencies {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ tasks {
test {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package io.opentelemetry.javaagent.instrumentation.clickhouse;

import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS;
import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT;
Expand Down Expand Up @@ -341,10 +342,10 @@ void testParameterizedQueryInput() throws ClickHouseException {
private static List<AttributeAssertion> attributeAssertions(String statement, String operation) {
return asList(
equalTo(DB_SYSTEM, DbIncubatingAttributes.DbSystemIncubatingValues.CLICKHOUSE),
equalTo(DB_NAME, dbName),
equalTo(maybeStable(DB_NAME), dbName),
equalTo(SERVER_ADDRESS, host),
equalTo(SERVER_PORT, port),
equalTo(DB_STATEMENT, statement),
equalTo(DB_OPERATION, operation));
equalTo(maybeStable(DB_STATEMENT), statement),
equalTo(maybeStable(DB_OPERATION), operation));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ dependencies {
}

tasks {
val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
// required on jdk17
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
jvmArgs("--add-opens=java.base/java.lang.invoke=ALL-UNNAMED")
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ dependencies {
}

tasks {
val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

withType<Test>().configureEach {
// TODO run tests both with and without experimental span attributes
jvmArgs("-Dotel.instrumentation.couchbase.experimental-span-attributes=true")
Expand All @@ -48,6 +44,10 @@ tasks {
jvmArgs("-XX:+IgnoreUnrecognizedVMOptions")
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ dependencies {
}

tasks {
test {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testStableSemconv by registering(Test::class) {
jvmArgs("-Dotel.semconv-stability.opt-in=database")
}

check {
dependsOn(testStableSemconv)
}
}
Loading
Loading