Skip to content

Commit df76235

Browse files
authored
Module cleanup (run 25297360039) (#18547)
Co-authored-by: otelbot <197425009+otelbot@users.noreply.github.com>
1 parent c2d057e commit df76235

15 files changed

Lines changed: 109 additions & 120 deletions

File tree

instrumentation/grpc-1.6/javaagent/build.gradle.kts

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,10 @@ dependencies {
2929
}
3030

3131
tasks {
32-
withType<Test>().configureEach {
33-
systemProperty("testLatestDeps", otelProps.testLatestDeps)
34-
// The agent context debug mechanism isn't compatible with the bridge approach which may add a
35-
// gRPC context to the root.
36-
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
37-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
38-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
39-
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
40-
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
41-
jvmArgs("-Djava.net.preferIPv4Stack=true")
42-
43-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
44-
// breaks the tests
45-
classpath = classpath.filter {
46-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
47-
}
48-
49-
systemProperty("collectMetadata", otelProps.collectMetadata)
50-
}
51-
5232
val testExperimental by registering(Test::class) {
5333
testClassesDirs = sourceSets.test.get().output.classesDirs
5434
classpath = sourceSets.test.get().runtimeClasspath
5535

56-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
57-
// breaks the tests
58-
classpath = classpath.filter {
59-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
60-
}
61-
6236
systemProperty("metadataConfig", "otel.instrumentation.grpc.experimental-span-attributes=true")
6337
jvmArgs("-Dotel.instrumentation.grpc.experimental-span-attributes=true")
6438
}
@@ -67,12 +41,6 @@ tasks {
6741
testClassesDirs = sourceSets.test.get().output.classesDirs
6842
classpath = sourceSets.test.get().runtimeClasspath
6943

70-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
71-
// breaks the tests
72-
classpath = classpath.filter {
73-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
74-
}
75-
7644
jvmArgs("-Dotel.semconv-stability.opt-in=rpc")
7745
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc")
7846
}
@@ -81,14 +49,28 @@ tasks {
8149
testClassesDirs = sourceSets.test.get().output.classesDirs
8250
classpath = sourceSets.test.get().runtimeClasspath
8351

52+
jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup")
53+
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup")
54+
}
55+
56+
withType<Test>().configureEach {
57+
systemProperty("testLatestDeps", otelProps.testLatestDeps)
58+
// The agent context debug mechanism isn't compatible with the bridge approach which may add a
59+
// gRPC context to the root.
60+
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
61+
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
62+
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
63+
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
64+
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
65+
jvmArgs("-Djava.net.preferIPv4Stack=true")
66+
8467
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
8568
// breaks the tests
8669
classpath = classpath.filter {
8770
!it.absolutePath.contains("opentelemetry-grpc-1.6")
8871
}
8972

90-
jvmArgs("-Dotel.semconv-stability.opt-in=rpc/dup")
91-
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=rpc/dup")
73+
systemProperty("collectMetadata", otelProps.collectMetadata)
9274
}
9375

9476
check {

instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingClientInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ final class TracingClientInterceptor implements ClientInterceptor {
3737
private static final String SENT = "SENT";
3838
private static final String RECEIVED = "RECEIVED";
3939

40-
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdate loses generic type
40+
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdater loses generic type
4141
private static final AtomicLongFieldUpdater<TracingClientCall> SENT_MESSAGE_ID_UPDATER =
4242
AtomicLongFieldUpdater.newUpdater(TracingClientCall.class, "sentMessageId");
4343

44-
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdate loses generic type
44+
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdater loses generic type
4545
private static final AtomicLongFieldUpdater<TracingClientCall> RECEIVED_MESSAGE_ID_UPDATER =
4646
AtomicLongFieldUpdater.newUpdater(TracingClientCall.class, "receivedMessageId");
4747

instrumentation/grpc-1.6/library/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/TracingServerInterceptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ final class TracingServerInterceptor implements ServerInterceptor {
3737
private static final String SENT = "SENT";
3838
private static final String RECEIVED = "RECEIVED";
3939

40-
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdate loses generic type
40+
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdater loses generic type
4141
private static final AtomicLongFieldUpdater<TracingServerCall> SENT_MESSAGE_ID_UPDATER =
4242
AtomicLongFieldUpdater.newUpdater(TracingServerCall.class, "sentMessageId");
4343

44-
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdate loses generic type
44+
@SuppressWarnings("rawtypes") // AtomicLongFieldUpdater.newUpdater loses generic type
4545
private static final AtomicLongFieldUpdater<TracingServerCall> RECEIVED_MESSAGE_ID_UPDATER =
4646
AtomicLongFieldUpdater.newUpdater(TracingServerCall.class, "receivedMessageId");
4747

instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/GrpcTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor;
2828
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
2929
import io.opentelemetry.instrumentation.testing.junit.LibraryInstrumentationExtension;
30-
import javax.annotation.Nullable;
3130
import org.junit.jupiter.api.Test;
3231
import org.junit.jupiter.api.extension.RegisterExtension;
3332

@@ -153,8 +152,8 @@ public void onEnd(
153152
AttributesBuilder attributes,
154153
Context context,
155154
GrpcRequest grpcRequest,
156-
@Nullable Status status,
157-
@Nullable Throwable error) {
155+
Status status,
156+
Throwable error) {
158157

159158
Metadata metadata = grpcRequest.getMetadata();
160159
if (metadata != null) {
@@ -184,7 +183,7 @@ public void onEnd(
184183
AttributesBuilder attributes,
185184
Context context,
186185
GrpcRequest grpcRequest,
187-
@Nullable Status status,
188-
@Nullable Throwable error) {}
186+
Status status,
187+
Throwable error) {}
189188
}
190189
}

instrumentation/grpc-1.6/library/src/test/java/io/opentelemetry/instrumentation/grpc/v1_6/MetadataSetterTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import io.opentelemetry.context.Context;
1919
import io.opentelemetry.context.propagation.TextMapGetter;
2020
import io.opentelemetry.context.propagation.TextMapPropagator;
21-
import javax.annotation.Nullable;
2221
import org.junit.jupiter.api.Test;
2322

2423
class MetadataSetterTest {
@@ -53,9 +52,8 @@ public Iterable<String> keys(Metadata metadata) {
5352
return metadata.keys();
5453
}
5554

56-
@Nullable
5755
@Override
58-
public String get(@Nullable Metadata metadata, String key) {
56+
public String get(Metadata metadata, String key) {
5957
if (metadata == null) {
6058
return null;
6159
}

instrumentation/grpc-1.6/testing/src/main/java/io/opentelemetry/instrumentation/grpc/v1_6/AbstractGrpcTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,8 @@ public void sayHello(
16321632
Server server = configureServer(ServerBuilder.forPort(0).addService(greeter)).build().start();
16331633

16341634
ManagedChannel channel = createChannel(server);
1635+
closer.add(() -> channel.shutdownNow().awaitTermination(10, SECONDS));
1636+
closer.add(() -> server.shutdownNow().awaitTermination());
16351637

16361638
Metadata extraMetadata = new Metadata();
16371639
extraMetadata.put(

instrumentation/helidon-4.3/testing/src/main/java/io/opentelemetry/instrumentation/helidon/v4_3/AbstractHelidonTest.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,6 @@
2828

2929
public abstract class AbstractHelidonTest extends AbstractHttpServerTest<WebServer> {
3030

31-
protected void configureRoutes(HttpRouting.Builder routing) {}
32-
33-
private static void sendResponse(ServerResponse res, int status, String response) {
34-
sendResponse(res, status, emptyMap(), response);
35-
}
36-
37-
private static void sendResponse(ServerResponse res, int status, Map<String, String> headers) {
38-
sendResponse(res, status, headers, "");
39-
}
40-
41-
private static void sendResponse(
42-
ServerResponse res, int status, Map<String, String> headers, String response) {
43-
res.header("Content-Type", "text/plain");
44-
headers.forEach(res::header);
45-
res.status(status).send(response);
46-
}
47-
48-
private static String getUrlQuery(ServerRequest req) {
49-
return req.query().rawValue();
50-
}
51-
5231
@Override
5332
protected WebServer setupServer() {
5433
var server = WebServer.builder().port(port);
@@ -148,4 +127,25 @@ protected void configure(HttpServerTestOptions options) {
148127
options.disableTestNonStandardHttpMethod();
149128
options.setTestException(false);
150129
}
130+
131+
protected void configureRoutes(HttpRouting.Builder routing) {}
132+
133+
private static void sendResponse(ServerResponse res, int status, String response) {
134+
sendResponse(res, status, emptyMap(), response);
135+
}
136+
137+
private static void sendResponse(ServerResponse res, int status, Map<String, String> headers) {
138+
sendResponse(res, status, headers, "");
139+
}
140+
141+
private static void sendResponse(
142+
ServerResponse res, int status, Map<String, String> headers, String response) {
143+
res.header("Content-Type", "text/plain");
144+
headers.forEach(res::header);
145+
res.status(status).send(response);
146+
}
147+
148+
private static String getUrlQuery(ServerRequest req) {
149+
return req.query().rawValue();
150+
}
151151
}

instrumentation/hibernate/hibernate-3.3/javaagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tasks {
7474
classpath = suite.sources.runtimeClasspath
7575

7676
jvmArgs("-Dotel.semconv-stability.opt-in=database")
77+
systemProperty("metadataConfig", "otel.semconv-stability.opt-in=database")
7778
}
7879
}
7980

instrumentation/hibernate/hibernate-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/v4_0/EntityNameUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.opentelemetry.javaagent.instrumentation.hibernate.v4_0;
77

88
import java.util.function.Function;
9+
import javax.annotation.Nullable;
910
import org.hibernate.SharedSessionContract;
1011
import org.hibernate.internal.SessionImpl;
1112
import org.hibernate.internal.StatelessSessionImpl;
@@ -16,7 +17,9 @@ public static Function<Object, String> bestGuessEntityName(SharedSessionContract
1617
return entity -> bestGuessEntityName(session, entity);
1718
}
1819

19-
private static String bestGuessEntityName(SharedSessionContract session, Object entity) {
20+
@Nullable
21+
private static String bestGuessEntityName(
22+
SharedSessionContract session, @Nullable Object entity) {
2023
if (entity == null) {
2124
return null;
2225
}

instrumentation/hibernate/hibernate-6.0/javaagent/src/hibernate6Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/v6_0/AbstractHibernateTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ abstract class AbstractHibernateTest {
2727
protected static void setup() {
2828
sessionFactory = new Configuration().configure().buildSessionFactory();
2929
// Pre-populate the DB, so delete/update can be tested.
30-
Session writer = sessionFactory.openSession();
31-
writer.beginTransaction();
32-
prepopulated = new ArrayList<>();
33-
for (int i = 0; i < 5; i++) {
34-
prepopulated.add(new Value("Hello :) " + i));
35-
writer.persist(prepopulated.get(i));
30+
try (Session writer = sessionFactory.openSession()) {
31+
writer.beginTransaction();
32+
prepopulated = new ArrayList<>();
33+
for (int i = 0; i < 5; i++) {
34+
prepopulated.add(new Value("Hello :) " + i));
35+
writer.persist(prepopulated.get(i));
36+
}
37+
writer.getTransaction().commit();
3638
}
37-
writer.getTransaction().commit();
38-
writer.close();
3939
}
4040

4141
@AfterAll

0 commit comments

Comments
 (0)