Skip to content

Commit 3aa41ae

Browse files
otelbot[bot]trask
andauthored
Code review sweep (run 24908813707) (open-telemetry#18271)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
1 parent 38b9507 commit 3aa41ae

10 files changed

Lines changed: 29 additions & 25 deletions

File tree

.github/agents/knowledge/general-rules.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ Do not flag the following patterns (common false positives):
7676

7777
- FQCN is acceptable when class-name collision makes import impossible.
7878
- Do not claim that a Java non-capturing lambda or method reference allocates per
79-
call. On HotSpot / OpenJDK 8+, these are cached at the call site.
79+
call. On HotSpot / OpenJDK 8+, these are cached at the `invokedynamic` call site.
80+
Do not suggest hoisting such a lambda into a `private static final` field for
81+
allocation/performance reasons — it is pure noise. If a PR makes that hoist,
82+
flag it and recommend reverting to the in-line lambda.
8083

8184
## [Style] Visibility modifiers
8285

instrumentation/spring/spring-boot-resources/javaagent-unit-tests/build.gradle.kts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
testCompileOnly("com.google.auto.service:auto-service-annotations")
7-
86
testImplementation(project(":instrumentation:spring:spring-boot-resources:javaagent"))
97
testImplementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi")
10-
testImplementation(project(path = ":smoke-tests:images:spring-boot", configuration = "springBootJar"))
8+
testRuntimeOnly(project(path = ":smoke-tests:images:spring-boot", configuration = "springBootJar"))
119
}

instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AcknowledgementExecutionContextInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static Scope methodEnter(@Advice.Argument(0) Collection<Message<?>> messa
3939
}
4040

4141
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
42-
public static void methodExit(@Advice.Enter Scope scope) {
42+
public static void methodExit(@Advice.Enter @Nullable Scope scope) {
4343
if (scope != null) {
4444
scope.close();
4545
}

instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/MessagingMessageListenerAdapterInstrumentation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public static SpringAwsUtil.MessageScope methodEnter(@Advice.Argument(0) Message
4141

4242
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
4343
public static void methodExit(
44-
@Advice.Enter SpringAwsUtil.MessageScope scope, @Advice.Thrown Throwable throwable) {
44+
@Advice.Enter @Nullable SpringAwsUtil.MessageScope scope,
45+
@Advice.Thrown @Nullable Throwable throwable) {
4546
if (scope != null) {
4647
scope.close(throwable);
4748
}

instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/aws/SpringAwsUtil.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ public static Scope handleBatch(Collection<Message<?>> messages) {
9292
}
9393

9494
public static class MessageScope {
95-
final Instrumenter<SqsProcessRequest, Response> instrumenter;
96-
final Context context;
97-
final SqsProcessRequest request;
98-
final Response response;
99-
final Scope scope;
95+
private final Instrumenter<SqsProcessRequest, Response> instrumenter;
96+
private final Context context;
97+
private final SqsProcessRequest request;
98+
private final Response response;
99+
private final Scope scope;
100100

101-
MessageScope(
101+
private MessageScope(
102102
Instrumenter<SqsProcessRequest, Response> instrumenter,
103103
Context context,
104104
SqsProcessRequest request,
@@ -110,21 +110,21 @@ public static class MessageScope {
110110
this.scope = context.makeCurrent();
111111
}
112112

113-
public void close(Throwable throwable) {
113+
public void close(@Nullable Throwable throwable) {
114114
scope.close();
115115
instrumenter.end(context, request, response, throwable);
116116
}
117117
}
118118

119119
private static class TracingContext {
120-
final ExecutionAttributes request;
121-
final Response response;
122-
final Instrumenter<SqsProcessRequest, Response> instrumenter;
123-
final TracingExecutionInterceptor config;
124-
final Context receiveContext;
125-
final software.amazon.awssdk.services.sqs.model.Message sqsMessage;
126-
127-
TracingContext(
120+
private final ExecutionAttributes request;
121+
private final Response response;
122+
private final Instrumenter<SqsProcessRequest, Response> instrumenter;
123+
private final TracingExecutionInterceptor config;
124+
@Nullable private final Context receiveContext;
125+
private final software.amazon.awssdk.services.sqs.model.Message sqsMessage;
126+
127+
private TracingContext(
128128
TracingList tracingList, software.amazon.awssdk.services.sqs.model.Message sqsMessage) {
129129
this.request = tracingList.getRequest();
130130
this.response = tracingList.getResponse();

instrumentation/spring/spring-cloud-aws-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/aws/AwsSqsTestApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@SpringBootApplication
2020
class AwsSqsTestApplication {
2121
static int sqsPort;
22-
static Consumer<String> messageHandler;
22+
static volatile Consumer<String> messageHandler;
2323

2424
@Bean
2525
SqsTemplate sqsTemplate(SqsAsyncClient sqsAsyncClient) {

instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-2.0/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ features:
88
- HTTP_ROUTE
99
configurations:
1010
- name: otel.instrumentation.spring-cloud-gateway.experimental-span-attributes
11+
declarative_name: java.spring_cloud_gateway.experimental_span_attributes/development
1112
type: boolean
1213
default: false
1314
description: >

instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/gateway/webmvc/v5_0/Gateway43MvcTestApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import org.springframework.web.servlet.function.ServerResponse;
1919

2020
@SpringBootApplication
21-
public class Gateway43MvcTestApplication {
21+
class Gateway43MvcTestApplication {
2222
@Bean
23-
public RouterFunction<ServerResponse> gatewayRouterFunction() {
23+
RouterFunction<ServerResponse> gatewayRouterFunction() {
2424
HandlerFunction<ServerResponse> echoHandler =
2525
request -> {
2626
try {

instrumentation/spring/spring-cloud-gateway/spring-cloud-gateway-webmvc-4.3/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ description: >
66
library_link: https://github.com/spring-cloud/spring-cloud-gateway
77
configurations:
88
- name: otel.instrumentation.spring-cloud-gateway.experimental-span-attributes
9+
declarative_name: java.spring_cloud_gateway.experimental_span_attributes/development
910
type: boolean
1011
default: false
1112
description: >

instrumentation/spring/spring-core-2.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/spring/core/v2_0/SimpleAsyncTaskExecutorInstrumentationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private static void executeTwoTasks(ThrowingConsumer<AsyncTask> task) {
9696
.hasParent(trace.getSpan(0))));
9797
}
9898

99-
static class AsyncTask implements Runnable, Callable<Object> {
99+
private static class AsyncTask implements Runnable, Callable<Object> {
100100

101101
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
102102

0 commit comments

Comments
 (0)