@@ -30,46 +30,37 @@ dependencies {
3030
3131val 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+
3354tasks {
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
0 commit comments