open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Add reusable Gradle helpers for derived JVM test suite variants

Open
#19,792 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs triage
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Is your feature request related to a problem? Please describe.

Instrumentation build scripts repeatedly map over testing.suites.withType(JvmTestSuite::class) to register Experimental, StableSemconv, and BothSemconv test variants. Each map repeats task naming, test class directories, runtime classpath, metadata configuration, and sometimes source-suite JVM settings and enabled state. The repetition is easy to get wrong when a source suite adds another JVM argument or system property.

Describe the solution you'd like

Add a typed helper to the shared Gradle conventions for registering a derived Test task per JvmTestSuite. The helper should bind the source suite's classes and classpath, optionally inherit its explicit JVM arguments, system properties, and enabled state, and retain a configuration block for variant-specific settings.

val stableSemconvSuites = registerTestSuiteVariants("StableSemconv") {
  otelConfig("otel.semconv-stability.opt-in=database")
}

val experimentalSuites = registerTestSuiteVariants(
  suffix = "Experimental",
  inheritSourceSettings = true,
) {
  otelConfig("otel.instrumentation.kafka.experimental-span-attributes=true")
}

The implementation must not use Test.copyTo(): Gradle flattens source jvmArgumentProviders into ordinary arguments, and repository conventions later attach providers to the derived task, which can add the javaagent twice and lose provider input tracking.

Start by migrating the uniform per-suite maps. Keep specialized task filters and multi-variant combinations in their build scripts until the helper proves it can represent them clearly.

Describe alternatives you've considered

Keep the existing maps in each module. This is explicit, but it preserves substantial boilerplate and makes source-suite inheritance a per-file responsibility. A helper specialized only for semconv tasks would be smaller, but the same registration pattern is already needed for experimental variants.

Additional context

PR #19738 introduced experimental variants for custom JVM suites and documented the safe source-setting inheritance pattern in .github/agents/knowledge/gradle-conventions.md and .github/agents/knowledge/testing-experimental-flags.md. This issue is the follow-up for consolidating that pattern rather than expanding the current PR.

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read .github/agents/knowledge/gradle-conventions.md and .github/agents/knowledge/testing-experimental-flags.md, then locate the repeated testing.suites.withType(JvmTestSuite::class) maps in the instrumentation build scripts. Done means uniform per-suite maps use the shared helper with safe source-setting inheritance, while specialized filters and multi-variant combinations remain in their scripts without using Test.copyTo().

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
build-system, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.