Skip to content

Commit fe4688b

Browse files
otelbot[bot]trask
andauthored
Code review sweep (run 24873566950) (open-telemetry#18255)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com> Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
1 parent a17708a commit fe4688b

9 files changed

Lines changed: 31 additions & 24 deletions

File tree

instrumentation/reactor/reactor-netty/reactor-netty-0.9/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v0_9/DecoratorFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private abstract static class OnMessageDecorator<M> implements BiConsumer<M, Con
3838
@Override
3939
public final void accept(M message, Connection connection) {
4040
Channel channel = connection.channel();
41-
// don't try to get the client span from the netty channel when forceParentSpan is true
41+
// don't try to get the client span from the netty channel when forceParentContext is true
4242
// this way the parent context will always be propagated
4343
if (forceParentContext) {
4444
channel = null;

instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/FailedRequestWithUrlMaker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.lang.reflect.Proxy;
1212
import java.net.InetSocketAddress;
1313
import java.net.SocketAddress;
14+
import javax.annotation.Nullable;
1415
import reactor.netty.http.client.HttpClientConfig;
1516
import reactor.netty.http.client.HttpClientRequest;
1617

@@ -35,7 +36,7 @@ private HttpRequestInvocationHandler(HttpClientConfig config, HttpClientRequest
3536
}
3637

3738
@Override
38-
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
39+
public Object invoke(Object proxy, Method method, @Nullable Object[] args) throws Throwable {
3940
if ("resourceUrl".equals(method.getName())) {
4041
return computeUrlFromConfig();
4142
}

instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/TransportConnectorInstrumentation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ public static AdviceScope onEnter(
157157

158158
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class, inline = false)
159159
public static void endConnect(
160-
@Advice.Thrown Throwable throwable, @Advice.Enter @Nullable AdviceScope adviceScope) {
160+
@Advice.Thrown @Nullable Throwable throwable,
161+
@Advice.Enter @Nullable AdviceScope adviceScope) {
161162
if (adviceScope != null) {
162163
adviceScope.end(throwable);
163164
}

instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonAsyncClientTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ void futureWhenComplete() throws ExecutionException, InterruptedException, Timeo
179179
// regression test for
180180
// https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues/6033
181181
@Test
182-
void scheduleCallable()
183-
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
182+
void scheduleCallable() throws ReflectiveOperationException {
184183
RScheduledExecutorService executorService = redisson.getExecutorService("EXECUTOR");
185184
// Adapt different method signature:
186185
// `java.util.concurrent.ScheduledFuture<V> schedule(Callable,long,TimeUnit)` in 3.0.1
@@ -195,7 +194,7 @@ void scheduleCallable()
195194
}
196195

197196
private static Object invokeSchedule(RScheduledExecutorService executorService)
198-
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
197+
throws ReflectiveOperationException {
199198
return executorService
200199
.getClass()
201200
.getMethod("schedule", Callable.class, long.class, TimeUnit.class)

instrumentation/redisson/redisson-common/testing/src/main/java/io/opentelemetry/javaagent/instrumentation/redisson/AbstractRedissonClientTest.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ void stringCommand() {
198198
}
199199

200200
@Test
201-
void batchCommand()
202-
throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
201+
void batchCommand() throws ReflectiveOperationException {
203202
RBatch batch = createBatch(redisson);
204203
assertThat(batch).isNotNull();
205204
batch.getBucket("batch1").setAsync("v1");
@@ -222,8 +221,7 @@ void batchCommand()
222221
equalTo(maybeStable(DB_STATEMENT), "SET batch1 ?;SET batch2 ?"))));
223222
}
224223

225-
private static void invokeExecute(RBatch batch)
226-
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
224+
private static void invokeExecute(RBatch batch) throws ReflectiveOperationException {
227225
batch.getClass().getMethod("execute").invoke(batch);
228226
}
229227

@@ -367,8 +365,7 @@ void setCommand() {
367365
}
368366

369367
@Test
370-
void sortedSetCommand()
371-
throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
368+
void sortedSetCommand() throws ReflectiveOperationException {
372369
Map<String, Double> scores = new HashMap<>();
373370
scores.put("u1", 1.0d);
374371
scores.put("u2", 3.0d);
@@ -395,7 +392,7 @@ void sortedSetCommand()
395392
}
396393

397394
private static void invokeAddAll(RScoredSortedSet<String> object, Map<String, Double> arg)
398-
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
395+
throws ReflectiveOperationException {
399396
object.getClass().getMethod("addAll", Map.class).invoke(object, arg);
400397
}
401398

instrumentation/resources/library/src/test/java/io/opentelemetry/instrumentation/resources/CgroupV2ContainerIdExtractorTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void fileNotReadable() {
3535
assertThat(result).isEmpty();
3636
}
3737

38-
private void verifyContainerId(String rawFileContent, String containerId) throws Exception {
38+
private void verifyContainerId(String rawFileContent, String containerId) throws IOException {
3939
when(filesystem.isReadable(V2_CGROUP_PATH)).thenReturn(true);
4040
when(filesystem.lineList(V2_CGROUP_PATH)).thenReturn(fileToListOfLines(rawFileContent));
4141
CgroupV2ContainerIdExtractor extractor = new CgroupV2ContainerIdExtractor(filesystem);
@@ -44,49 +44,49 @@ private void verifyContainerId(String rawFileContent, String containerId) throws
4444
}
4545

4646
@Test
47-
void extractSuccess_docker() throws Exception {
47+
void extractSuccess_docker() throws IOException {
4848
verifyContainerId(
4949
"docker_proc_self_mountinfo",
5050
"be522444b60caf2d3934b8b24b916a8a314f4b68d4595aa419874657e8d103f2");
5151
}
5252

5353
@Test
54-
void extractSuccess_docker1() throws Exception {
54+
void extractSuccess_docker1() throws IOException {
5555
verifyContainerId(
5656
"docker_proc_self_mountinfo1",
5757
"188329f95b930c32eeeffd34658ed2538960947e166743fa3743f5ce3d739b40");
5858
}
5959

6060
@Test
61-
void extractSuccess_containerd() throws Exception {
61+
void extractSuccess_containerd() throws IOException {
6262
verifyContainerId(
6363
"containerd_proc_self_mountinfo",
6464
"f2a44bc8e090f93a2b4d7f510bdaff0615ad52906e3287ee956dcf5aa5012a91");
6565
}
6666

6767
@Test
68-
void extractSuccess_podman() throws Exception {
68+
void extractSuccess_podman() throws IOException {
6969
verifyContainerId(
7070
"podman_proc_self_mountinfo",
7171
"2a33efc76e519c137fe6093179653788bed6162d4a15e5131c8e835c968afbe6");
7272
}
7373

7474
@Test
75-
void extractSuccess_crio() throws Exception {
75+
void extractSuccess_crio() throws IOException {
7676
verifyContainerId(
7777
"crio_proc_self_mountinfo",
7878
"a8f62e52ed7c2cd85242dcf0eb1d727b643540ceca7f328ad7d2f31aedf07731");
7979
}
8080

8181
@Test
82-
void extractSuccess_crio1() throws Exception {
82+
void extractSuccess_crio1() throws IOException {
8383
verifyContainerId(
8484
"crio_proc_self_mountinfo1",
8585
"f23ec1d4b715c6531a17e9c549222fbbe1f7ffff697a29a2212b3b4cdc37f52e");
8686
}
8787

8888
@Test
89-
void extractSuccess_crio2() throws Exception {
89+
void extractSuccess_crio2() throws IOException {
9090
verifyContainerId(
9191
"crio_proc_self_mountinfo2",
9292
"b4873629b312dc1d77472aba6fb177c6ce9a8f7c205ad7a03302726805007fe6");

instrumentation/resources/library/src/test/java/io/opentelemetry/instrumentation/resources/ContainerResourceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.opentelemetry.sdk.resources.Resource;
1515
import java.io.File;
1616
import java.io.FileOutputStream;
17+
import java.io.IOException;
1718
import java.nio.charset.Charset;
1819
import java.util.Optional;
1920
import org.junit.jupiter.api.Test;
@@ -56,7 +57,7 @@ void bothVersionsFail() {
5657
}
5758

5859
@Test
59-
void testAlternateEncoding() throws Exception {
60+
void testAlternateEncoding() throws IOException {
6061
String containerId = "ac679f8a8319c8cf7d38e1adf263bc08d231f2ff81abda3915f6e8ba4d64156a";
6162
String line = "13:name=systemd:/podruntime/docker/kubepods/" + containerId + ".aaaa";
6263
Charset ibmCharset = Charset.forName("Cp1047");

instrumentation/resources/library/src/test/java/io/opentelemetry/instrumentation/resources/internal/ManifestResourceExtractorTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import static org.assertj.core.api.Assertions.assertThat;
1212

1313
import io.opentelemetry.sdk.resources.Resource;
14+
import java.io.IOException;
1415
import java.io.InputStream;
1516
import java.util.Collection;
1617
import java.util.Optional;
@@ -54,11 +55,14 @@ Collection<DynamicTest> extractResource() {
5455
prop -> null,
5556
JarServiceNameResourceExtractorTest::failPath),
5657
p -> {
58+
if (t.input == null) {
59+
return Optional.empty();
60+
}
5761
try {
5862
Manifest manifest = new Manifest();
5963
manifest.read(t.input);
6064
return Optional.of(manifest);
61-
} catch (Exception ignored) {
65+
} catch (IOException ignored) {
6266
return Optional.empty();
6367
}
6468
})

instrumentation/restlet/restlet-1.1/metadata.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,27 @@ features:
88
library_link: https://restlet.github.io/
99
configurations:
1010
- name: otel.instrumentation.http.server.capture-request-headers
11+
declarative_name: general.http.server.request_captured_headers
1112
description: List of HTTP request headers to capture in HTTP server telemetry.
1213
type: list
1314
default: ""
1415
- name: otel.instrumentation.http.server.capture-response-headers
16+
declarative_name: general.http.server.response_captured_headers
1517
description: List of HTTP response headers to capture in HTTP server telemetry.
1618
type: list
1719
default: ""
1820
- name: otel.instrumentation.http.server.emit-experimental-telemetry
21+
declarative_name: java.common.http.server.emit_experimental_telemetry/development
1922
description: >
2023
Enable the capture of experimental HTTP server telemetry. Adds the `http.request.body.size`
2124
and `http.response.body.size` attributes to spans, and records `http.server.request.size` and
2225
`http.server.response.size` metrics.
2326
type: boolean
2427
default: false
2528
- name: otel.instrumentation.http.known-methods
29+
declarative_name: java.common.http.known_methods
2630
description: >
2731
Configures the instrumentation to recognize an alternative set of HTTP request methods. All
2832
other methods will be treated as `_OTHER`.
2933
type: list
30-
default: "CONNECT,DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT,TRACE"
34+
default: "CONNECT,DELETE,GET,HEAD,OPTIONS,PATCH,POST,PUT,TRACE"

0 commit comments

Comments
 (0)