Skip to content

Commit ba5e621

Browse files
committed
remove unneeded vars, make s3 exception more specific
1 parent 70b4349 commit ba5e621

File tree

2 files changed

+21
-41
lines changed
  • instrumentation/aws-sdk/aws-sdk-1.11

2 files changed

+21
-41
lines changed

instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/S3ClientTest.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ private static Stream<Arguments> provideS3Arguments() {
8383
@MethodSource("provideS3Arguments")
8484
@SuppressWarnings("deprecation") // AmazonS3Client constructor is deprecated
8585
void testRequestHandlerIsHookedUpWithConstructor(boolean addHandler, int size) throws Exception {
86-
String accessKey = "asdf";
87-
String secretKey = "qwerty";
88-
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
86+
BasicAWSCredentials credentials = new BasicAWSCredentials("asdf", "qwerty");
8987
AmazonS3Client client = new AmazonS3Client(credentials);
9088
if (addHandler) {
9189
client.addRequestHandler(new RequestHandler2() {});

instrumentation/aws-sdk/aws-sdk-1.11/testing/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractS3ClientTest.java

+20-38
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import static io.opentelemetry.api.trace.SpanKind.CLIENT;
1010
import static io.opentelemetry.instrumentation.test.utils.PortUtils.UNUSABLE_PORT;
1111
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo;
12-
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
1312
import static io.opentelemetry.semconv.ErrorAttributes.ERROR_TYPE;
1413
import static io.opentelemetry.semconv.HttpAttributes.HTTP_REQUEST_METHOD;
1514
import static io.opentelemetry.semconv.ServerAttributes.SERVER_ADDRESS;
@@ -159,42 +158,25 @@ void testTimeoutAndRetryErrorsNotCaptured() {
159158
.waitAndAssertTraces(
160159
trace ->
161160
trace.hasSpansSatisfyingExactly(
162-
span -> {
163-
span.hasName("S3.GetObject")
164-
.hasKind(CLIENT)
165-
.hasStatus(StatusData.error())
166-
.hasNoParent()
167-
.hasAttributesSatisfyingExactly(
168-
equalTo(URL_FULL, server.httpUri().toString()),
169-
equalTo(HTTP_REQUEST_METHOD, "GET"),
170-
equalTo(SERVER_PORT, server.httpPort()),
171-
equalTo(SERVER_ADDRESS, "127.0.0.1"),
172-
equalTo(RPC_SYSTEM, "aws-api"),
173-
equalTo(RPC_SERVICE, "Amazon S3"),
174-
equalTo(RPC_METHOD, "GetObject"),
175-
equalTo(stringKey("aws.endpoint"), server.httpUri().toString()),
176-
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
177-
equalTo(stringKey("aws.bucket.name"), "someBucket"),
178-
satisfies(
179-
ERROR_TYPE,
180-
val ->
181-
val.satisfiesAnyOf(
182-
v ->
183-
assertThat(v)
184-
.isEqualTo(SdkClientException.class.getName()),
185-
v ->
186-
assertThat(v)
187-
.isEqualTo(
188-
AmazonClientException.class.getName()))));
189-
190-
try {
191-
span.hasException(
192-
new AmazonClientException("Unable to execute HTTP request"));
193-
} catch (AssertionError e) {
194-
span.hasException(
195-
new SdkClientException(
196-
"Unable to execute HTTP request: Request did not complete before the request timeout configuration."));
197-
}
198-
}));
161+
span ->
162+
span.hasName("S3.GetObject")
163+
.hasKind(CLIENT)
164+
.hasStatus(StatusData.error())
165+
.hasNoParent()
166+
.hasException(
167+
new SdkClientException(
168+
"Unable to execute HTTP request: Request did not complete before the request timeout configuration."))
169+
.hasAttributesSatisfyingExactly(
170+
equalTo(URL_FULL, server.httpUri().toString()),
171+
equalTo(HTTP_REQUEST_METHOD, "GET"),
172+
equalTo(SERVER_PORT, server.httpPort()),
173+
equalTo(SERVER_ADDRESS, "127.0.0.1"),
174+
equalTo(RPC_SYSTEM, "aws-api"),
175+
equalTo(RPC_SERVICE, "Amazon S3"),
176+
equalTo(RPC_METHOD, "GetObject"),
177+
equalTo(stringKey("aws.endpoint"), server.httpUri().toString()),
178+
equalTo(stringKey("aws.agent"), "java-aws-sdk"),
179+
equalTo(stringKey("aws.bucket.name"), "someBucket"),
180+
equalTo(ERROR_TYPE, SdkClientException.class.getName()))));
199181
}
200182
}

0 commit comments

Comments
 (0)