Skip to content

Commit edbcfeb

Browse files
authored
Code review sweep (run 25203544834) (#18479)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent fd994a6 commit edbcfeb

11 files changed

Lines changed: 31 additions & 20 deletions

File tree

instrumentation/netty/netty-4.1/metadata.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,65 @@ semantic_conventions:
1010
library_link: https://netty.io/
1111
configurations:
1212
- name: otel.instrumentation.http.known-methods
13+
declarative_name: java.common.http.known_methods
1314
description: >
1415
Configures the instrumentation to recognize an alternative set of HTTP request methods. All
1516
other methods will be treated as `_OTHER`.
1617
type: list
1718
default: "CONNECT,DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT,TRACE"
1819
- name: otel.instrumentation.http.client.capture-request-headers
20+
declarative_name: general.http.client.request_captured_headers
1921
description: List of HTTP request headers to capture in HTTP client telemetry.
2022
type: list
2123
default: ""
2224
- name: otel.instrumentation.http.client.capture-response-headers
25+
declarative_name: general.http.client.response_captured_headers
2326
description: List of HTTP response headers to capture in HTTP client telemetry.
2427
type: list
2528
default: ""
2629
- name: otel.instrumentation.common.peer-service-mapping
30+
declarative_name: java.common.peer_service_mapping
2731
description: Used to specify a mapping from host names or IP addresses to peer services.
2832
type: map
2933
default: ""
3034
- name: otel.instrumentation.http.client.emit-experimental-telemetry
35+
declarative_name: java.common.http.client.emit_experimental_telemetry/development
3136
description: >
3237
Enable the capture of experimental HTTP client telemetry. Adds the `http.request.body.size`
3338
and `http.response.body.size` attributes to spans, and records `http.client.request.size` and
3439
`http.client.response.size` metrics.
3540
type: boolean
3641
default: false
3742
- name: otel.instrumentation.http.server.capture-request-headers
43+
declarative_name: general.http.server.request_captured_headers
3844
description: List of HTTP request headers to capture in HTTP server telemetry.
3945
type: list
4046
default: ""
4147
- name: otel.instrumentation.http.server.capture-response-headers
48+
declarative_name: general.http.server.response_captured_headers
4249
description: List of HTTP response headers to capture in HTTP server telemetry.
4350
type: list
4451
default: ""
4552
- name: otel.instrumentation.http.server.emit-experimental-telemetry
53+
declarative_name: java.common.http.server.emit_experimental_telemetry/development
4654
description: >
4755
Enable the capture of experimental HTTP server telemetry. Adds the `http.request.body.size`
4856
and `http.response.body.size` attributes to spans, and records `http.server.request.size` and
4957
`http.server.response.size` metrics.
5058
type: boolean
5159
default: false
5260
- name: otel.instrumentation.netty.connection-telemetry.enabled
61+
declarative_name: java.netty.connection_telemetry.enabled
5362
description: Enable the creation of Connect and DNS spans.
5463
type: boolean
5564
default: false
5665
- name: otel.instrumentation.netty.ssl-telemetry.enabled
66+
declarative_name: java.netty.ssl_telemetry.enabled
5767
description: Enable SSL telemetry.
5868
type: boolean
5969
default: false
6070
- name: otel.instrumentation.sanitization.url.experimental.sensitive-query-parameters
71+
declarative_name: general.sanitization.url.sensitive_query_parameters/development
6172
description: List of URL query parameter names whose values are redacted in URL attributes. See https://opentelemetry.io/docs/specs/semconv/http/http-spans.
6273
type: list
6374
default: "AWSAccessKeyId,Signature,sig,X-Goog-Signature"

instrumentation/netty/netty-4.1/testing/src/main/java/io/opentelemetry/instrumentation/netty/v4_1/ClientHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public ClientHandler(CompletableFuture<Integer> responseCode) {
3131
}
3232

3333
@Override
34-
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) {
34+
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) {
3535
if (msg instanceof FullHttpResponse) {
3636
ctx.pipeline().remove(this);
3737
FullHttpResponse response = (FullHttpResponse) msg;

instrumentation/netty/netty-common-4.0/library/src/main/java/io/opentelemetry/instrumentation/netty/common/v4_0/internal/HttpSchemeUtil.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public final class HttpSchemeUtil {
1616

1717
@Nullable
18-
private static final Class<? extends ChannelHandler> sslHandlerClass = getSslHandlerClass();
18+
private static final Class<? extends ChannelHandler> SSL_HANDLER_CLASS = getSslHandlerClass();
1919

2020
@Nullable
2121
private static Class<? extends ChannelHandler> getSslHandlerClass() {
@@ -33,8 +33,8 @@ public static String getScheme(NettyCommonRequest requestAndChannel) {
3333
}
3434

3535
private static boolean isHttps(NettyCommonRequest requestAndChannel) {
36-
return sslHandlerClass != null
37-
&& requestAndChannel.getChannel().pipeline().get(sslHandlerClass) != null;
36+
return SSL_HANDLER_CLASS != null
37+
&& requestAndChannel.getChannel().pipeline().get(SSL_HANDLER_CLASS) != null;
3838
}
3939

4040
private HttpSchemeUtil() {}

instrumentation/netty/netty-common-4.0/library/src/main/java/io/opentelemetry/instrumentation/netty/common/v4_0/internal/client/NettyClientInstrumenterBuilderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* any time.
1616
*/
1717
public final class NettyClientInstrumenterBuilderFactory {
18-
private NettyClientInstrumenterBuilderFactory() {}
19-
2018
public static DefaultHttpClientInstrumenterBuilder<NettyCommonRequest, HttpResponse> create(
2119
String instrumentationName, OpenTelemetry openTelemetry) {
2220

@@ -26,4 +24,6 @@ public static DefaultHttpClientInstrumenterBuilder<NettyCommonRequest, HttpRespo
2624
new NettyHttpClientAttributesGetter(),
2725
new HttpRequestHeadersSetter());
2826
}
27+
28+
private NettyClientInstrumenterBuilderFactory() {}
2929
}

instrumentation/netty/netty-common-4.0/library/src/main/java/io/opentelemetry/instrumentation/netty/common/v4_0/internal/client/NettySslInstrumentationHandler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public final class NettySslInstrumentationHandler extends ChannelDuplexHandler {
2929

3030
// this is used elsewhere to manage the link between the underlying (user) handler and our handler
3131
// which is needed below so that we can unlink this handler when we remove it below
32-
private static final VirtualField<ChannelHandler, ChannelHandler> instrumentationHandlerField =
32+
private static final VirtualField<ChannelHandler, ChannelHandler> INSTRUMENTATION_HANDLER_FIELD =
3333
VirtualField.find(ChannelHandler.class, ChannelHandler.class);
3434

3535
static {
@@ -45,7 +45,7 @@ public final class NettySslInstrumentationHandler extends ChannelDuplexHandler {
4545
MethodHandles.lookup()
4646
.findVirtual(
4747
sslHandshakeCompletionEvent, "cause", MethodType.methodType(Throwable.class));
48-
} catch (Throwable t) {
48+
} catch (Throwable ignored) {
4949
// no SSL classes on classpath
5050
}
5151
SSL_HANDSHAKE_COMPLETION_EVENT = sslHandshakeCompletionEvent;
@@ -70,7 +70,7 @@ public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
7070
// are on classpath); checking just to be extra safe
7171
if (SSL_HANDSHAKE_COMPLETION_EVENT == null) {
7272
ctx.pipeline().remove(this);
73-
instrumentationHandlerField.set(realHandler, null);
73+
INSTRUMENTATION_HANDLER_FIELD.set(realHandler, null);
7474
super.channelRegistered(ctx);
7575
return;
7676
}
@@ -113,7 +113,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
113113
if (sslHandshakeCompletionEvent != null && sslHandshakeCompletionEvent.isInstance(evt)) {
114114
if (ctx.pipeline().context(this) != null) {
115115
ctx.pipeline().remove(this);
116-
instrumentationHandlerField.set(realHandler, null);
116+
INSTRUMENTATION_HANDLER_FIELD.set(realHandler, null);
117117
}
118118

119119
if (context != null && request != null) {
@@ -132,7 +132,7 @@ private static Throwable getCause(Object evt) {
132132
}
133133
try {
134134
return (Throwable) getCause.invoke(evt);
135-
} catch (Throwable e) {
135+
} catch (Throwable ignored) {
136136
// should not ever happen
137137
return null;
138138
}

instrumentation/netty/netty-common/library/src/main/java/io/opentelemetry/instrumentation/netty/common/internal/Timer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ public final class Timer implements ImplicitContextKeyed {
1919

2020
private static final ContextKey<Timer> KEY = ContextKey.named("opentelemetry-timer-key");
2121

22+
private final Instant startTime;
23+
private final long startNanoTime;
24+
2225
public static Timer start() {
2326
return new Timer(Instant.now(), System.nanoTime());
2427
}
2528

26-
private final Instant startTime;
27-
private final long startNanoTime;
28-
2929
private Timer(Instant startTime, long startNanoTime) {
3030
this.startTime = startTime;
3131
this.startNanoTime = startNanoTime;

instrumentation/okhttp/okhttp-2.2/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/okhttp/v2_2/DispatcherInstrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static PropagatedContext onEnter(@Advice.Argument(0) Runnable call) {
5050
public static void onExit(
5151
@Advice.Argument(0) Runnable call,
5252
@Advice.Enter @Nullable PropagatedContext propagatedContext,
53-
@Advice.Thrown Throwable throwable) {
53+
@Advice.Thrown @Nullable Throwable throwable) {
5454
ExecutorAdviceHelper.cleanUpAfterSubmit(
5555
propagatedContext, throwable, PROPAGATED_CONTEXT, call);
5656
}

instrumentation/okhttp/okhttp-2.2/metadata.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ configurations:
2222
type: list
2323
default: ""
2424
- name: otel.instrumentation.common.peer-service-mapping
25+
declarative_name: java.common.peer_service_mapping
2526
description: Used to specify a mapping from host names or IP addresses to peer services.
2627
type: map
2728
default: ""

instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/TracingCallFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TracingCallFactory implements Call.Factory {
3333
static {
3434
try {
3535
timeoutMethod = Call.class.getMethod("timeout");
36-
} catch (NoSuchMethodException e) {
36+
} catch (NoSuchMethodException ignored) {
3737
timeoutMethod = null;
3838
}
3939
}
@@ -148,7 +148,7 @@ public Timeout timeout() {
148148
}
149149
try {
150150
return (Timeout) timeoutMethod.invoke(delegate);
151-
} catch (IllegalAccessException | InvocationTargetException e) {
151+
} catch (IllegalAccessException | InvocationTargetException ignored) {
152152
// do nothing...we're before 3.12, or something else has gone wrong that we can't do
153153
// anything about.
154154
return Timeout.NONE;

instrumentation/okhttp/okhttp-3.0/library/src/main/java/io/opentelemetry/instrumentation/okhttp/v3_0/internal/TracingInterceptor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ public Response intercept(Chain chain) throws IOException {
5252
return response;
5353
}
5454

55-
// Context injection is being handled manually for a reason: we want to use the OkHttp Request
56-
// type for additional AttributeExtractors provided by the user of this library
57-
// thus we must use Instrumenter<Request, Response>, and Request is immutable
55+
// Context injection is handled manually because OkHttp Request is immutable.
5856
private Request injectContextToRequest(Request request, Context context) {
5957
Request.Builder requestBuilder = request.newBuilder();
6058
propagators

0 commit comments

Comments
 (0)