Skip to content

Commit 6bdf451

Browse files
authored
Code review sweep (run 25081250139) (#18390)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent 1b9eecc commit 6bdf451

13 files changed

Lines changed: 33 additions & 30 deletions

File tree

instrumentation/servlet/servlet-common/bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/servlet/ServletContextPath.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
* that routing framework instrumentation that updates the span name with a more specific route can
1616
* prepend the servlet context path in front of that route.
1717
*
18-
* <p>This needs to be in the instrumentation-api module, instead of injected as a helper class into
19-
* the different modules that need it, in order to make sure that there is only a single instance of
20-
* the context key, since otherwise instrumentation across different class loaders would use
21-
* different context keys and not be able to share the servlet context path.
18+
* <p>This needs to be in the bootstrap module, instead of injected as a helper class into the
19+
* different modules that need it, in order to make sure that there is only a single instance of the
20+
* context key, since otherwise instrumentation across different class loaders would use different
21+
* context keys and not be able to share the servlet context path.
2222
*/
2323
public final class ServletContextPath {
2424

instrumentation/servlet/servlet-common/bootstrap/src/test/java/io/opentelemetry/javaagent/bootstrap/servlet/ServletContextPathTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void shouldIgnoreEmptySpanName() {
4141
assertThat(ServletContextPath.prepend(contextWithEmptyPath, "")).isEqualTo("");
4242
assertThat(ServletContextPath.prepend(contextWithPath, "")).isEqualTo("/context");
4343

44-
assertThat(ServletContextPath.prepend(contextWithEmptyPath, null)).isEqualTo(null);
44+
assertThat(ServletContextPath.prepend(contextWithEmptyPath, null)).isNull();
4545
assertThat(ServletContextPath.prepend(contextWithPath, null)).isEqualTo("/context");
4646
}
4747
}

instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletMappingResolverFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Mappings(Collection<String> mappings) {
6262
this.mappings = mappings;
6363
}
6464

65-
public Collection<String> getMappings() {
65+
Collection<String> getMappings() {
6666
return mappings;
6767
}
6868
}

instrumentation/servlet/servlet-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/ServletSpanNameProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ServletSpanNameProvider<REQUEST>
1717
implements HttpServerRouteBiGetter<MappingResolver, REQUEST> {
1818
private final ServletAccessor<REQUEST, ?> servletAccessor;
1919

20-
public ServletSpanNameProvider(ServletAccessor<REQUEST, ?> servletAccessor) {
20+
ServletSpanNameProvider(ServletAccessor<REQUEST, ?> servletAccessor) {
2121
this.servletAccessor = servletAccessor;
2222
}
2323

instrumentation/servlet/servlet-common/library/src/main/java/io/opentelemetry/instrumentation/servlet/internal/ServletAccessor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ public interface ServletAccessor<REQUEST, RESPONSE> {
4343

4444
String getRequestRemoteAddr(REQUEST request);
4545

46+
@Nullable
4647
Integer getRequestRemotePort(REQUEST request);
4748

49+
@Nullable
4850
String getRequestLocalAddr(REQUEST request);
4951

52+
@Nullable
5053
Integer getRequestLocalPort(REQUEST request);
5154

5255
@Nullable

instrumentation/servlet/servlet-common/library/src/main/java/io/opentelemetry/instrumentation/servlet/internal/ServletHttpAttributesGetter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public List<String> getHttpResponseHeader(
8989
if (response == null) {
9090
return emptyList();
9191
}
92-
return accessor.getResponseHeaderValues(responseContext.response(), name);
92+
return accessor.getResponseHeaderValues(response, name);
9393
}
9494

9595
@Nullable

instrumentation/spring/spring-batch-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/chunk/ChunkSingletons.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class ChunkSingletons {
2323

24-
private static final Instrumenter<ChunkContextAndBuilder, Void> instrumenter;
24+
private static final Instrumenter<ChunkContextAndBuilder, Void> chunkInstrumenter;
2525

2626
static {
2727
InstrumenterBuilder<ChunkContextAndBuilder, Void> instrumenterBuilder =
@@ -32,11 +32,11 @@ public class ChunkSingletons {
3232
instrumenterBuilder.addSpanLinksExtractor(ChunkSingletons::extractSpanLinks);
3333
}
3434

35-
instrumenter = instrumenterBuilder.buildInstrumenter();
35+
chunkInstrumenter = instrumenterBuilder.buildInstrumenter();
3636
}
3737

3838
public static Instrumenter<ChunkContextAndBuilder, Void> chunkInstrumenter() {
39-
return instrumenter;
39+
return chunkInstrumenter;
4040
}
4141

4242
private static void extractSpanLinks(

instrumentation/spring/spring-batch-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/item/ItemSingletons.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ public class ItemSingletons {
2020
static final String ITEM_OPERATION_WRITE = "ItemWrite";
2121
static final String ITEM_OPERATION_PROCESS = "ItemProcess";
2222

23-
private static final Instrumenter<String, Void> instrumenter =
23+
private static final ContextKey<ChunkContext> CHUNK_CONTEXT_KEY =
24+
ContextKey.named("opentelemetry-spring-batch-chunk-context-context-key");
25+
26+
private static final Instrumenter<String, Void> itemInstrumenter =
2427
Instrumenter.<String, Void>builder(
2528
GlobalOpenTelemetry.get(), instrumentationName(), str -> str)
2629
.buildInstrumenter();
2730

2831
public static Instrumenter<String, Void> itemInstrumenter() {
29-
return instrumenter;
32+
return itemInstrumenter;
3033
}
3134

3235
public static String itemName(ChunkContext chunkContext, String itemOperationName) {
@@ -36,9 +39,6 @@ public static String itemName(ChunkContext chunkContext, String itemOperationNam
3639
return "BatchJob " + jobName + "." + stepName + "." + itemOperationName;
3740
}
3841

39-
private static final ContextKey<ChunkContext> CHUNK_CONTEXT_KEY =
40-
ContextKey.named("opentelemetry-spring-batch-chunk-context-context-key");
41-
4242
/**
4343
* Item-level listeners do not receive chunk/step context as parameters. Fortunately the whole
4444
* chunk always executes on one thread - in Spring Batch chunk is almost synonymous with a DB

instrumentation/spring/spring-batch-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/job/JobSingletons.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class JobSingletons {
2121
DeclarativeConfigUtil.getInstrumentationConfig(GlobalOpenTelemetry.get(), "spring_batch")
2222
.getBoolean("experimental_span_attributes/development", false);
2323

24-
private static final Instrumenter<JobExecution, Void> instrumenter;
24+
private static final Instrumenter<JobExecution, Void> jobInstrumenter;
2525

2626
static {
2727
InstrumenterBuilder<JobExecution, Void> instrumenterBuilder =
@@ -31,15 +31,15 @@ public class JobSingletons {
3131
instrumenterBuilder.addAttributesExtractor(
3232
AttributesExtractor.constant(AttributeKey.stringKey("job.system"), "spring_batch"));
3333
}
34-
instrumenter = instrumenterBuilder.buildInstrumenter();
34+
jobInstrumenter = instrumenterBuilder.buildInstrumenter();
3535
}
3636

3737
private static String extractSpanName(JobExecution jobExecution) {
3838
return "BatchJob " + jobExecution.getJobInstance().getJobName();
3939
}
4040

4141
public static Instrumenter<JobExecution, Void> jobInstrumenter() {
42-
return instrumenter;
42+
return jobInstrumenter;
4343
}
4444

4545
private JobSingletons() {}

instrumentation/spring/spring-batch-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/batch/v3_0/step/StepSingletons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313

1414
public class StepSingletons {
1515

16-
private static final Instrumenter<StepExecution, Void> instrumenter =
16+
private static final Instrumenter<StepExecution, Void> stepInstrumenter =
1717
Instrumenter.<StepExecution, Void>builder(
1818
GlobalOpenTelemetry.get(), instrumentationName(), StepSingletons::spanName)
1919
.buildInstrumenter();
2020

2121
public static Instrumenter<StepExecution, Void> stepInstrumenter() {
22-
return instrumenter;
22+
return stepInstrumenter;
2323
}
2424

2525
private static String spanName(StepExecution stepExecution) {

0 commit comments

Comments
 (0)