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
33 changes: 22 additions & 11 deletions agent-lambda/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-javaagent")
}

fun isolateClasses(jars: Iterable<File>) = copySpec {
fun isolateClasses(jars: Iterable<File>): CopySpec = copySpec {
jars.forEach {
from(zipTree(it)) {
into("inst")
Expand All @@ -79,6 +79,9 @@ tasks {
archiveFileName.set("javaagentLibs-relocated.jar")

mergeServiceFiles()
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("**/module-info.class")

// exclude known bootstrap dependencies - they can't appear in the inst/ directory
Expand All @@ -88,6 +91,8 @@ tasks {
exclude("io.opentelemetry:opentelemetry-api-logs")
exclude("io.opentelemetry:opentelemetry-context")
exclude("io.opentelemetry:opentelemetry-semconv")
exclude("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
exclude("io.opentelemetry:opentelemetry-api-incubator")
}
}

Expand All @@ -109,23 +114,29 @@ tasks {
dependsOn(isolateJavaagentLibs)
from(isolateJavaagentLibs.get().outputs)

archiveClassifier = null
archiveClassifier.set("")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles {
include("inst/META-INF/services/*")
mergeServiceFiles("inst/META-INF/services")

filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

exclude("**/module-info.class")
exclude("inst/com/solarwinds/opentelemetry/core/**")

manifest {
attributes["Main-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Agent-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Premain-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Can-Redefine-Classes"] = "true"
attributes["Can-Retransform-Classes"] = "true"
attributes["Implementation-Vendor"] = "SolarWinds Inc."
attributes["Implementation-Version"] = swoAgentVersion
attributes(
mapOf(
"Main-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Premain-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Can-Redefine-Classes" to "true",
"Can-Retransform-Classes" to "true",
"Implementation-Vendor" to "SolarWinds Inc.",
"Implementation-Version" to swoAgentVersion
)
)
}
}

Expand Down
45 changes: 27 additions & 18 deletions agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ dependencies {
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-javaagent")
}

fun isolateClasses(jars: Iterable<File>): CopySpec {
return copySpec {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
}
fun isolateClasses(jars: Iterable<File>): CopySpec = copySpec {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
}
}
}
Expand All @@ -80,16 +78,21 @@ tasks {
archiveFileName.set("javaagentLibs-relocated.jar")

mergeServiceFiles()
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("**/module-info.class")

// exclude known bootstrap dependencies - they can"t appear in the inst/ directory
// exclude known bootstrap dependencies - they can't appear in the inst/ directory
dependencies {
exclude("org.slf4j:slf4j-api")
exclude("io.opentelemetry:opentelemetry-api")
exclude("io.opentelemetry:opentelemetry-api-logs")
exclude("io.opentelemetry:opentelemetry-context")
exclude("io.opentelemetry:opentelemetry-semconv")
exclude("io.opentelemetry:opentelemetry-common")
exclude("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
exclude("io.opentelemetry:opentelemetry-api-incubator")
}
}

Expand All @@ -111,24 +114,30 @@ tasks {
dependsOn(isolateJavaagentLibs)
from(isolateJavaagentLibs.get().outputs)

archiveClassifier = null
archiveClassifier.set("")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles {
include("inst/META-INF/services/*")
mergeServiceFiles("inst/META-INF/services")

filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

exclude("**/module-info.class")
exclude("inst/com/solarwinds/opentelemetry/core/**")
exclude("com/solarwinds/joboe/shaded/google/errorprone/annotations/**")

manifest {
attributes["Main-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Agent-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Premain-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Can-Redefine-Classes"] = "true"
attributes["Can-Retransform-Classes"] = "true"
attributes["Implementation-Vendor"] = "SolarWinds Inc."
attributes["Implementation-Version"] = swoAgentVersion
attributes(
mapOf(
"Main-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Premain-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Can-Redefine-Classes" to "true",
"Can-Retransform-Classes" to "true",
"Implementation-Vendor" to "SolarWinds Inc.",
"Implementation-Version" to swoAgentVersion
)
)
}
}

Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

# This script exist to enable conveniently building and publishing the artifacts to local maven repo
date
./gradlew spotlessApply clean build
./gradlew spotlessApply
./gradlew clean build
./gradlew solarwinds-otel-sdk:publishToMavenLocal

8 changes: 4 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ repositories {

dependencies {
implementation(gradleApi())
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:8.2.1")

implementation("io.opentelemetry.instrumentation:gradle-plugins:2.10.0-alpha")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")
implementation("com.github.gmazzo.buildconfig:com.github.gmazzo.buildconfig.gradle.plugin:5.5.1")
implementation("io.opentelemetry.instrumentation:gradle-plugins:2.24.0-alpha")
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.3.1")
implementation("com.github.gmazzo.buildconfig:com.github.gmazzo.buildconfig.gradle.plugin:6.0.7")
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ evaluationDependsOn(":dependencyManagement")
val dependencyManagementConfiguration = configurations.create("dependencyManagement") {
isCanBeConsumed = false
isCanBeResolved = false
isVisible = false
}

afterEvaluate {
Expand Down Expand Up @@ -118,7 +117,11 @@ tasks {
"-Xlint:all",
// disable annotation ownership warnings
"-Xlint:-processing",
"-Werror"
"-Werror",
// FIXME: Refactor generic service provider interfaces (e.g., ConfigParser) to avoid rawtypes warnings
// Disable AutoService verify check to prevent rawtypes warnings for generic service provider interfaces
// The @SuppressWarnings("rawtypes") annotation is not recognized in certain Gradle 9 compilation contexts
"-Averify=false"
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ plugins {
}

tasks.withType<ShadowJar>().configureEach {
mergeServiceFiles()
// mergeServiceFiles requires that duplicate strategy is set to include
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

// Prevents conflict with other SLF4J instances. Important for premain.
relocate("org.slf4j", "io.opentelemetry.javaagent.slf4j")

Expand All @@ -38,7 +44,7 @@ tasks.withType<ShadowJar>().configureEach {
relocate("io.opentelemetry.common", "io.opentelemetry.javaagent.shaded.io.opentelemetry.common")

// relocate the OpenTelemetry extensions that are used by instrumentation modules
// these extensions live in the AgentClassLoader, and are injected into the user"s class loader
// these extensions live in the AgentClassLoader, and are injected into the user's class loader
// by the instrumentation modules that use them
relocate("io.opentelemetry.extension.aws", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.aws")
relocate("io.opentelemetry.extension.kotlin", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.kotlin")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ spotless {
"*.md",
"*.sh"
)
indentWithSpaces()
leadingTabsToSpaces()
trimTrailingWhitespace()
endWithNewline()
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion solarwinds-otel-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies {

tasks {
shadowJar {
archiveClassifier = null
archiveClassifier.set("")
}
}

Expand Down
46 changes: 26 additions & 20 deletions testing/agent-for-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.File

plugins {
id("solarwinds.java-conventions")
Expand Down Expand Up @@ -52,13 +51,11 @@ dependencies {
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-agent-for-testing")
}

fun isolateClasses(jars: Iterable<File>): CopySpec {
return copySpec {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
}
fun isolateClasses(jars: Iterable<File>): CopySpec = copySpec {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
}
}
}
Expand All @@ -72,27 +69,30 @@ tasks {
// 1. all distro specific javaagent libs are relocated
val relocateJavaagentLibs by registering(ShadowJar::class) {
configurations = listOf(javaagentLibs)

duplicatesStrategy = DuplicatesStrategy.FAIL

archiveFileName.set("javaagentLibs-relocated.jar")

mergeServiceFiles()
filesMatching("META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("**/module-info.class")

// exclude known bootstrap dependencies - they can"t appear in the inst/ directory
// exclude known bootstrap dependencies - they can't appear in the inst/ directory
dependencies {
exclude("org.slf4j:slf4j-api")
exclude("io.opentelemetry:opentelemetry-api")
exclude("io.opentelemetry:opentelemetry-api-logs")
exclude("io.opentelemetry:opentelemetry-context")
exclude("io.opentelemetry:opentelemetry-semconv")
exclude("io.opentelemetry.semconv:opentelemetry-semconv-incubating")
exclude("io.opentelemetry:opentelemetry-api-incubator")
}
}

// 2. the distro javaagent libs are then isolated - moved to the inst/ directory
// having a separate task for isolating javaagent libs is required to avoid duplicates with the upstream javaagent
// duplicatesStrategy in shadowJar won"t be applied when adding files with with(CopySpec) because each CopySpec has
// duplicatesStrategy in shadowJar won't be applied when adding files with with(CopySpec) because each CopySpec has
// its own duplicatesStrategy
val isolateJavaagentLibs by registering(Copy::class) {
dependsOn(relocateJavaagentLibs)
Expand All @@ -108,21 +108,27 @@ tasks {
dependsOn(isolateJavaagentLibs)
from(isolateJavaagentLibs.get().outputs)

archiveClassifier = null
archiveClassifier.set("")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
mergeServiceFiles {
include("inst/META-INF/services/*")
mergeServiceFiles("inst/META-INF/services")

filesMatching("inst/META-INF/services/**") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
exclude("**/module-info.class")
exclude("inst/com/solarwinds/opentelemetry/core/**")
exclude("com/solarwinds/joboe/shaded/google/errorprone/annotations/**")

manifest {
attributes["Main-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Agent-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Premain-Class"] = "io.opentelemetry.javaagent.OpenTelemetryAgent"
attributes["Can-Redefine-Classes"] = "true"
attributes["Can-Retransform-Classes"] = "true"
attributes(
mapOf(
"Main-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Agent-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Premain-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
"Can-Redefine-Classes" to "true",
"Can-Retransform-Classes" to "true"
)
)
}
}

Expand Down
Loading