Skip to content

Commit b1a25a4

Browse files
committed
cleanup
1 parent e9c39af commit b1a25a4

2 files changed

Lines changed: 34 additions & 62 deletions

File tree

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

Lines changed: 24 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,37 @@ dependencies {
3030

3131
val collectMetadata = findProperty("collectMetadata")?.toString() ?: "false"
3232

33+
fun Test.configureTestTask() {
34+
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
35+
// The agent context debug mechanism isn't compatible with the bridge approach which may add a
36+
// gRPC context to the root.
37+
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
38+
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
39+
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
40+
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
41+
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
42+
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
43+
jvmArgs("-Djava.net.preferIPv4Stack=true")
44+
45+
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
46+
// breaks the tests
47+
classpath = classpath.filter {
48+
!it.absolutePath.contains("opentelemetry-grpc-1.6")
49+
}
50+
51+
systemProperty("collectMetadata", collectMetadata)
52+
}
53+
3354
tasks {
3455
test {
35-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
36-
// The agent context debug mechanism isn't compatible with the bridge approach which may add a
37-
// gRPC context to the root.
38-
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
39-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
40-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
41-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
42-
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
43-
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
44-
jvmArgs("-Djava.net.preferIPv4Stack=true")
45-
46-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
47-
// breaks the tests
48-
classpath = classpath.filter {
49-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
50-
}
51-
52-
systemProperty("collectMetadata", collectMetadata)
56+
configureTestTask()
5357
}
5458

5559
val testExperimental by registering(Test::class) {
5660
testClassesDirs = sourceSets.test.get().output.classesDirs
5761
classpath = sourceSets.test.get().runtimeClasspath
5862

59-
// replicated base config from standard test task
60-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
61-
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
62-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
63-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
64-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
65-
66-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
67-
// breaks the tests
68-
classpath = classpath.filter {
69-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
70-
}
71-
72-
systemProperty("collectMetadata", collectMetadata)
63+
configureTestTask()
7364
systemProperty("metadataConfig", "otel.instrumentation.grpc.experimental-span-attributes=true")
7465
jvmArgs("-Dotel.instrumentation.grpc.experimental-span-attributes=true")
7566
}
@@ -78,25 +69,7 @@ tasks {
7869
testClassesDirs = sourceSets.test.get().output.classesDirs
7970
classpath = sourceSets.test.get().runtimeClasspath
8071

81-
// replicated base config from standard test task
82-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
83-
// The agent context debug mechanism isn't compatible with the bridge approach which may add a
84-
// gRPC context to the root.
85-
jvmArgs("-Dotel.javaagent.experimental.thread-propagation-debugger.enabled=false")
86-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.client.request=some-client-key")
87-
jvmArgs("-Dotel.instrumentation.grpc.capture-metadata.server.request=some-server-key")
88-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
89-
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
90-
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
91-
jvmArgs("-Djava.net.preferIPv4Stack=true")
92-
93-
// exclude our grpc library instrumentation, the ContextStorageOverride contained within it
94-
// breaks the tests
95-
classpath = classpath.filter {
96-
!it.absolutePath.contains("opentelemetry-grpc-1.6")
97-
}
98-
99-
systemProperty("collectMetadata", collectMetadata)
72+
configureTestTask()
10073
jvmArgs("-Dotel.semconv-stability.opt-in=rpc")
10174
}
10275

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ dependencies {
1616
testImplementation(project(":instrumentation:grpc-1.6:testing"))
1717
}
1818

19+
fun Test.configureTestTask() {
20+
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
21+
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
22+
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
23+
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
24+
jvmArgs("-Djava.net.preferIPv4Stack=true")
25+
}
26+
1927
tasks {
2028
test {
21-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
22-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
23-
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
24-
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
25-
jvmArgs("-Djava.net.preferIPv4Stack=true")
29+
configureTestTask()
2630
}
2731

2832
val testStableSemconv by registering(Test::class) {
2933
testClassesDirs = sourceSets.test.get().output.classesDirs
3034
classpath = sourceSets.test.get().runtimeClasspath
3135

32-
systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
33-
jvmArgs("-Dotel.instrumentation.common.experimental.controller-telemetry.enabled=true")
34-
// latest dep test occasionally fails because network type is ipv6 instead of the expected ipv4
35-
// and peer address is 0:0:0:0:0:0:0:1 instead of 127.0.0.1
36-
jvmArgs("-Djava.net.preferIPv4Stack=true")
37-
36+
configureTestTask()
3837
jvmArgs("-Dotel.semconv-stability.opt-in=rpc")
3938
}
4039

0 commit comments

Comments
 (0)