Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/instructions/instrumentation-gradle.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ or test failure that CI will report.
of the same coordinate does not test both versions: Gradle resolves one dependency graph,
normally selecting the higher version. Exercise the newer runtime in a wired version-specific
test suite.
- Inspect test sources before requiring `testcontainersBuildService`: declare `usesService`
on tasks that really use containers, not every task with a transitive dependency. Use
`withType<Test>().configureEach` for configuration shared by multiple explicitly declared
test tasks; not for a module with only `tasks.test` (implicit `latestDepTest` does not count).
- Inspect test sources before requiring `testcontainersBuildService`; a transitive dependency
alone is not enough. In projects that use Testcontainers, register it once for all test tasks,
including container-free variants. Narrower registration requires a demonstrated scheduling
problem.
- Prefer `tasks.test` for single-test-task projects. Use `withType<Test>().configureEach` for
configuration shared by multiple explicitly declared test tasks or JVM test suites.
Implicit `latestDepTest` does not count. Keep unrelated JVM settings and properties scoped.
- Check metadata collection when its wiring or collected telemetry changes, not as unrelated
cleanup. Collect default telemetry and supported non-default telemetry modes. Register
representative tasks in `.github/scripts/instrumentations.sh` covering each profile's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ testing {
implementation(project(":instrumentation:aws-sdk:aws-sdk-2.2:library"))
implementation("org.testcontainers:testcontainers-localstack")
}

targets {
all {
testTask.configure {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
}
}

register<JvmTestSuite>("testBedrockRuntime") {
Expand Down Expand Up @@ -193,6 +185,7 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

Expand Down
6 changes: 4 additions & 2 deletions instrumentation/jms/jms-1.1/javaagent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ testing {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val testReceiveSpansDisabled = register<Test>("testReceiveSpansDisabled") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

filter {
includeTestsMatching("Jms1SuppressReceiveSpansTest")
Expand All @@ -79,7 +82,6 @@ tasks {
}

test {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
filter {
excludeTestsMatching("Jms1SuppressReceiveSpansTest")
}
Expand Down
3 changes: 2 additions & 1 deletion instrumentation/jmx-metrics/library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ tasks {
filter {
includeTestsMatching(testClass)
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}

Expand All @@ -81,6 +80,8 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

// the base agent only contains the agent machinery and the internal instrumentations that it
// requires, the JMX instrumentation is added on top of it. Using the full agent would capture
// telemetry from the target systems that is unrelated to JMX metrics.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ testing {

tasks {
withType<Test>().configureEach {
if (name != "unitTests") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)

systemProperty("testLatestDeps", otelProps.testLatestDeps)
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

val testReceiveSpansDisabled = register<Test>("testReceiveSpansDisabled") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ testing {

tasks {
withType<Test>().configureEach {
if (!name.endsWith("unitTests", ignoreCase = true)) {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

val agentTestSuites = testing.suites.withType(JvmTestSuite::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ tasks {
}

withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
if (name != "version41Test") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ testing {
}

tasks {
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}

test {
systemProperty("testLatestDeps", otelProps.testLatestDeps)
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
check {
dependsOn(testing.suites)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ tasks {
val testJmsDisabled = register<Test>("testJmsDisabled") {
testClassesDirs = sourceSets.test.get().output.classesDirs
classpath = sourceSets.test.get().runtimeClasspath
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
filter {
includeTestsMatching("*.testSpringJmsListenerWithJmsDisabled")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ testing {

tasks {
withType<Test>().configureEach {
if (!name.endsWith("unitTests", ignoreCase = true)) {
if (name != "testSpringDisabled") {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
}
}
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)

// add byte buddy agent for mockito
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ testing {
}

tasks {
withType<Test>()
.matching { it.name != "unitTests" }
.configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}
withType<Test>().configureEach {
usesService(gradle.sharedServices.registrations["testcontainersBuildService"].service)
systemProperty("testLatestDeps", otelProps.testLatestDeps)
}

val testPreviewSemconv = register<Test>("testPreviewSemconv") {
testClassesDirs = sourceSets.test.get().output.classesDirs
Expand Down
Loading