Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NH-20004: NH Java agent: upgrade Otel dependency to the latest version #74

Merged
merged 13 commits into from
Feb 10, 2023
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The service key can also be defined via the environment variable `SW_APM_SERVICE

Upon successful initialization, the log should print such as:
```
[otel.javaagent 2021-06-30 13:04:07:759 -0700] [main] INFO com.appoptics.opentelemetry.extensions.AppOpticsTracerProviderConfigurer - Successfully initialized Solarwinds APM OpenTelemetry extensions with service key ec3d********************************************************5468:ot
[otel.javaagent 2021-06-30 13:04:07:759 -0700] [main] INFO com.appoptics.opentelemetry.extensions.AppOpticsTracerProviderCustomizer - Successfully initialized Solarwinds APM OpenTelemetry extensions with service key ec3d********************************************************5468:ot
```

#### SDK
Expand Down
122 changes: 102 additions & 20 deletions agent/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("com.github.johnrengelman.shadow") version "7.0.0"
id("com.github.johnrengelman.shadow")
id 'maven-publish'
id 'signing'
}
Expand All @@ -11,47 +13,99 @@ project.archivesBaseName = 'solarwinds-apm-agent'
def relocatePackages = ext.relocatePackages

configurations {
customShadow
// this configuration collects libs that will be placed in the bootstrap classloader
bootstrapLibs {
canBeResolved = true
canBeConsumed = false
}
// this configuration collects libs that will be placed in the agent classloader, isolated from the instrumented application code
javaagentLibs {
canBeResolved = true
canBeConsumed = false
}
// this configuration stores the upstream agent dep that's extended by this project
upstreamAgent {
canBeResolved = true
canBeConsumed = false
}
}

dependencies {
customShadow project(path: ":custom", configuration: "shadow")
customShadow project(path: ":instrumentation", configuration: "shadow")
implementation project(path: ":core-bootstrap")
implementation project(path: ":solarwinds-otel-sdk")
implementation "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}"
implementation "com.appoptics.agent.java:core:${versions.appopticsCore}"
implementation "com.appoptics.agent.java:metrics:${versions.appopticsMetrics}"
javaagentLibs project(path: ":custom")
javaagentLibs project(path: ":instrumentation")

bootstrapLibs project(path: ":bootstrap")
bootstrapLibs "com.appoptics.agent.java:core:${versions.appopticsCore}"
bootstrapLibs "com.appoptics.agent.java:metrics:${versions.appopticsMetrics}"

upstreamAgent "io.opentelemetry.javaagent:opentelemetry-javaagent:${versions.opentelemetryJavaagent}"
}

CopySpec isolateSpec() {
CopySpec isolateClasses(Iterable<File> jars) {
return copySpec {
configurations.customShadow.files.each {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("(^.*)\\.class\$", "\$1.classdata")
rename("^(.*)\\.class\$", "\$1.classdata")
}
}
}
}

shadowJar {
archiveClassifier.set(null)
}

tasks {
// building the final javaagent jar is done in 3 steps:

// 1. all distro specific javaagent libs are relocated
task relocateJavaagentLibs(type: ShadowJar) {
configurations = [project.configurations.javaagentLibs]

duplicatesStrategy = DuplicatesStrategy.FAIL

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

mergeServiceFiles()
exclude("**/module-info.class")
relocatePackages(it)

// 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")
}
}

// 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
// its own duplicatesStrategy
task isolateJavaagentLibs(type: Copy) {
dependsOn(tasks.relocateJavaagentLibs)
with isolateClasses(tasks.relocateJavaagentLibs.outputs.files)

into("$buildDir/isolated/javaagentLibs")
}


// 3. the relocated and isolated javaagent libs are merged together with the bootstrap libs (which undergo relocation
// in this task) and the upstream javaagent jar; duplicates are removed
shadowJar {
dependsOn ':custom:shadowJar'
dependsOn ':instrumentation:shadowJar'
with isolateSpec()
configurations = [project.configurations.bootstrapLibs, project.configurations.upstreamAgent]

dependsOn(tasks.isolateJavaagentLibs)
from(tasks.isolateJavaagentLibs.outputs)

archiveClassifier.set(null)

duplicatesStrategy = DuplicatesStrategy.EXCLUDE

mergeServiceFiles {
include("inst/META-INF/services/*")
}
exclude("**/module-info.class")

exclude("inst/com/appoptics/opentelemetry/core/**")
relocatePackages(it)

manifest {
Expand Down Expand Up @@ -113,6 +167,34 @@ publishing {
artifact javadocJar
}
}
localInstall(MavenPublication){
pom {
name = "${archivesBaseName}"
description = "${archivesBaseName}"
url = "www.solarwinds.com"
scm {
url = 'https://www.solarwinds.com'
}
developers {
developer {
id = 'APM'
name = 'The APM Agent team'
}
}
licenses {
license {
name = 'Librato Open License'
}
}
groupId = 'io.github.appoptics'
artifactId = "${archivesBaseName}"
version = "${versions.agent}"
from components.java
artifact sourcesJar
artifact javadocJar
}
}
publishLocalInstallPublicationToMavenLocal
}
repositories {
// -- uncomment the lines below to publish the agent artifact to the Maven central --
Expand Down
5 changes: 1 addition & 4 deletions core-bootstrap/build.gradle → bootstrap/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
plugins {
id "java"
id("com.github.johnrengelman.shadow") version "7.0.0"
}

apply from: "$rootDir/gradle/shadow.gradle"

dependencies {
compileOnly("io.opentelemetry:opentelemetry-semconv:${versions.opentelemetryAlpha}")
compileOnly('org.checkerframework:checker-qual:3.21.2')
compileOnly 'org.slf4j:slf4j-api:1.7.36'
implementation 'org.slf4j:slf4j-api:2.0.6'

compileOnly "com.appoptics.agent.java:core:${versions.appopticsCore}"
compileOnly "com.appoptics.agent.java:metrics:${versions.appopticsMetrics}"
Expand Down
130 changes: 72 additions & 58 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,73 +1,87 @@
group = "io.github.appoptics"

subprojects {
apply plugin: "java"
apply plugin: "muzzle"
apply plugin: "checkstyle"
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:6.14.0"
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
classpath "io.opentelemetry.instrumentation:gradle-plugins:1.23.0-alpha-SNAPSHOT"
}
}

ext {
versions = [
opentelemetry : "1.12.0",
opentelemetryJavaagent: "1.12.1",
bytebuddy : "1.12.6",
guava : "30.1-jre",
appopticsCore : "7.8.1",
agent : "0.14.2" // the custom distro agent version
]
versions.appopticsMetrics = "${versions.appopticsCore}" // they share the same version now
versions.opentelemetryAlpha = "${versions.opentelemetry}-alpha"
versions.opentelemetryJavaagentAlpha = "${versions.opentelemetryJavaagent}-alpha"
subprojects {
apply plugin: "java"
apply plugin: "checkstyle"

deps = [
bytebuddy : "net.bytebuddy:byte-buddy-dep:${versions.bytebuddy}",
autoservice : [
"com.google.auto.service:auto-service:1.0-rc7",
"com.google.auto:auto-common:0.8",
"com.google.guava:guava:${versions.guava}",
],
autoValueAnnotations: "com.google.auto.value:auto-value-annotations:${versions.autoValue}",
]
}
ext {
versions = [
opentelemetry : "1.22.0",
opentelemetryJavaagent: "1.22.0",
bytebuddy : "1.12.10",
guava : "30.1-jre",
appopticsCore : "7.8.1",
agent : "0.14.2", // the custom distro agent version
autoservice : "1.0.1",
]
versions.appopticsMetrics = "${versions.appopticsCore}" // they share the same version now
versions.opentelemetryAlpha = "${versions.opentelemetry}-alpha"
versions.opentelemetryJavaagentAlpha = "${versions.opentelemetryJavaagent}-alpha"

repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
deps = [
bytebuddy : "net.bytebuddy:byte-buddy-dep:${versions.bytebuddy}",
autoservice : [
"com.google.auto.service:auto-service:${versions.autoservice}",
"com.google.auto.service:auto-service-annotations:${versions.autoservice}",
],
]
}
maven {
url = uri("https://maven.pkg.github.com/librato/joboe")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GP_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GP_TOKEN")
}
}
mavenLocal()
mavenCentral()
}

dependencies {
testImplementation("org.mockito:mockito-core:3.3.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
}
repositories {
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
}
maven {
url = uri("https://maven.pkg.github.com/librato/joboe")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GP_USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GP_TOKEN")
}
}
mavenLocal()
mavenCentral()
}

checkstyleMain {
configFile = file("$rootDir/checkstyle.xml")
}
dependencies {
testImplementation("org.mockito:mockito-core:3.3.3")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
}

checkstyleTest.enabled = false
checkstyleMain {
configFile = file("$rootDir/checkstyle.xml")
}

// too many trailing spaces warnings
// checkstyleTest {
// configFile = file("$rootDir/checkstyle.xml")
// }
checkstyleTest.enabled = false

tasks {
test {
useJUnitPlatform()
checkstyleTest {
configFile = file("$rootDir/checkstyle.xml")
}

compileJava {
options.release.set(8)
tasks {
test {
useJUnitPlatform()
}

compileJava {
options.release.set(8)
}
}
}
}
52 changes: 0 additions & 52 deletions buildSrc/build.gradle

This file was deleted.

Loading