Skip to content

Commit 8017cf1

Browse files
authored
Code review sweep (run 24946562825) (#18304)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 1714d47 commit 8017cf1

14 files changed

Lines changed: 31 additions & 28 deletions

File tree

instrumentation/aws-lambda/aws-lambda-events-3.11/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ semantic_conventions:
88
library_link: https://docs.aws.amazon.com/lambda/latest/dg/java-handler.html
99
configurations:
1010
- name: otel.instrumentation.aws-lambda.flush-timeout
11+
declarative_name: java.aws_lambda.flush_timeout
1112
type: int
1213
default: 10000
1314
description: Flush timeout in milliseconds.
14-

instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/CustomJodaModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CustomJodaModule extends SimpleModule {
3333

3434
private static final long serialVersionUID = 1L;
3535

36-
public CustomJodaModule() {
36+
CustomJodaModule() {
3737
addDeserializer(DateTime.class, new DateTimeDeserialiser());
3838
}
3939

instrumentation/aws-lambda/aws-lambda-events-common-2.2/library/src/main/java/io/opentelemetry/instrumentation/awslambdaevents/common/v2_2/internal/SqsMessageSpanLinksExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
class SqsMessageSpanLinksExtractor implements SpanLinksExtractor<SQSMessage> {
2323
private static final String AWS_TRACE_HEADER_SQS_ATTRIBUTE_KEY = "AWSTraceHeader";
24+
private static final MapGetter mapGetter = new MapGetter();
2425

2526
// lower-case map getter used for extraction
2627
static final String AWS_TRACE_HEADER_PROPAGATOR_KEY = "x-amzn-trace-id";
@@ -34,7 +35,7 @@ public void extract(SpanLinksBuilder spanLinks, Context parentContext, SQSMessag
3435
.extract(
3536
Context.root(), // We don't want the ambient context.
3637
singletonMap(AWS_TRACE_HEADER_PROPAGATOR_KEY, parentHeader),
37-
new MapGetter());
38+
mapGetter);
3839
SpanContext messageSpanCtx = Span.fromContext(xrayContext).getSpanContext();
3940
if (messageSpanCtx.isValid()) {
4041
spanLinks.addLink(messageSpanCtx);

instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/SqsInstrumentationModule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void doTransform(TypeTransformer transformer) {
2727

2828
@SuppressWarnings("unused")
2929
public static class RegisterAdvice {
30-
@Advice.OnMethodExit(suppress = Throwable.class, inline = false)
30+
@Advice.OnMethodExit(inline = false)
3131
public static void onExit() {
3232
// (indirectly) using SqsImpl class here to make sure it is available from SqsAccess
3333
// (injected into app classloader) and checked by Muzzle

instrumentation/aws-sdk/aws-sdk-1.11/javaagent/src/test_before_1_11_106/java/io/opentelemetry/javaagent/instrumentation/awssdk/v1_11/Aws0ClientTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ private static Stream<Arguments> provideArguments() {
115115
@ParameterizedTest
116116
@SuppressWarnings("unchecked")
117117
@MethodSource("provideArguments")
118-
void testRequestHandlerIsHookedUpWithConstructor(boolean addHandler, int size) throws Exception {
118+
void testRequestHandlerIsHookedUpWithConstructor(boolean addHandler, int size)
119+
throws ReflectiveOperationException {
119120
BasicAWSCredentials credentials = new BasicAWSCredentials("asdf", "qwerty");
120121
AmazonS3Client client = new AmazonS3Client(credentials);
121122
if (addHandler) {
@@ -126,7 +127,7 @@ void testRequestHandlerIsHookedUpWithConstructor(boolean addHandler, int size) t
126127

127128
assertThat(requestHandler2s).isNotNull();
128129
assertThat(requestHandler2s).hasSize(size);
129-
assertThat(requestHandler2s.stream().findFirst().get().getClass().getSimpleName())
130+
assertThat(requestHandler2s.get(0).getClass().getSimpleName())
130131
.isEqualTo("TracingRequestHandler");
131132
}
132133

@@ -191,7 +192,7 @@ void testSendRequestWithMockedResponse(
191192
Function<AmazonWebServiceClient, Object> call,
192193
Map<String, String> additionalAttributes,
193194
String body)
194-
throws Exception {
195+
throws ReflectiveOperationException {
195196
server.enqueue(HttpResponse.of(HttpStatus.OK, MediaType.PLAIN_TEXT_UTF_8, body));
196197

197198
Object response = call.apply(client);
@@ -201,7 +202,7 @@ void testSendRequestWithMockedResponse(
201202

202203
assertThat(requestHandler2s).isNotNull();
203204
assertThat(requestHandler2s).hasSize(handlerCount);
204-
assertThat(requestHandler2s.stream().findFirst().get().getClass().getSimpleName())
205+
assertThat(requestHandler2s.get(0).getClass().getSimpleName())
205206
.isEqualTo("TracingRequestHandler");
206207

207208
testing.waitAndAssertTraces(
@@ -362,7 +363,8 @@ void testCallingGeneratePresignedUrlDoesNotLeakContext() {
362363
}
363364

364365
@SuppressWarnings("unchecked")
365-
private static List<RequestHandler2> extractRequestHandlers(Object client) throws Exception {
366+
private static List<RequestHandler2> extractRequestHandlers(Object client)
367+
throws ReflectiveOperationException {
366368
Field requestHandler2sField = AmazonWebServiceClient.class.getDeclaredField("requestHandler2s");
367369
requestHandler2sField.setAccessible(true);
368370
return (List<RequestHandler2>) requestHandler2sField.get(client);

instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AbstractSqsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99

1010
abstract class AbstractSqsRequest {
1111

12-
public abstract Request<?> getRequest();
12+
abstract Request<?> getRequest();
1313
}

instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/AwsSdkAttributesExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private static ResponseMetadata getResponseMetadata(@Nullable Response<?> respon
119119
return null;
120120
}
121121

122-
public static void setAttribute(
122+
private static void setAttribute(
123123
AttributesBuilder attributes,
124124
AttributeKey<String> key,
125125
Object carrier,

instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/PluginImplUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import java.util.logging.Logger;
1111

12-
final class PluginImplUtil { // TODO: Copy & paste from v2
12+
final class PluginImplUtil {
1313
private static final Logger logger = Logger.getLogger(PluginImplUtil.class.getName());
1414

1515
/**
@@ -20,14 +20,14 @@ final class PluginImplUtil { // TODO: Copy & paste from v2
2020
* the Impl is available only when the corresponding InstrumentationModule was successfully
2121
* applied (muzzle passed).
2222
*
23-
* <p>Note that an present-but-incompatible library can only be reliably detected by Muzzle. In
23+
* <p>Note that a present-but-incompatible library can only be reliably detected by Muzzle. In
2424
* library-mode, users need to ensure they are using a compatible SDK (component) versions
2525
* themselves.
2626
*
27-
* @param implSimpleClassName The simple name of the impl class, e.g. {@code "SqsImpl"}. *
27+
* @param implSimpleClassName The simple name of the impl class, e.g. {@code "SqsImpl"}.
2828
*/
2929
static boolean isImplPresent(String implSimpleClassName) {
30-
// Computing the full name dynamically name here because library instrumentation classes are
30+
// Compute the full name dynamically here because library instrumentation classes are
3131
// relocated when embedded in the agent.
3232
// We use getName().replace() instead of getPackage() because the latter is not guaranteed to
3333
// work in all cases (e.g., we might be loaded into a custom classloader that doesn't handle it)

instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/RequestAccess.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private static <T> T invokeOrNull(
122122
}
123123
try {
124124
return returnType.cast(method.invoke(obj));
125-
} catch (Throwable t) {
125+
} catch (Throwable ignored) {
126126
return null;
127127
}
128128
}
@@ -172,7 +172,7 @@ private static MethodHandle findAccessorOrNull(
172172
try {
173173
return MethodHandles.publicLookup()
174174
.findVirtual(clz, methodName, MethodType.methodType(returnType));
175-
} catch (Throwable t) {
175+
} catch (Throwable ignored) {
176176
return null;
177177
}
178178
}
@@ -183,7 +183,7 @@ private static MethodHandle findLambdaGetConfigurationMethod(Class<?> clz) {
183183
Class<?> returnType =
184184
Class.forName("com.amazonaws.services.lambda.model.FunctionConfiguration");
185185
return findAccessorOrNull(clz, "getConfiguration", returnType);
186-
} catch (Throwable t) {
186+
} catch (Throwable ignored) {
187187
return null;
188188
}
189189
}
@@ -197,7 +197,7 @@ private static MethodHandle findGetLambdaArnMethod() {
197197
Class<?> lambdaConfigurationClass =
198198
Class.forName("com.amazonaws.services.lambda.model.FunctionConfiguration");
199199
return findAccessorOrNull(lambdaConfigurationClass, "getFunctionArn");
200-
} catch (Throwable t) {
200+
} catch (Throwable ignored) {
201201
return null;
202202
}
203203
}

instrumentation/aws-sdk/aws-sdk-1.11/library/src/main/java/io/opentelemetry/instrumentation/awssdk/v1_11/SqsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private static Field getMessagesField() {
8686
Field field = ReceiveMessageResult.class.getDeclaredField("messages");
8787
field.setAccessible(true);
8888
return field;
89-
} catch (Exception e) {
89+
} catch (Exception ignored) {
9090
return null;
9191
}
9292
}

0 commit comments

Comments
 (0)