diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java index 0db35cef3f1b..eb90b4488d63 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkInstrumenterFactory.java @@ -28,8 +28,8 @@ import io.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; +import java.util.function.Consumer; import javax.annotation.Nullable; final class AwsSdkInstrumenterFactory { @@ -189,14 +189,16 @@ Instrumenter, Response> producerInstrumenter() { } Instrumenter, Response> dynamoDbInstrumenter() { - DynamoDbAttributesExtractor dynamoDbAttributesExtractor = new DynamoDbAttributesExtractor(); - - return Instrumenter., Response>builder( - openTelemetry, INSTRUMENTATION_NAME, spanName) - .addAttributesExtractors(attributesExtractors()) - .addAttributesExtractors(Collections.singletonList(dynamoDbAttributesExtractor)) - .addOperationMetrics(DbClientMetrics.get()) - .buildInstrumenter(SpanKindExtractor.alwaysClient()); + return createInstrumenter( + openTelemetry, + spanName, + SpanKindExtractor.alwaysClient(), + attributesExtractors(), + builder -> + builder + .addAttributesExtractor(new DynamoDbAttributesExtractor()) + .addOperationMetrics(DbClientMetrics.get()), + true); } private static Instrumenter createInstrumenter( @@ -206,11 +208,29 @@ private static Instrumenter createInstrum List> attributeExtractors, List> additionalAttributeExtractors, boolean enabled) { - return Instrumenter.builder( - openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) - .addAttributesExtractors(attributeExtractors) - .addAttributesExtractors(additionalAttributeExtractors) - .setEnabled(enabled) - .buildInstrumenter(spanKindExtractor); + return createInstrumenter( + openTelemetry, + spanNameExtractor, + spanKindExtractor, + attributeExtractors, + builder -> builder.addAttributesExtractors(additionalAttributeExtractors), + enabled); + } + + private static Instrumenter createInstrumenter( + OpenTelemetry openTelemetry, + SpanNameExtractor spanNameExtractor, + SpanKindExtractor spanKindExtractor, + List> attributeExtractors, + Consumer> customizer, + boolean enabled) { + InstrumenterBuilder builder = + Instrumenter.builder( + openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) + .addAttributesExtractors(attributeExtractors) + .setEnabled(enabled); + customizer.accept(builder); + + return builder.buildInstrumenter(spanKindExtractor); } } diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/DynamoDbAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/DynamoDbAttributesExtractor.java index f014955c2fce..09098be32d76 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/DynamoDbAttributesExtractor.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/DynamoDbAttributesExtractor.java @@ -17,9 +17,12 @@ import java.util.List; import javax.annotation.Nullable; -public class DynamoDbAttributesExtractor implements AttributesExtractor, Response> { +class DynamoDbAttributesExtractor implements AttributesExtractor, Response> { // copied from DbIncubatingAttributes + private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); + private static final AttributeKey DB_OPERATION_NAME = + AttributeKey.stringKey("db.operation.name"); private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); private static final AttributeKey DB_SYSTEM_NAME = AttributeKey.stringKey("db.system.name"); @@ -36,14 +39,35 @@ public class DynamoDbAttributesExtractor implements AttributesExtractor request) { if (SemconvStability.emitStableDatabaseSemconv()) { AttributesExtractorUtil.internalSet(attributes, DB_SYSTEM_NAME, AWS_DYNAMODB); - } else { + } + if (SemconvStability.emitOldDatabaseSemconv()) { AttributesExtractorUtil.internalSet(attributes, DB_SYSTEM, DYNAMODB); } + + String operation = getOperationName(request.getOriginalRequest()); + if (operation != null) { + if (SemconvStability.emitStableDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_OPERATION_NAME, operation); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_OPERATION, operation); + } + } + String tableName = RequestAccess.getTableName(request.getOriginalRequest()); AttributesExtractorUtil.internalSet( attributes, AWS_DYNAMODB_TABLE_NAMES, Collections.singletonList(tableName)); } + private static String getOperationName(Object request) { + String name = request.getClass().getSimpleName(); + if (!name.endsWith("Request")) { + return null; + } + + return name.substring(0, name.length() - "Request".length()); + } + @Override public void onEnd( AttributesBuilder attributes, diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractDynamoDbClientTest.java b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractDynamoDbClientTest.java index bef81bdb9e7a..6263ed2ff89d 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractDynamoDbClientTest.java +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractDynamoDbClientTest.java @@ -12,6 +12,8 @@ import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS; import static io.opentelemetry.semconv.ServerAttributes.SERVER_PORT; import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_DYNAMODB_TABLE_NAMES; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION_NAME; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM_NAME; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DbSystemNameIncubatingValues.AWS_DYNAMODB; @@ -59,6 +61,7 @@ public void sendRequestWithMockedResponse() throws Exception { SemconvStability.emitStableDatabaseSemconv() ? AWS_DYNAMODB : DbIncubatingAttributes.DbSystemIncubatingValues.DYNAMODB), + equalTo(maybeStable(DB_OPERATION), "CreateTable"), equalTo(AWS_DYNAMODB_TABLE_NAMES, singletonList("sometable"))); Object response = client.createTable(new CreateTableRequest("sometable", null)); @@ -66,6 +69,11 @@ public void sendRequestWithMockedResponse() throws Exception { response, client, "DynamoDBv2", "CreateTable", "POST", additionalAttributes); assertDurationMetric( - testing(), "io.opentelemetry.aws-sdk-1.11", DB_SYSTEM_NAME, SERVER_ADDRESS, SERVER_PORT); + testing(), + "io.opentelemetry.aws-sdk-1.11", + DB_SYSTEM_NAME, + DB_OPERATION_NAME, + SERVER_ADDRESS, + SERVER_PORT); } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java index 3349ad4f8653..b8c3253d0287 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkTelemetry.java @@ -54,6 +54,7 @@ public static AwsSdkTelemetryBuilder builder(OpenTelemetry openTelemetry) { private final Instrumenter consumerReceiveInstrumenter; private final Instrumenter consumerProcessInstrumenter; private final Instrumenter producerInstrumenter; + private final Instrumenter dynamoDbInstrumenter; private final boolean captureExperimentalSpanAttributes; @Nullable private final TextMapPropagator messagingPropagator; private final boolean useXrayPropagator; @@ -84,6 +85,7 @@ public static AwsSdkTelemetryBuilder builder(OpenTelemetry openTelemetry) { this.consumerReceiveInstrumenter = instrumenterFactory.consumerReceiveInstrumenter(); this.consumerProcessInstrumenter = instrumenterFactory.consumerProcessInstrumenter(); this.producerInstrumenter = instrumenterFactory.producerInstrumenter(); + this.dynamoDbInstrumenter = instrumenterFactory.dynamoDbInstrumenter(); this.captureExperimentalSpanAttributes = captureExperimentalSpanAttributes; this.recordIndividualHttpError = recordIndividualHttpError; } @@ -98,6 +100,7 @@ public ExecutionInterceptor newExecutionInterceptor() { consumerReceiveInstrumenter, consumerProcessInstrumenter, producerInstrumenter, + dynamoDbInstrumenter, captureExperimentalSpanAttributes, messagingPropagator, useXrayPropagator, diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java index 57a18d5987fa..5a63c6b7cf53 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java @@ -13,6 +13,7 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapPropagator; +import io.opentelemetry.instrumentation.api.incubator.semconv.db.DbClientMetrics; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessageOperation; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesExtractor; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; @@ -27,6 +28,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.function.Consumer; import javax.annotation.Nullable; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; @@ -204,6 +206,19 @@ public Instrumenter producerInstrumenter() { true); } + public Instrumenter dynamoDbInstrumenter() { + return createInstrumenter( + openTelemetry, + AwsSdkInstrumenterFactory::spanName, + SpanKindExtractor.alwaysClient(), + attributesExtractors(), + builder -> + builder + .addAttributesExtractor(new DynamoDbAttributesExtractor()) + .addOperationMetrics(DbClientMetrics.get()), + true); + } + private static Instrumenter createInstrumenter( OpenTelemetry openTelemetry, SpanNameExtractor spanNameExtractor, @@ -212,12 +227,31 @@ private static Instrumenter createInstrum List> additionalAttributeExtractors, boolean enabled) { - return Instrumenter.builder( - openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) - .addAttributesExtractors(attributeExtractors) - .addAttributesExtractors(additionalAttributeExtractors) - .setEnabled(enabled) - .buildInstrumenter(spanKindExtractor); + return createInstrumenter( + openTelemetry, + spanNameExtractor, + spanKindExtractor, + attributeExtractors, + builder -> builder.addAttributesExtractors(additionalAttributeExtractors), + enabled); + } + + private static Instrumenter createInstrumenter( + OpenTelemetry openTelemetry, + SpanNameExtractor spanNameExtractor, + SpanKindExtractor spanKindExtractor, + List> attributeExtractors, + Consumer> customizer, + boolean enabled) { + + InstrumenterBuilder builder = + Instrumenter.builder( + openTelemetry, INSTRUMENTATION_NAME, spanNameExtractor) + .addAttributesExtractors(attributeExtractors) + .setEnabled(enabled); + customizer.accept(builder); + + return builder.buildInstrumenter(spanKindExtractor); } private static String spanName(ExecutionAttributes attributes) { diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/DynamoDbAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/DynamoDbAttributesExtractor.java new file mode 100644 index 000000000000..e4dee3f40f1f --- /dev/null +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/DynamoDbAttributesExtractor.java @@ -0,0 +1,62 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; + +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.context.Context; +import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; +import io.opentelemetry.instrumentation.api.internal.AttributesExtractorUtil; +import io.opentelemetry.instrumentation.api.internal.SemconvStability; +import javax.annotation.Nullable; +import software.amazon.awssdk.core.interceptor.ExecutionAttributes; +import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; + +class DynamoDbAttributesExtractor implements AttributesExtractor { + + // copied from DbIncubatingAttributes + private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); + private static final AttributeKey DB_OPERATION_NAME = + AttributeKey.stringKey("db.operation.name"); + private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); + private static final AttributeKey DB_SYSTEM_NAME = + AttributeKey.stringKey("db.system.name"); + + // copied from DbIncubatingAttributes.DbSystemIncubatingValues + private static final String DYNAMODB = "dynamodb"; + // copied from DbIncubatingAttributes.DbSystemNameIncubatingValues + private static final String AWS_DYNAMODB = "aws.dynamodb"; + + @Override + public void onStart( + AttributesBuilder attributes, + Context parentContext, + ExecutionAttributes executionAttributes) { + if (SemconvStability.emitStableDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_SYSTEM_NAME, AWS_DYNAMODB); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_SYSTEM, DYNAMODB); + } + String operation = executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); + if (operation != null) { + if (SemconvStability.emitStableDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_OPERATION_NAME, operation); + } + if (SemconvStability.emitOldDatabaseSemconv()) { + AttributesExtractorUtil.internalSet(attributes, DB_OPERATION, operation); + } + } + } + + @Override + public void onEnd( + AttributesBuilder attributes, + Context context, + ExecutionAttributes executionAttributes, + @Nullable Response response, + @Nullable Throwable error) {} +} diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java index f44b47d3ae60..e204e3140b75 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java @@ -16,7 +16,6 @@ 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; @@ -49,17 +48,6 @@ */ public final class TracingExecutionInterceptor implements ExecutionInterceptor { - // copied from DbIncubatingAttributes - private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); - private static final AttributeKey DB_OPERATION_NAME = - AttributeKey.stringKey("db.operation.name"); - private static final AttributeKey DB_SYSTEM = AttributeKey.stringKey("db.system"); - private static final AttributeKey DB_SYSTEM_NAME = - AttributeKey.stringKey("db.system.name"); - // copied from DbIncubatingAttributes.DbSystemIncubatingValues - private static final String DB_SYSTEM_DYNAMODB = "dynamodb"; - // copied from DbIncubatingAttributes.DbSystemNameIncubatingValues - private static final String DB_SYSTEM_AWS_DYNAMODB = "aws.dynamodb"; // copied from AwsIncubatingAttributes private static final AttributeKey AWS_REQUEST_ID = AttributeKey.stringKey("aws.request_id"); @@ -88,6 +76,7 @@ public final class TracingExecutionInterceptor implements ExecutionInterceptor { private final Instrumenter consumerReceiveInstrumenter; private final Instrumenter consumerProcessInstrumenter; private final Instrumenter producerInstrumenter; + private final Instrumenter dynamoDbInstrumenter; private final boolean captureExperimentalSpanAttributes; static final AttributeKey HTTP_ERROR_MSG = @@ -121,6 +110,7 @@ public TracingExecutionInterceptor( Instrumenter consumerReceiveInstrumenter, Instrumenter consumerProcessInstrumenter, Instrumenter producerInstrumenter, + Instrumenter dynamoDbInstrumenter, boolean captureExperimentalSpanAttributes, TextMapPropagator messagingPropagator, boolean useXrayPropagator, @@ -129,6 +119,7 @@ public TracingExecutionInterceptor( this.consumerReceiveInstrumenter = consumerReceiveInstrumenter; this.consumerProcessInstrumenter = consumerProcessInstrumenter; this.producerInstrumenter = producerInstrumenter; + this.dynamoDbInstrumenter = dynamoDbInstrumenter; this.captureExperimentalSpanAttributes = captureExperimentalSpanAttributes; this.messagingPropagator = messagingPropagator; this.useXrayPropagator = useXrayPropagator; @@ -159,7 +150,10 @@ public SdkRequest modifyRequest( } executionAttributes.putAttribute(SDK_REQUEST_ATTRIBUTE, request); - Instrumenter instrumenter = getInstrumenter(request); + AwsSdkRequest awsSdkRequest = AwsSdkRequest.ofSdkRequest(request); + executionAttributes.putAttribute(AWS_SDK_REQUEST_ATTRIBUTE, awsSdkRequest); + Instrumenter instrumenter = + getInstrumenter(request, awsSdkRequest); if (!instrumenter.shouldStart(parentOtelContext, executionAttributes)) { // NB: We also skip injection in case we don't start. @@ -205,10 +199,9 @@ public SdkRequest modifyRequest( Span span = Span.fromContext(otelContext); try { - AwsSdkRequest awsSdkRequest = AwsSdkRequest.ofSdkRequest(context.request()); if (awsSdkRequest != null) { executionAttributes.putAttribute(AWS_SDK_REQUEST_ATTRIBUTE, awsSdkRequest); - populateRequestAttributes(span, awsSdkRequest, context.request(), executionAttributes); + fieldMapper.mapToAttributes(request, awsSdkRequest, span); } } catch (Throwable throwable) { requestFinisher.finish(otelContext, executionAttributes, null, throwable); @@ -343,33 +336,6 @@ public Optional modifyHttpResponseContent( return responseBody; } - private void populateRequestAttributes( - Span span, - AwsSdkRequest awsSdkRequest, - SdkRequest sdkRequest, - ExecutionAttributes attributes) { - - fieldMapper.mapToAttributes(sdkRequest, awsSdkRequest, span); - - if (awsSdkRequest.type() == DYNAMODB) { - if (SemconvStability.emitStableDatabaseSemconv()) { - span.setAttribute(DB_SYSTEM_NAME, DB_SYSTEM_AWS_DYNAMODB); - } - if (SemconvStability.emitOldDatabaseSemconv()) { - span.setAttribute(DB_SYSTEM, DB_SYSTEM_DYNAMODB); - } - String operation = attributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME); - if (operation != null) { - if (SemconvStability.emitStableDatabaseSemconv()) { - span.setAttribute(DB_OPERATION_NAME, operation); - } - if (SemconvStability.emitOldDatabaseSemconv()) { - span.setAttribute(DB_OPERATION, operation); - } - } - } - } - @Override public void afterExecution( Context.AfterExecution context, ExecutionAttributes executionAttributes) { @@ -480,8 +446,15 @@ static io.opentelemetry.context.Context getParentContext(ExecutionAttributes att return attributes.getAttribute(PARENT_CONTEXT_ATTRIBUTE); } - private Instrumenter getInstrumenter(SdkRequest request) { - return SqsAccess.isSqsProducerRequest(request) ? producerInstrumenter : requestInstrumenter; + private Instrumenter getInstrumenter( + SdkRequest request, AwsSdkRequest awsSdkRequest) { + if (SqsAccess.isSqsProducerRequest(request)) { + return producerInstrumenter; + } + if (awsSdkRequest != null && awsSdkRequest.type() == DYNAMODB) { + return dynamoDbInstrumenter; + } + return requestInstrumenter; } private interface RequestSpanFinisher { diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientCoreTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientCoreTest.java index 41b2149f80e0..c6cde851deb8 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientCoreTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractAws2ClientCoreTest.java @@ -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.DbClientMetricsTestUtil.assertDurationMetric; import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStable; import static io.opentelemetry.instrumentation.testing.junit.db.SemconvStabilityUtil.maybeStableDbSystemName; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; @@ -16,7 +17,9 @@ import static io.opentelemetry.semconv.UrlAttributes.URL_FULL; import static io.opentelemetry.semconv.incubating.AwsIncubatingAttributes.AWS_REQUEST_ID; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_OPERATION_NAME; import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM; +import static io.opentelemetry.semconv.incubating.DbIncubatingAttributes.DB_SYSTEM_NAME; import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_METHOD; import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SERVICE; import static io.opentelemetry.semconv.incubating.RpcIncubatingAttributes.RPC_SYSTEM; @@ -123,6 +126,9 @@ private void validateOperationResponse(String operation, Object response) { assertDynamoDbRequest(span, operation); } })); + + assertDurationMetric( + getTesting(), "io.opentelemetry.aws-sdk-2.2", DB_SYSTEM_NAME, DB_OPERATION_NAME); } private static CreateTableRequest createTableRequest() {