Fix awssdk2 latest dep tests
MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts
instrumentation/aws-sdk/aws-sdk-2.2/javaagent/build.gradle.kts
@@ -22,6 +22,9 @@ dependencies {
// Make sure these don't add HTTP headers
testImplementation(project(":instrumentation:apache-httpclient:apache-httpclient-4.0:javaagent"))
testImplementation(project(":instrumentation:netty:netty-4.1:javaagent"))
+
+ latestDepTestLibrary("software.amazon.awssdk:aws-json-protocol:+")
+ latestDepTestLibrary("software.amazon.awssdk:kinesis:+")
}
tasks.withType<Test>().configureEach {

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsJsonProtocolFactoryAccess.java
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/AwsJsonProtocolFactoryAccess.java
@@ -40,6 +40,13 @@ final class AwsJsonProtocolFactoryAccess {
// AwsJsonProtocolFactory requires any URI to be present
.option(SdkClientOption.ENDPOINT, URI.create("http://empty"))
.build());
+ Class awsJsonProtocolClass =
+ Class.forName("software.amazon.awssdk.protocols.json.AwsJsonProtocol");
+ Object awsJsonProtocol = Enum.valueOf(awsJsonProtocolClass, "AWS_JSON");
+ awsJsonProtocolFactoryBuilder
+ .getClass()
+ .getMethod("protocol", awsJsonProtocolClass)
+ .invoke(awsJsonProtocolFactoryBuilder, awsJsonProtocol);
Object awsJsonProtocolFactory =
awsJsonProtocolFactoryBuilder
.getClass()

MODIFY
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
instrumentation/aws-sdk/aws-sdk-2.2/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v2_2/TracingExecutionInterceptor.java
@@ -77,11 +77,17 @@ final class TracingExecutionInterceptor implements ExecutionInterceptor {
Span span = Span.fromContext(otelContext);
+ try {
AwsSdkRequest awsSdkRequest = AwsSdkRequest.ofSdkRequest(context.request());
if (awsSdkRequest != null) {
executionAttributes.putAttribute(AWS_SDK_REQUEST_ATTRIBUTE, awsSdkRequest);
populateRequestAttributes(span, awsSdkRequest, context.request(), executionAttributes);
}
+ } catch (Throwable throwable) {
+ instrumenter.end(otelContext, executionAttributes, null, throwable);
+ clearAttributes(executionAttributes);
+ throw throwable;
+ }
}
@Override

Fix awssdk2 latest dep tests (#4472)