From 9a7f7125ab3f77c47a46be524f29e150536fba6f Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Mon, 7 Oct 2024 16:01:18 +0300 Subject: [PATCH] Add instrumentation for spring-cloud-aws SqsListener annotation (#12314) --- dependencyManagement/build.gradle.kts | 3 +- docs/supported-libraries.md | 1 + .../aws-sdk-1.11/testing/build.gradle.kts | 2 +- .../{ => internal}/LambdaAdviceBridge.java | 6 +- .../v2_2/{ => internal}/SnsAdviceBridge.java | 6 +- .../v2_2/{ => internal}/SqsAdviceBridge.java | 6 +- .../v2_2/LambdaInstrumentationModule.java | 2 +- .../awssdk/v2_2/SnsInstrumentationModule.java | 2 +- .../awssdk/v2_2/SqsInstrumentationModule.java | 2 +- .../awssdk/v2_2/AwsSdkTelemetry.java | 6 + .../{ => internal}/AbstractSqsRequest.java | 2 +- .../AwsJsonProtocolFactoryAccess.java | 2 +- ...AwsSdkExperimentalAttributesExtractor.java | 2 +- .../AwsSdkHttpAttributesGetter.java | 2 +- ...pClientSuppressionAttributesExtractor.java | 2 +- .../AwsSdkInstrumenterFactory.java | 18 +- .../v2_2/{ => internal}/AwsSdkRequest.java | 16 +- .../{ => internal}/AwsSdkRequestType.java | 4 +- .../AwsSdkRpcAttributesGetter.java | 2 +- .../v2_2/{ => internal}/FieldMapper.java | 2 +- .../v2_2/{ => internal}/FieldMapping.java | 2 +- .../v2_2/{ => internal}/LambdaAccess.java | 2 +- .../v2_2/{ => internal}/LambdaImpl.java | 2 +- .../{ => internal}/MethodHandleFactory.java | 2 +- .../v2_2/{ => internal}/PluginImplUtil.java | 2 +- .../{ => internal}/RequestHeaderSetter.java | 2 +- .../awssdk/v2_2/{ => internal}/Response.java | 8 +- .../v2_2/{ => internal}/Serializer.java | 2 +- .../awssdk/v2_2/{ => internal}/SnsAccess.java | 2 +- .../awssdk/v2_2/{ => internal}/SnsImpl.java | 2 +- .../awssdk/v2_2/{ => internal}/SqsAccess.java | 2 +- .../{ => internal}/SqsAttributesGetter.java | 2 +- .../awssdk/v2_2/{ => internal}/SqsImpl.java | 16 +- .../v2_2/{ => internal}/SqsMessage.java | 7 +- .../v2_2/{ => internal}/SqsMessageImpl.java | 10 +- .../v2_2/{ => internal}/SqsParentContext.java | 10 +- .../{ => internal}/SqsProcessRequest.java | 8 +- .../SqsProcessRequestAttributesGetter.java | 2 +- .../{ => internal}/SqsReceiveRequest.java | 8 +- .../SqsReceiveRequestAttributesGetter.java | 2 +- .../{ => internal}/SqsTracingContext.java | 2 +- .../TracingExecutionInterceptor.java | 15 +- .../v2_2/{ => internal}/TracingIterator.java | 2 +- .../v2_2/{ => internal}/TracingList.java | 33 ++- .../v2_2/{ => internal}/FieldMapperTest.java | 6 +- .../v2_2/{ => internal}/SerializerTest.java | 2 +- .../v2_2/{ => internal}/Aws2LambdaTest.java | 4 +- .../aws-sdk-2.2/testing/build.gradle.kts | 2 +- .../camel-2.20/javaagent/build.gradle.kts | 2 +- .../javaagent/build.gradle.kts | 28 +++ ...onvertingMessageSourceInstrumentation.java | 62 ++++++ ...gementExecutionContextInstrumentation.java | 46 +++++ .../spring/aws/CompletableFutureWrapper.java | 31 +++ ...MessageListenerAdapterInstrumentation.java | 48 +++++ .../SpringAwsSqsInstrumentationModule.java | 42 ++++ .../spring/aws/SpringAwsUtil.java | 146 ++++++++++++++ .../aws/SqsTemplateInstrumentation.java | 40 ++++ .../spring/aws/AwsSqsTest.java | 189 ++++++++++++++++++ .../spring/aws/AwsSqsTestApplication.java | 45 +++++ ...ditionalLibraryIgnoredTypesConfigurer.java | 1 + settings.gradle.kts | 1 + 61 files changed, 847 insertions(+), 81 deletions(-) rename instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/LambdaAdviceBridge.java (66%) rename instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SnsAdviceBridge.java (65%) rename instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsAdviceBridge.java (65%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AbstractSqsRequest.java (79%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsJsonProtocolFactoryAccess.java (98%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkExperimentalAttributesExtractor.java (94%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkHttpAttributesGetter.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkHttpClientSuppressionAttributesExtractor.java (95%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkInstrumenterFactory.java (94%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkRequest.java (89%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkRequestType.java (89%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/AwsSdkRpcAttributesGetter.java (92%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/FieldMapper.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/FieldMapping.java (95%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/LambdaAccess.java (89%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/LambdaImpl.java (98%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/MethodHandleFactory.java (95%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/PluginImplUtil.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/RequestHeaderSetter.java (86%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/Response.java (75%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/Serializer.java (96%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SnsAccess.java (91%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SnsImpl.java (98%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsAccess.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsAttributesGetter.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsImpl.java (96%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsMessage.java (71%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsMessageImpl.java (80%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsParentContext.java (89%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsProcessRequest.java (72%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsProcessRequestAttributesGetter.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsReceiveRequest.java (74%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsReceiveRequestAttributesGetter.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SqsTracingContext.java (93%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/TracingExecutionInterceptor.java (97%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/TracingIterator.java (98%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/TracingList.java (75%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/FieldMapperTest.java (93%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/SerializerTest.java (96%) rename instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/{ => internal}/Aws2LambdaTest.java (94%) create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/build.gradle.kts create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AbstractMessageConvertingMessageSourceInstrumentation.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AcknowledgementExecutionContextInstrumentation.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/CompletableFutureWrapper.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/MessagingMessageListenerAdapterInstrumentation.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsSqsInstrumentationModule.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsUtil.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SqsTemplateInstrumentation.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTest.java create mode 100644 instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTestApplication.java diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index ba9d3ba5101d..bc5246e10be5 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -115,7 +115,8 @@ val DEPENDENCIES = listOf( "org.junit-pioneer:junit-pioneer:1.9.1", "org.objenesis:objenesis:3.4", "javax.validation:validation-api:2.0.1.Final", - "org.snakeyaml:snakeyaml-engine:2.8" + "org.snakeyaml:snakeyaml-engine:2.8", + "org.elasticmq:elasticmq-rest-sqs_2.13:1.6.8" ) javaPlatform { diff --git a/docs/supported-libraries.md b/docs/supported-libraries.md index 725423a4c465..91a0c211446c 100644 --- a/docs/supported-libraries.md +++ b/docs/supported-libraries.md @@ -126,6 +126,7 @@ These are the supported libraries and frameworks: | [Spark Web Framework](/~https://github.com/perwendel/spark) | 2.3+ | N/A | Provides `http.route` [2] | | [Spring Batch](https://spring.io/projects/spring-batch) | 3.0+ (not including 5.0+ yet) | N/A | none | | [Spring Boot](https://spring.io/projects/spring-boot) | | [opentelemetry-spring-boot-resources](https://opentelemetry.io/docs/zero-code/java/spring-boot/) | none | +| [Spring Cloud AWS](https://spring.io/projects/spring-cloud-aws) | 3.0+ | N/A | [Messaging Spans] | | [Spring Cloud Gateway](/~https://github.com/spring-cloud/spring-cloud-gateway) | 2.0+ | N/A | Provides `http.route` [2] | | [Spring Core](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/package-summary.html) | 2.0+ | N/A | Context propagation | | [Spring Data](https://spring.io/projects/spring-data) | 1.8+ | N/A | none | diff --git a/instrumentation/aws-sdk/aws-sdk-1.11/testing/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-1.11/testing/build.gradle.kts index 548631e9f187..b15ba0bd52a3 100644 --- a/instrumentation/aws-sdk/aws-sdk-1.11/testing/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-1.11/testing/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { compileOnly("com.amazonaws:aws-java-sdk-sqs:1.11.106") // needed for SQS - using emq directly as localstack references emq v0.15.7 ie WITHOUT AWS trace header propagation - implementation("org.elasticmq:elasticmq-rest-sqs_2.12:1.0.0") + implementation("org.elasticmq:elasticmq-rest-sqs_2.13") implementation("com.google.guava:guava") diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAdviceBridge.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAdviceBridge.java similarity index 66% rename from instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAdviceBridge.java rename to instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAdviceBridge.java index 3aaa17525137..9452139c5907 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAdviceBridge.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAdviceBridge.java @@ -3,8 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ public final class LambdaAdviceBridge { private LambdaAdviceBridge() {} diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAdviceBridge.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAdviceBridge.java similarity index 65% rename from instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAdviceBridge.java rename to instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAdviceBridge.java index 9077412ec258..b87d872789a2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAdviceBridge.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAdviceBridge.java @@ -3,8 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ public final class SnsAdviceBridge { private SnsAdviceBridge() {} diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAdviceBridge.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAdviceBridge.java similarity index 65% rename from instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAdviceBridge.java rename to instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAdviceBridge.java index ddb3c05c5cbb..0229be7cf9f2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAdviceBridge.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAdviceBridge.java @@ -3,8 +3,12 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ public final class SqsAdviceBridge { private SqsAdviceBridge() {} diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/LambdaInstrumentationModule.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/LambdaInstrumentationModule.java index 575bb5ec7fbc..0c2004cafbe3 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/LambdaInstrumentationModule.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/LambdaInstrumentationModule.java @@ -9,7 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.none; import com.google.auto.service.AutoService; -import io.opentelemetry.instrumentation.awssdk.v2_2.LambdaAdviceBridge; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.LambdaAdviceBridge; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; import net.bytebuddy.asm.Advice; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SnsInstrumentationModule.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SnsInstrumentationModule.java index 6086fb4431e3..8a026407cee5 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SnsInstrumentationModule.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SnsInstrumentationModule.java @@ -9,7 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.none; import com.google.auto.service.AutoService; -import io.opentelemetry.instrumentation.awssdk.v2_2.SnsAdviceBridge; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SnsAdviceBridge; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; import net.bytebuddy.asm.Advice; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SqsInstrumentationModule.java b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SqsInstrumentationModule.java index bc1f0c351713..e3c54161c4c4 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SqsInstrumentationModule.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v2_2/SqsInstrumentationModule.java @@ -9,7 +9,7 @@ import static net.bytebuddy.matcher.ElementMatchers.none; import com.google.auto.service.AutoService; -import io.opentelemetry.instrumentation.awssdk.v2_2.SqsAdviceBridge; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsAdviceBridge; import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; 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 0a938e45967b..3349ad4f8653 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 @@ -8,6 +8,12 @@ import io.opentelemetry.api.OpenTelemetry; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkInstrumenterFactory; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.Response; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsImpl; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsProcessRequest; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsReceiveRequest; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.TracingExecutionInterceptor; import io.opentelemetry.javaagent.tooling.muzzle.NoMuzzle; import java.util.List; import javax.annotation.Nullable; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractSqsRequest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AbstractSqsRequest.java similarity index 79% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractSqsRequest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AbstractSqsRequest.java index 8413ce772df4..3442926e653b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AbstractSqsRequest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AbstractSqsRequest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsJsonProtocolFactoryAccess.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsJsonProtocolFactoryAccess.java similarity index 98% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsJsonProtocolFactoryAccess.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsJsonProtocolFactoryAccess.java index a6e4720d17db..d1ee5b9e823b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsJsonProtocolFactoryAccess.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsJsonProtocolFactoryAccess.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkExperimentalAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkExperimentalAttributesExtractor.java similarity index 94% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkExperimentalAttributesExtractor.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkExperimentalAttributesExtractor.java index 646234ce0e03..839b60e989b2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkExperimentalAttributesExtractor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkExperimentalAttributesExtractor.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.AttributesBuilder; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpAttributesGetter.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpAttributesGetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpAttributesGetter.java index 63284523eb14..0cb3315d5cce 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpAttributesGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import static java.util.Collections.emptyList; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpClientSuppressionAttributesExtractor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpClientSuppressionAttributesExtractor.java similarity index 95% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpClientSuppressionAttributesExtractor.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpClientSuppressionAttributesExtractor.java index 2530ad754ea7..af21a86e5edd 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkHttpClientSuppressionAttributesExtractor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkHttpClientSuppressionAttributesExtractor.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.context.Context; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java similarity index 94% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java index 0b04496debc6..57a18d5987fa 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkInstrumenterFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkInstrumenterFactory.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import static java.util.Collections.emptyList; import static java.util.Collections.singletonList; @@ -31,7 +31,11 @@ import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; -final class AwsSdkInstrumenterFactory { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class AwsSdkInstrumenterFactory { private static final String INSTRUMENTATION_NAME = "io.opentelemetry.aws-sdk-2.2"; private static final AttributesExtractor rpcAttributesExtractor = @@ -74,7 +78,7 @@ final class AwsSdkInstrumenterFactory { private final boolean messagingReceiveInstrumentationEnabled; private final boolean useXrayPropagator; - AwsSdkInstrumenterFactory( + public AwsSdkInstrumenterFactory( OpenTelemetry openTelemetry, @Nullable TextMapPropagator messagingPropagator, List capturedHeaders, @@ -89,7 +93,7 @@ final class AwsSdkInstrumenterFactory { this.useXrayPropagator = useXrayPropagator; } - Instrumenter requestInstrumenter() { + public Instrumenter requestInstrumenter() { return createInstrumenter( openTelemetry, AwsSdkInstrumenterFactory::spanName, @@ -118,7 +122,7 @@ private AttributesExtractor messagingAttr .build(); } - Instrumenter consumerReceiveInstrumenter() { + public Instrumenter consumerReceiveInstrumenter() { MessageOperation operation = MessageOperation.RECEIVE; SqsReceiveRequestAttributesGetter getter = SqsReceiveRequestAttributesGetter.INSTANCE; AttributesExtractor messagingAttributeExtractor = @@ -133,7 +137,7 @@ Instrumenter consumerReceiveInstrumenter() { messagingReceiveInstrumentationEnabled); } - Instrumenter consumerProcessInstrumenter() { + public Instrumenter consumerProcessInstrumenter() { MessageOperation operation = MessageOperation.PROCESS; SqsProcessRequestAttributesGetter getter = SqsProcessRequestAttributesGetter.INSTANCE; @@ -185,7 +189,7 @@ public void onEnd( return result; } - Instrumenter producerInstrumenter() { + public Instrumenter producerInstrumenter() { MessageOperation operation = MessageOperation.PUBLISH; SqsAttributesGetter getter = SqsAttributesGetter.INSTANCE; AttributesExtractor messagingAttributeExtractor = diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequest.java similarity index 89% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequest.java index 163488c06ac6..02d92ca07052 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequest.java @@ -3,15 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.DYNAMODB; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.KINESIS; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.S3; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.SNS; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.SQS; -import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request; -import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.response; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.DYNAMODB; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.KINESIS; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.S3; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.SNS; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.SQS; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.FieldMapping.request; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.FieldMapping.response; import java.util.Collections; import java.util.List; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequestType.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequestType.java similarity index 89% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequestType.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequestType.java index 8c6f4d4f311a..274ec271940e 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRequestType.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRequestType.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; -import static io.opentelemetry.instrumentation.awssdk.v2_2.FieldMapping.request; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.FieldMapping.request; import io.opentelemetry.api.common.AttributeKey; import java.util.Collections; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRpcAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRpcAttributesGetter.java similarity index 92% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRpcAttributesGetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRpcAttributesGetter.java index af355b3a9752..f6a6ba078a2b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsSdkRpcAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/AwsSdkRpcAttributesGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.instrumentation.api.incubator.semconv.rpc.RpcAttributesGetter; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapper.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapper.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapper.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapper.java index 569d0eb5ae18..9e7aeacbceb3 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapper.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapper.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.api.trace.Span; import java.util.List; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapping.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapping.java similarity index 95% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapping.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapping.java index 6858113f4281..6d690144511d 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapping.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapping.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.util.ArrayList; import java.util.Arrays; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAccess.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAccess.java similarity index 89% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAccess.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAccess.java index 33d792c0c826..f03b0a7d3eb2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaAccess.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaAccess.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.javaagent.tooling.muzzle.NoMuzzle; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaImpl.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaImpl.java similarity index 98% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaImpl.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaImpl.java index fae5edf5e12a..809905afdd3a 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/LambdaImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/LambdaImpl.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.api.GlobalOpenTelemetry; import java.nio.charset.StandardCharsets; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/MethodHandleFactory.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/MethodHandleFactory.java similarity index 95% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/MethodHandleFactory.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/MethodHandleFactory.java index 000beaa4f679..a25278efa4a2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/MethodHandleFactory.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/MethodHandleFactory.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/PluginImplUtil.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/PluginImplUtil.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java index e77e52129082..7961338c694b 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/PluginImplUtil.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/PluginImplUtil.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/RequestHeaderSetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/RequestHeaderSetter.java similarity index 86% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/RequestHeaderSetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/RequestHeaderSetter.java index aab3b4d3f45d..dd03ae343680 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/RequestHeaderSetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/RequestHeaderSetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.propagation.TextMapSetter; import software.amazon.awssdk.http.SdkHttpRequest; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Response.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Response.java similarity index 75% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Response.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Response.java index ca6c37c6247c..ed298e118c31 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Response.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Response.java @@ -3,12 +3,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import software.amazon.awssdk.core.SdkResponse; import software.amazon.awssdk.http.SdkHttpResponse; -final class Response { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class Response { private final SdkHttpResponse sdkHttpResponse; private final SdkResponse sdkResponse; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Serializer.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Serializer.java similarity index 96% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Serializer.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Serializer.java index 979ecb08e87d..7ae15901521c 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/Serializer.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Serializer.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.io.IOException; import java.io.InputStream; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAccess.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAccess.java similarity index 91% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAccess.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAccess.java index 7c9cd1bc596d..4075235f54c7 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsAccess.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsAccess.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapPropagator; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsImpl.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsImpl.java similarity index 98% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsImpl.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsImpl.java index 464b50922c5c..bd6e32e92512 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SnsImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SnsImpl.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapPropagator; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAccess.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAccess.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAccess.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAccess.java index 29baec5c6bf1..5b1e32836d64 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAccess.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAccess.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.propagation.TextMapPropagator; import io.opentelemetry.instrumentation.api.internal.Timer; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAttributesGetter.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAttributesGetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAttributesGetter.java index 1d899029d90e..ea955e69dc20 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsAttributesGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; import java.util.Collections; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsImpl.java similarity index 96% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsImpl.java index bca3a6c49c69..6fe1cfcd9ff2 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsImpl.java @@ -3,10 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; -import static io.opentelemetry.instrumentation.awssdk.v2_2.TracingExecutionInterceptor.SDK_HTTP_REQUEST_ATTRIBUTE; -import static io.opentelemetry.instrumentation.awssdk.v2_2.TracingExecutionInterceptor.SDK_REQUEST_ATTRIBUTE; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.TracingExecutionInterceptor.SDK_HTTP_REQUEST_ATTRIBUTE; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.TracingExecutionInterceptor.SDK_REQUEST_ATTRIBUTE; import io.opentelemetry.context.Scope; import io.opentelemetry.context.propagation.TextMapPropagator; @@ -39,8 +39,12 @@ import software.amazon.awssdk.services.sqs.model.SendMessageRequest; import software.amazon.awssdk.services.sqs.model.SendMessageResponse; +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ // this class is only used from SqsAccess from method with @NoMuzzle annotation -final class SqsImpl { +public final class SqsImpl { static { // Force loading of SqsClient; this ensures that an exception is thrown at this point when the // SQS library is not present, which will cause SqsAccess to have enabled=false in library mode. @@ -275,7 +279,7 @@ static String getMessageId(SdkResponse response) { return null; } - static SqsClient wrap(SqsClient sqsClient) { + public static SqsClient wrap(SqsClient sqsClient) { // proxy SqsClient so we could replace the messages list in ReceiveMessageResponse returned from // receiveMessage call return (SqsClient) @@ -305,7 +309,7 @@ static SqsClient wrap(SqsClient sqsClient) { } @SuppressWarnings("unchecked") - static SqsAsyncClient wrap(SqsAsyncClient sqsClient) { + public static SqsAsyncClient wrap(SqsAsyncClient sqsClient) { // proxy SqsAsyncClient so we could replace the messages list in ReceiveMessageResponse returned // from receiveMessage call return (SqsAsyncClient) diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessage.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessage.java similarity index 71% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessage.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessage.java index 966f76ec7732..9e4b71a770e7 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessage.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessage.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.util.Map; import software.amazon.awssdk.services.sqs.model.MessageAttributeValue; @@ -11,8 +11,11 @@ /** * A wrapper interface for {@link software.amazon.awssdk.services.sqs.model.Message}. Using this * wrapper avoids muzzle failure when sqs classes are not present. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. */ -interface SqsMessage { +public interface SqsMessage { Map messageAttributes(); diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessageImpl.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessageImpl.java similarity index 80% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessageImpl.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessageImpl.java index 63f7009d250b..95bf7c388c6e 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsMessageImpl.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsMessageImpl.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.util.ArrayList; import java.util.List; @@ -11,7 +11,11 @@ import software.amazon.awssdk.services.sqs.model.Message; import software.amazon.awssdk.services.sqs.model.MessageAttributeValue; -final class SqsMessageImpl implements SqsMessage { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class SqsMessageImpl implements SqsMessage { private final Message message; @@ -19,7 +23,7 @@ private SqsMessageImpl(Message message) { this.message = message; } - static SqsMessage wrap(Message message) { + public static SqsMessage wrap(Message message) { return new SqsMessageImpl(message); } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsParentContext.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsParentContext.java similarity index 89% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsParentContext.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsParentContext.java index 1540215cf561..1c975fe813c4 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsParentContext.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsParentContext.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.context.propagation.TextMapGetter; @@ -14,7 +14,11 @@ import java.util.Map; import software.amazon.awssdk.services.sqs.model.MessageAttributeValue; -final class SqsParentContext { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class SqsParentContext { enum StringMapGetter implements TextMapGetter> { INSTANCE; @@ -69,7 +73,7 @@ static Context ofSystemAttributes(Map systemAttributes) { StringMapGetter.INSTANCE); } - static Context ofMessage(SqsMessage message, TracingExecutionInterceptor config) { + public static Context ofMessage(SqsMessage message, TracingExecutionInterceptor config) { return ofMessage(message, config.getMessagingPropagator(), config.shouldUseXrayPropagator()); } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequest.java similarity index 72% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequest.java index a2bc70295a55..d21c67f1575f 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequest.java @@ -3,11 +3,15 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; -final class SqsProcessRequest extends AbstractSqsRequest { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class SqsProcessRequest extends AbstractSqsRequest { private final ExecutionAttributes request; private final SqsMessage message; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequestAttributesGetter.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequestAttributesGetter.java index d8ecfefbb113..9f629f73b499 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsProcessRequestAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsProcessRequestAttributesGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; import java.util.Collections; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequest.java similarity index 74% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequest.java index 4d1ef63accb2..43f7020b8489 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequest.java @@ -3,12 +3,16 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import java.util.List; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; -final class SqsReceiveRequest extends AbstractSqsRequest { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class SqsReceiveRequest extends AbstractSqsRequest { private final ExecutionAttributes request; private final List messages; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequestAttributesGetter.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequestAttributesGetter.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequestAttributesGetter.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequestAttributesGetter.java index cab84a37205b..2fcab869001f 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsReceiveRequestAttributesGetter.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsReceiveRequestAttributesGetter.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.instrumentation.api.incubator.semconv.messaging.MessagingAttributesGetter; import java.util.List; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsTracingContext.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsTracingContext.java similarity index 93% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsTracingContext.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsTracingContext.java index d23838b94e4b..97b9ed0fa354 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/SqsTracingContext.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SqsTracingContext.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import static io.opentelemetry.context.ContextKey.named; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java similarity index 97% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java index ada21457d45b..52e2e326c2b7 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingExecutionInterceptor.java @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequestType.DYNAMODB; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequestType.DYNAMODB; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.api.common.Attributes; @@ -40,8 +40,13 @@ import software.amazon.awssdk.http.SdkHttpRequest; import software.amazon.awssdk.http.SdkHttpResponse; -/** AWS request execution interceptor. */ -final class TracingExecutionInterceptor implements ExecutionInterceptor { +/** + * AWS request execution interceptor. + * + *

This class is internal and is hence not for public use. Its APIs are unstable and can change + * at any time. + */ +public final class TracingExecutionInterceptor implements ExecutionInterceptor { // copied from DbIncubatingAttributes private static final AttributeKey DB_OPERATION = AttributeKey.stringKey("db.operation"); @@ -101,7 +106,7 @@ boolean shouldUseXrayPropagator() { private final boolean recordIndividualHttpError; private final FieldMapper fieldMapper; - TracingExecutionInterceptor( + public TracingExecutionInterceptor( Instrumenter requestInstrumenter, Instrumenter consumerReceiveInstrumenter, Instrumenter consumerProcessInstrumenter, diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingIterator.java similarity index 98% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingIterator.java index 8d2e1e4d99c4..74bf989ed540 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingIterator.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingIterator.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.context.Scope; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingList.java similarity index 75% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingList.java index b2b262b3c3a0..6243b38fb959 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingList.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/TracingList.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import io.opentelemetry.context.Context; import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; @@ -14,7 +14,11 @@ import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.services.sqs.model.Message; -class TracingList extends ArrayList { +/** + * This class is internal and is hence not for public use. Its APIs are unstable and can change at + * any time. + */ +public final class TracingList extends ArrayList { private static final long serialVersionUID = 1L; private final Instrumenter instrumenter; @@ -49,6 +53,11 @@ public static TracingList wrap( return new TracingList(list, instrumenter, request, response, config, receiveContext); } + public void disableTracing() { + // only the first call to iterator() is traced + firstIterator = false; + } + @Override public Iterator iterator() { Iterator it; @@ -73,4 +82,24 @@ public void forEach(Consumer action) { action.accept(message); } } + + public Instrumenter getInstrumenter() { + return instrumenter; + } + + public ExecutionAttributes getRequest() { + return request; + } + + public Response getResponse() { + return response; + } + + public TracingExecutionInterceptor getConfig() { + return config; + } + + public Context getReceiveContext() { + return receiveContext; + } } diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapperTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapperTest.java similarity index 93% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapperTest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapperTest.java index 0e8309d6e059..fa761ca057af 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/FieldMapperTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/FieldMapperTest.java @@ -3,10 +3,10 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequest.BatchWriteItem; -import static io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkRequest.UpdateTable; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequest.BatchWriteItem; +import static io.opentelemetry.instrumentation.awssdk.v2_2.internal.AwsSdkRequest.UpdateTable; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/SerializerTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SerializerTest.java similarity index 96% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/SerializerTest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SerializerTest.java index b2616dcaddc2..0ebd904ef6ac 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/SerializerTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/test/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/SerializerTest.java @@ -3,7 +3,7 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import static org.assertj.core.api.Assertions.assertThat; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2LambdaTest.java b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Aws2LambdaTest.java similarity index 94% rename from instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2LambdaTest.java rename to instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Aws2LambdaTest.java index 3bfe7788e066..e5eeeb89e7c3 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/Aws2LambdaTest.java +++ b/instrumentation/aws-sdk/aws-sdk-2.2/library/src/testLambda/java/io/opentelemetry/instrumentation/awssdk/v2_2/internal/Aws2LambdaTest.java @@ -3,11 +3,13 @@ * SPDX-License-Identifier: Apache-2.0 */ -package io.opentelemetry.instrumentation.awssdk.v2_2; +package io.opentelemetry.instrumentation.awssdk.v2_2.internal; import static org.assertj.core.api.Assertions.assertThat; import io.opentelemetry.context.Context; +import io.opentelemetry.instrumentation.awssdk.v2_2.AbstractAws2LambdaTest; +import io.opentelemetry.instrumentation.awssdk.v2_2.AwsSdkTelemetry; import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension; import java.nio.charset.StandardCharsets; diff --git a/instrumentation/aws-sdk/aws-sdk-2.2/testing/build.gradle.kts b/instrumentation/aws-sdk/aws-sdk-2.2/testing/build.gradle.kts index f9c0791bd205..08b000a05ce1 100644 --- a/instrumentation/aws-sdk/aws-sdk-2.2/testing/build.gradle.kts +++ b/instrumentation/aws-sdk/aws-sdk-2.2/testing/build.gradle.kts @@ -22,7 +22,7 @@ dependencies { compileOnly("software.amazon.awssdk:ses:2.2.0") // needed for SQS - using emq directly as localstack references emq v0.15.7 ie WITHOUT AWS trace header propagation - implementation("org.elasticmq:elasticmq-rest-sqs_2.13:1.5.1") + implementation("org.elasticmq:elasticmq-rest-sqs_2.13") implementation("com.google.guava:guava") diff --git a/instrumentation/camel-2.20/javaagent/build.gradle.kts b/instrumentation/camel-2.20/javaagent/build.gradle.kts index 6b2feb8d4cf8..8123ea331c46 100644 --- a/instrumentation/camel-2.20/javaagent/build.gradle.kts +++ b/instrumentation/camel-2.20/javaagent/build.gradle.kts @@ -45,7 +45,7 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter:1.5.17.RELEASE") testImplementation("javax.xml.bind:jaxb-api:2.3.1") - testImplementation("org.elasticmq:elasticmq-rest-sqs_2.12:1.0.0") + testImplementation("org.elasticmq:elasticmq-rest-sqs_2.13") testImplementation("org.testcontainers:cassandra") testImplementation("org.testcontainers:testcontainers") diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/build.gradle.kts b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/build.gradle.kts new file mode 100644 index 000000000000..2e1aac948038 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/build.gradle.kts @@ -0,0 +1,28 @@ +plugins { + id("otel.javaagent-instrumentation") +} + +muzzle { + pass { + group.set("io.awspring.cloud") + module.set("spring-cloud-aws-sqs") + versions.set("[3.0.0,)") + assertInverse.set(true) + } +} + +dependencies { + library("io.awspring.cloud:spring-cloud-aws-starter-sqs:3.0.0") + implementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:library")) + + testInstrumentation(project(":instrumentation:aws-sdk:aws-sdk-2.2:javaagent")) + + testImplementation("org.elasticmq:elasticmq-rest-sqs_2.13") + + testLibrary("org.springframework.boot:spring-boot-starter-test:3.0.0") + testLibrary("org.springframework.boot:spring-boot-starter-web:3.0.0") +} + +otelJava { + minJavaVersionSupported.set(JavaVersion.VERSION_17) +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AbstractMessageConvertingMessageSourceInstrumentation.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AbstractMessageConvertingMessageSourceInstrumentation.java new file mode 100644 index 000000000000..b2078a089791 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AbstractMessageConvertingMessageSourceInstrumentation.java @@ -0,0 +1,62 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.returns; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Collection; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.springframework.messaging.Message; + +public class AbstractMessageConvertingMessageSourceInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher typeMatcher() { + return named("io.awspring.cloud.sqs.listener.source.AbstractMessageConvertingMessageSource"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + named("convertMessages") + .and(takesArgument(0, Collection.class)) + .and(returns(Collection.class)), + this.getClass().getName() + "$ConvertMessagesAdvice"); + transformer.applyAdviceToMethod( + named("convertMessage") + .and(takesArgument(0, Object.class)) + .and(returns(named("org.springframework.messaging.Message"))), + this.getClass().getName() + "$ConvertAdvice"); + } + + @SuppressWarnings("unused") + public static class ConvertMessagesAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static void methodEnter(@Advice.Argument(0) Collection messages) { + SpringAwsUtil.initialize(messages); + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void methodExit() { + SpringAwsUtil.clear(); + } + } + + @SuppressWarnings("unused") + public static class ConvertAdvice { + @Advice.OnMethodExit(suppress = Throwable.class) + public static void methodExit( + @Advice.Argument(0) Object originalMessage, @Advice.Return Message convertedMessage) { + SpringAwsUtil.attachTracingState(originalMessage, convertedMessage); + } + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AcknowledgementExecutionContextInstrumentation.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AcknowledgementExecutionContextInstrumentation.java new file mode 100644 index 000000000000..51ab27ccbbe4 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AcknowledgementExecutionContextInstrumentation.java @@ -0,0 +1,46 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +import io.opentelemetry.context.Scope; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.Collection; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.springframework.messaging.Message; + +public class AcknowledgementExecutionContextInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher typeMatcher() { + return named( + "io.awspring.cloud.sqs.listener.acknowledgement.BatchingAcknowledgementProcessor$AcknowledgementExecutionContext"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod(named("execute"), this.getClass().getName() + "$ExecuteAdvice"); + } + + @SuppressWarnings("unused") + public static class ExecuteAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static Scope methodEnter(@Advice.Argument(0) Collection> messages) { + return SpringAwsUtil.handleBatch(messages); + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void methodExit(@Advice.Enter Scope scope) { + if (scope != null) { + scope.close(); + } + } + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/CompletableFutureWrapper.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/CompletableFutureWrapper.java new file mode 100644 index 000000000000..76832e618cfd --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/CompletableFutureWrapper.java @@ -0,0 +1,31 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import java.util.concurrent.CompletableFuture; + +public final class CompletableFutureWrapper { + + private CompletableFutureWrapper() {} + + public static CompletableFuture wrap(CompletableFuture future, Context context) { + CompletableFuture result = new CompletableFuture<>(); + future.whenComplete( + (T value, Throwable throwable) -> { + try (Scope ignored = context.makeCurrent()) { + if (throwable != null) { + result.completeExceptionally(throwable); + } else { + result.complete(value); + } + } + }); + + return result; + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/MessagingMessageListenerAdapterInstrumentation.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/MessagingMessageListenerAdapterInstrumentation.java new file mode 100644 index 000000000000..89c7be3ebe17 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/MessagingMessageListenerAdapterInstrumentation.java @@ -0,0 +1,48 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.springframework.messaging.Message; + +public class MessagingMessageListenerAdapterInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher typeMatcher() { + return named("io.awspring.cloud.sqs.listener.adapter.MessagingMessageListenerAdapter"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + named("onMessage").and(takesArgument(0, named("org.springframework.messaging.Message"))), + this.getClass().getName() + "$OnMessageAdvice"); + // TODO: onMessage(Collection> messages) not instrumented + } + + @SuppressWarnings("unused") + public static class OnMessageAdvice { + @Advice.OnMethodEnter(suppress = Throwable.class) + public static SpringAwsUtil.MessageScope methodEnter(@Advice.Argument(0) Message message) { + return SpringAwsUtil.handleMessage(message); + } + + @Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) + public static void methodExit( + @Advice.Enter SpringAwsUtil.MessageScope scope, @Advice.Thrown Throwable throwable) { + if (scope != null) { + scope.close(throwable); + } + } + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsSqsInstrumentationModule.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsSqsInstrumentationModule.java new file mode 100644 index 000000000000..df773c5057d5 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsSqsInstrumentationModule.java @@ -0,0 +1,42 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static java.util.Arrays.asList; + +import com.google.auto.service.AutoService; +import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule; +import java.util.List; + +@AutoService(InstrumentationModule.class) +public class SpringAwsSqsInstrumentationModule extends InstrumentationModule + implements ExperimentalInstrumentationModule { + + public SpringAwsSqsInstrumentationModule() { + super("spring-cloud-aws", "spring-cloud-aws-3.0"); + } + + @Override + public boolean isHelperClass(String className) { + return className.startsWith("io.opentelemetry.contrib.awsxray."); + } + + @Override + public String getModuleGroup() { + return "aws-sdk-v2"; + } + + @Override + public List typeInstrumentations() { + return asList( + new AbstractMessageConvertingMessageSourceInstrumentation(), + new MessagingMessageListenerAdapterInstrumentation(), + new SqsTemplateInstrumentation(), + new AcknowledgementExecutionContextInstrumentation()); + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsUtil.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsUtil.java new file mode 100644 index 000000000000..fb8a4dc574ec --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsUtil.java @@ -0,0 +1,146 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.instrumentation.api.instrumenter.Instrumenter; +import io.opentelemetry.instrumentation.api.util.VirtualField; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.Response; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsMessage; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsMessageImpl; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsParentContext; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.SqsProcessRequest; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.TracingExecutionInterceptor; +import io.opentelemetry.instrumentation.awssdk.v2_2.internal.TracingList; +import java.util.Collection; +import org.springframework.messaging.Message; +import software.amazon.awssdk.core.interceptor.ExecutionAttributes; + +public final class SpringAwsUtil { + private static final ThreadLocal context = new ThreadLocal<>(); + private static final VirtualField, TracingContext> tracingContextField = + VirtualField.find(Message.class, TracingContext.class); + + // put the TracingList into thread local, so we can use it in attachTracingState method + public static void initialize(Collection messages) { + if (messages instanceof TracingList) { + TracingList tracingList = (TracingList) messages; + // disable tracing int the iterator of TracingList, we'll do the tracing when message handler + // is called + tracingList.disableTracing(); + context.set(tracingList); + } + } + + public static void clear() { + context.remove(); + } + + // copy tracing state from the sqs message to spring message, we'll use that state when the + // message handler is called + public static void attachTracingState(Object originalMessage, Message convertedMessage) { + TracingList tracingList = context.get(); + if (tracingList == null) { + return; + } + if (!(originalMessage instanceof software.amazon.awssdk.services.sqs.model.Message)) { + return; + } + + tracingContextField.set( + convertedMessage, + new TracingContext( + tracingList, (software.amazon.awssdk.services.sqs.model.Message) originalMessage)); + } + + public static MessageScope handleMessage(Message message) { + TracingContext tracingContext = tracingContextField.get(message); + if (tracingContext == null) { + return null; + } + + return tracingContext.trace(); + } + + // restore context from the first message of the batch + public static Scope handleBatch(Collection> messages) { + if (messages == null || messages.isEmpty()) { + return null; + } + Message message = messages.iterator().next(); + TracingContext tracingContext = tracingContextField.get(message); + if (tracingContext == null) { + return null; + } + SqsMessage wrappedMessage = SqsMessageImpl.wrap(tracingContext.sqsMessage); + Context parentContext = tracingContext.receiveContext; + if (parentContext == null) { + parentContext = SqsParentContext.ofMessage(wrappedMessage, tracingContext.config); + } + return parentContext.makeCurrent(); + } + + public static class MessageScope { + final Instrumenter instrumenter; + final Context context; + final SqsProcessRequest request; + final Response response; + final Scope scope; + + MessageScope( + Instrumenter instrumenter, + Context context, + SqsProcessRequest request, + Response response) { + this.instrumenter = instrumenter; + this.context = context; + this.request = request; + this.response = response; + this.scope = context.makeCurrent(); + } + + public void close(Throwable throwable) { + scope.close(); + instrumenter.end(context, request, response, throwable); + } + } + + private static class TracingContext { + final ExecutionAttributes request; + final Response response; + final Instrumenter instrumenter; + final TracingExecutionInterceptor config; + final Context receiveContext; + final software.amazon.awssdk.services.sqs.model.Message sqsMessage; + + TracingContext( + TracingList tracingList, software.amazon.awssdk.services.sqs.model.Message sqsMessage) { + this.request = tracingList.getRequest(); + this.response = tracingList.getResponse(); + this.instrumenter = tracingList.getInstrumenter(); + this.config = tracingList.getConfig(); + this.receiveContext = tracingList.getReceiveContext(); + this.sqsMessage = sqsMessage; + } + + MessageScope trace() { + SqsMessage wrappedMessage = SqsMessageImpl.wrap(sqsMessage); + Context parentContext = receiveContext; + if (parentContext == null) { + parentContext = SqsParentContext.ofMessage(wrappedMessage, config); + } + SqsProcessRequest processRequest = SqsProcessRequest.create(request, wrappedMessage); + if (!instrumenter.shouldStart(parentContext, processRequest)) { + return null; + } + Context context = instrumenter.start(parentContext, processRequest); + return new MessageScope(instrumenter, context, processRequest, response); + } + } + + private SpringAwsUtil() {} +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SqsTemplateInstrumentation.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SqsTemplateInstrumentation.java new file mode 100644 index 000000000000..6a282af2b21b --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SqsTemplateInstrumentation.java @@ -0,0 +1,40 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.returns; + +import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge; +import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; +import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; +import java.util.concurrent.CompletableFuture; +import net.bytebuddy.asm.Advice; +import net.bytebuddy.description.type.TypeDescription; +import net.bytebuddy.matcher.ElementMatcher; + +public class SqsTemplateInstrumentation implements TypeInstrumentation { + + @Override + public ElementMatcher typeMatcher() { + return named("io.awspring.cloud.sqs.operations.SqsTemplate"); + } + + @Override + public void transform(TypeTransformer transformer) { + transformer.applyAdviceToMethod( + named("getQueueAttributes").and(returns(CompletableFuture.class)), + this.getClass().getName() + "$GetQueueAttributesAdvice"); + } + + @SuppressWarnings("unused") + public static class GetQueueAttributesAdvice { + @Advice.OnMethodExit(suppress = Throwable.class) + public static void methodExit(@Advice.Return(readOnly = false) CompletableFuture result) { + result = CompletableFutureWrapper.wrap(result, Java8BytecodeBridge.currentContext()); + } + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTest.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTest.java new file mode 100644 index 000000000000..676f94fe5a77 --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTest.java @@ -0,0 +1,189 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import static io.opentelemetry.api.common.AttributeKey.stringKey; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies; +import static org.assertj.core.api.Assertions.assertThat; + +import io.awspring.cloud.sqs.operations.SqsTemplate; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension; +import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension; +import io.opentelemetry.semconv.HttpAttributes; +import io.opentelemetry.semconv.ServerAttributes; +import io.opentelemetry.semconv.UrlAttributes; +import io.opentelemetry.semconv.incubating.MessagingIncubatingAttributes; +import io.opentelemetry.semconv.incubating.RpcIncubatingAttributes; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.apache.pekko.http.scaladsl.Http; +import org.assertj.core.api.AbstractStringAssert; +import org.elasticmq.rest.sqs.SQSRestServer; +import org.elasticmq.rest.sqs.SQSRestServerBuilder; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.NONE, + classes = AwsSqsTestApplication.class) +class AwsSqsTest { + @RegisterExtension + static final InstrumentationExtension testing = AgentInstrumentationExtension.create(); + + private static SQSRestServer sqs; + + @Autowired SqsTemplate sqsTemplate; + + @BeforeAll + static void setUp() { + sqs = SQSRestServerBuilder.withPort(0).withInterface("localhost").start(); + Http.ServerBinding server = sqs.waitUntilStarted(); + AwsSqsTestApplication.sqsPort = server.localAddress().getPort(); + } + + @AfterAll + static void cleanUp() { + if (sqs != null) { + sqs.stopAndWait(); + } + } + + @Test + void sqsListener() throws InterruptedException, ExecutionException, TimeoutException { + String messageContent = "hello"; + CompletableFuture messageFuture = new CompletableFuture<>(); + AwsSqsTestApplication.messageHandler = + string -> testing.runWithSpan("callback", () -> messageFuture.complete(string)); + + testing.runWithSpan("parent", () -> sqsTemplate.send("test-queue", messageContent)); + + String result = messageFuture.get(10, TimeUnit.SECONDS); + assertThat(result).isEqualTo(messageContent); + + testing.waitAndAssertTraces( + trace -> + trace.hasSpansSatisfyingExactly( + span -> span.hasName("parent").hasKind(SpanKind.INTERNAL).hasNoParent(), + span -> + span.hasName("Sqs.GetQueueUrl") + .hasKind(SpanKind.CLIENT) + .hasParent(trace.getSpan(0)) + .hasAttributesSatisfyingExactly( + equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"), + equalTo(RpcIncubatingAttributes.RPC_METHOD, "GetQueueUrl"), + equalTo(RpcIncubatingAttributes.RPC_SERVICE, "Sqs"), + equalTo( + HttpAttributes.HTTP_REQUEST_METHOD, + HttpAttributes.HttpRequestMethodValues.POST), + equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"), + equalTo(ServerAttributes.SERVER_PORT, AwsSqsTestApplication.sqsPort), + satisfies( + UrlAttributes.URL_FULL, + v -> + v.startsWith( + "http://localhost:" + AwsSqsTestApplication.sqsPort)), + equalTo(AttributeKey.stringKey("aws.queue.name"), "test-queue")), + span -> + span.hasName("test-queue publish") + .hasKind(SpanKind.PRODUCER) + .hasParent(trace.getSpan(0)) + .hasAttributesSatisfyingExactly( + equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"), + equalTo(RpcIncubatingAttributes.RPC_METHOD, "SendMessage"), + equalTo(RpcIncubatingAttributes.RPC_SERVICE, "Sqs"), + equalTo( + HttpAttributes.HTTP_REQUEST_METHOD, + HttpAttributes.HttpRequestMethodValues.POST), + equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"), + equalTo(ServerAttributes.SERVER_PORT, AwsSqsTestApplication.sqsPort), + satisfies( + UrlAttributes.URL_FULL, + v -> + v.startsWith( + "http://localhost:" + AwsSqsTestApplication.sqsPort)), + equalTo( + MessagingIncubatingAttributes.MESSAGING_SYSTEM, + MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS), + satisfies( + MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, + AbstractStringAssert::isNotBlank), + equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "publish"), + equalTo( + MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, + "test-queue"), + equalTo( + stringKey("aws.queue.url"), + "http://localhost:" + + AwsSqsTestApplication.sqsPort + + "/000000000000/test-queue")), + span -> + span.hasName("test-queue process") + .hasKind(SpanKind.CONSUMER) + .hasParent(trace.getSpan(2)) + .hasAttributesSatisfyingExactly( + equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"), + equalTo(RpcIncubatingAttributes.RPC_METHOD, "ReceiveMessage"), + equalTo(RpcIncubatingAttributes.RPC_SERVICE, "Sqs"), + equalTo( + HttpAttributes.HTTP_REQUEST_METHOD, + HttpAttributes.HttpRequestMethodValues.POST), + equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"), + equalTo(ServerAttributes.SERVER_PORT, AwsSqsTestApplication.sqsPort), + satisfies( + UrlAttributes.URL_FULL, + v -> + v.startsWith( + "http://localhost:" + AwsSqsTestApplication.sqsPort)), + equalTo( + MessagingIncubatingAttributes.MESSAGING_SYSTEM, + MessagingIncubatingAttributes.MessagingSystemValues.AWS_SQS), + satisfies( + MessagingIncubatingAttributes.MESSAGING_MESSAGE_ID, + AbstractStringAssert::isNotBlank), + equalTo(MessagingIncubatingAttributes.MESSAGING_OPERATION, "process"), + equalTo( + MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME, + "test-queue")), + span -> + span.hasName("callback").hasKind(SpanKind.INTERNAL).hasParent(trace.getSpan(3)), + span -> + span.hasName("Sqs.DeleteMessageBatch") + .hasKind(SpanKind.CLIENT) + .hasParent(trace.getSpan(2)) + .hasAttributesSatisfyingExactly( + equalTo(RpcIncubatingAttributes.RPC_SYSTEM, "aws-api"), + equalTo(RpcIncubatingAttributes.RPC_METHOD, "DeleteMessageBatch"), + equalTo(RpcIncubatingAttributes.RPC_SERVICE, "Sqs"), + equalTo( + HttpAttributes.HTTP_REQUEST_METHOD, + HttpAttributes.HttpRequestMethodValues.POST), + equalTo(HttpAttributes.HTTP_RESPONSE_STATUS_CODE, 200), + equalTo(ServerAttributes.SERVER_ADDRESS, "localhost"), + equalTo(ServerAttributes.SERVER_PORT, AwsSqsTestApplication.sqsPort), + satisfies( + UrlAttributes.URL_FULL, + v -> + v.startsWith( + "http://localhost:" + AwsSqsTestApplication.sqsPort)), + equalTo( + stringKey("aws.queue.url"), + "http://localhost:" + + AwsSqsTestApplication.sqsPort + + "/000000000000/test-queue")))); + } +} diff --git a/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTestApplication.java b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTestApplication.java new file mode 100644 index 000000000000..997b38f18caf --- /dev/null +++ b/instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTestApplication.java @@ -0,0 +1,45 @@ +/* + * Copyright The OpenTelemetry Authors + * SPDX-License-Identifier: Apache-2.0 + */ + +package io.opentelemetry.javaagent.instrumentation.spring.aws; + +import io.awspring.cloud.sqs.annotation.SqsListener; +import io.awspring.cloud.sqs.operations.SqsTemplate; +import java.net.URI; +import java.util.function.Consumer; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.sqs.SqsAsyncClient; + +@SpringBootApplication +class AwsSqsTestApplication { + static int sqsPort; + static Consumer messageHandler; + + @Bean + SqsTemplate sqsTemplate(SqsAsyncClient sqsAsyncClient) { + return SqsTemplate.builder().sqsAsyncClient(sqsAsyncClient).build(); + } + + @Bean + SqsAsyncClient sqsAsyncClient() { + return SqsAsyncClient.builder() + .endpointOverride(URI.create("http://localhost:" + sqsPort)) + .credentialsProvider( + StaticCredentialsProvider.create(AwsBasicCredentials.create("accessKey", "secretKey"))) + .region(Region.AP_NORTHEAST_1) + .build(); + } + + @SqsListener("test-queue") + void receiveStringMessage(String message) { + if (messageHandler != null) { + messageHandler.accept(message); + } + } +} diff --git a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ignore/AdditionalLibraryIgnoredTypesConfigurer.java b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ignore/AdditionalLibraryIgnoredTypesConfigurer.java index d326d56e6e02..becdc270f4bb 100644 --- a/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ignore/AdditionalLibraryIgnoredTypesConfigurer.java +++ b/javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ignore/AdditionalLibraryIgnoredTypesConfigurer.java @@ -64,6 +64,7 @@ public void configure(IgnoredTypesBuilder builder) { .ignoreClass("org.springframework.jndi.") .ignoreClass("org.springframework.lang.") .ignoreClass("org.springframework.messaging.") + .allowClass("org.springframework.messaging.support.GenericMessage") .ignoreClass("org.springframework.objenesis.") .ignoreClass("org.springframework.orm.") .ignoreClass("org.springframework.scripting.") diff --git a/settings.gradle.kts b/settings.gradle.kts index 99e34ace004d..8ff32ec1348b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -564,6 +564,7 @@ include(":instrumentation:spring:spring-boot-actuator-autoconfigure-2.0:javaagen include(":instrumentation:spring:spring-boot-autoconfigure") include(":instrumentation:spring:spring-boot-resources:javaagent") include(":instrumentation:spring:spring-boot-resources:javaagent-unit-tests") +include(":instrumentation:spring:spring-cloud-aws-3.0:javaagent") include(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.0:javaagent") include(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-2.2:testing") include(":instrumentation:spring:spring-cloud-gateway:spring-cloud-gateway-common:testing")