Skip to content

Commit

Permalink
Update to latest otel and reduce fork
Browse files Browse the repository at this point in the history
  • Loading branch information
trask committed May 6, 2022
1 parent 3c14bb5 commit 29c638e
Show file tree
Hide file tree
Showing 67 changed files with 2,803 additions and 1,072 deletions.
25 changes: 10 additions & 15 deletions agent/agent-bootstrap/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,21 @@ plugins {
id("ai.sdk-version-file")
}

val otelInstrumentationAlphaVersion = "1.13.0+ai.patches-alpha"
val otelInstrumentationAlphaVersion = "1.14.0.1-alpha"

dependencies {
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap") {
exclude("org.slf4j", "slf4j-simple")
}
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-annotation-support")
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-appender-api-internal")
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api")
// FIXME (trask)
// implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap") {
// exclude("org.slf4j", "slf4j-simple")
// }

// needed to access io.opentelemetry.instrumentation.api.aisdk.MicrometerUtil
// TODO (heya) remove this when updating to upstream micrometer instrumentation
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")

implementation("ch.qos.logback:logback-classic")
implementation("ch.qos.logback.contrib:logback-json-classic")

implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-executors-bootstrap:$otelInstrumentationAlphaVersion")
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-jaxrs-common-bootstrap:$otelInstrumentationAlphaVersion")
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-kafka-clients-0.11-bootstrap:$otelInstrumentationAlphaVersion")
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap:$otelInstrumentationAlphaVersion")
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-undertow-1.4-bootstrap:$otelInstrumentationAlphaVersion")

// not using gson because it has dependency on java.sql.*, which is not available in Java 9+ bootstrap class loader
// only complaint so far about moshi is that it doesn"t give line numbers when there are json formatting errors
implementation("com.squareup.moshi:moshi")
Expand Down
18 changes: 2 additions & 16 deletions agent/agent-bootstrap/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,9 @@ com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
com.squareup.moshi:moshi:1.11.0=runtimeClasspath
com.squareup.okio:okio:1.17.5=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-annotation-support:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-appender-api-internal:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-executors-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-jaxrs-common-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-kafka-clients-0.11-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-undertow-1.4-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-api:1.13.0=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
io.opentelemetry:opentelemetry-context:1.13.0=runtimeClasspath
io.opentelemetry:opentelemetry-semconv:1.13.0-alpha=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
org.slf4j:slf4j-api:1.7.32=runtimeClasspath
empty=
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* ApplicationInsights-Java
* Copyright (c) Microsoft Corporation
* All rights reserved.
*
* MIT License
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
* software and associated documentation files (the ""Software""), to deal in the Software
* without restriction, including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

package com.microsoft.applicationinsights.agent.bootstrap;

public class AiLazyConfiguration {

private static volatile Accessor accessor;

public static void setAccessor(Accessor accessor) {
AiLazyConfiguration.accessor = accessor;
}

public static void lazyLoad() {
if (accessor != null) {
accessor.lazyLoad();
}
}

public interface Accessor {
void lazyLoad();
}

private AiLazyConfiguration() {}
}
89 changes: 89 additions & 0 deletions agent/agent-for-testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id("ai.java-conventions")
id("ai.shadow-conventions")
}

// this configuration collects libs that will be placed in the bootstrap classloader
val bootstrapLibs: Configuration by configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
}
// this configuration collects libs that will be placed in the agent classloader, isolated from the instrumented application code
val javaagentLibs: Configuration by configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
}
// this configuration stores the upstream agent dep that's extended by this project
val upstreamAgent: Configuration by configurations.creating {
isCanBeResolved = true
isCanBeConsumed = false
}

dependencies {
// include everything from otel agent for testing
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-agent-for-testing")
}

tasks {
jar {
enabled = false
}

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

// 1. all distro-specific javaagent libs are relocated (by the ai.shadow-conventions plugin)
val relocateJavaagentLibs by registering(ShadowJar::class) {
configurations = listOf(javaagentLibs)

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

// 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
val isolateJavaagentLibs by registering(Copy::class) {
dependsOn(relocateJavaagentLibs)
isolateClasses(relocateJavaagentLibs.get().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 {
configurations = listOf(bootstrapLibs, upstreamAgent)

dependsOn(isolateJavaagentLibs)
from(isolateJavaagentLibs.get().outputs)

duplicatesStrategy = DuplicatesStrategy.EXCLUDE

manifest {
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
)
)
}
}

assemble {
dependsOn(shadowJar)
}
}

fun CopySpec.isolateClasses(jars: Iterable<File>) {
jars.forEach {
from(zipTree(it)) {
into("inst")
rename("^(.*)\\.class\$", "\$1.classdata")
}
}
}
2 changes: 1 addition & 1 deletion agent/agent-gc-monitor/gc-monitor-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
com.google.errorprone:error_prone_annotations:2.9.0=runtimeClasspath
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-gc-monitor/gc-monitor-core/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
com.google.errorprone:error_prone_annotations:2.9.0=runtimeClasspath
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-gc-monitor/gc-monitor-tests/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is expected to be part of source control.
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-profiler/agent-alerting-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is expected to be part of source control.
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-profiler/agent-alerting/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This file is expected to be part of source control.
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
org.junit:junit-bom:5.7.2=runtimeClasspath
Expand Down
2 changes: 1 addition & 1 deletion agent/agent-profiler/agent-profiler-api/gradle.lockfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ com.squareup.okio:okio:1.17.5=runtimeClasspath
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
io.netty:netty-tcnative-boringssl-static:2.0.46.Final=runtimeClasspath
io.netty:netty-tcnative-classes:2.0.46.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
io.projectreactor:reactor-core:3.4.14=runtimeClasspath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ io.netty:netty-transport-native-epoll:4.1.72.Final=runtimeClasspath
io.netty:netty-transport-native-kqueue:4.1.72.Final=runtimeClasspath
io.netty:netty-transport-native-unix-common:4.1.72.Final=runtimeClasspath
io.netty:netty-transport:4.1.72.Final=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
io.projectreactor.netty:reactor-netty-core:1.0.15=runtimeClasspath
Expand Down
45 changes: 23 additions & 22 deletions agent/agent-tooling/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
plugins {
id("ai.java-conventions")
id("ai.sdk-version-file")
id("com.github.johnrengelman.shadow")
}

// Adding this step to copy playback test results from session-records to build/classes/java/test. Azure core testing framework follows this directory structure.
Expand All @@ -24,24 +23,29 @@ dependencies {
implementation(project(":agent:agent-gc-monitor:gc-monitor-api"))
implementation(project(":agent:agent-gc-monitor:gc-monitor-core"))

implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") {
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")

testImplementation("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") {
// excluded temporarily while hosting azure-monitor-opentelemetry-exporter in this repo
// because it causes problems for those unit tests
exclude("io.opentelemetry", "opentelemetry-extension-noop-api")
}
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
implementation("net.bytebuddy:byte-buddy")

compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-extension-api")
compileOnly("net.bytebuddy:byte-buddy-dep")

implementation("commons-codec:commons-codec")
implementation("org.apache.commons:commons-text")
// TODO (trask) this is probably still needed for above apache commons projects
implementation("org.slf4j:jcl-over-slf4j")

// TODO (trask) consolidate and use same annotations as upstream
implementation("org.checkerframework:checker-qual")
implementation("com.google.code.findbugs:annotations:3.0.1")

implementation("ch.qos.logback:logback-classic")
implementation("ch.qos.logback.contrib:logback-json-classic")
// these are present in the bootstrap class loader
compileOnly("ch.qos.logback:logback-classic")
compileOnly("ch.qos.logback.contrib:logback-json-classic")

implementation(project(":agent:agent-profiler:agent-profiler-api"))

Expand All @@ -56,25 +60,24 @@ dependencies {
exclude("org.linguafranca.pwdb", "KeePassJava2")
}

implementation("io.opentelemetry:opentelemetry-sdk-extension-tracing-incubator")
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
implementation("io.opentelemetry:opentelemetry-extension-trace-propagators")
// compileOnly("io.opentelemetry:opentelemetry-sdk-extension-tracing-incubator")
compileOnly("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
compileOnly("io.opentelemetry:opentelemetry-extension-trace-propagators")

implementation("com.github.oshi:oshi-core")
implementation("org.slf4j:slf4j-api")

implementation("io.opentelemetry:opentelemetry-api")
testImplementation("io.opentelemetry:opentelemetry-sdk-metrics-testing")
implementation("org.jctools:jctools-core:3.3.0")
compileOnly("org.slf4j:slf4j-api")

compileOnly("io.opentelemetry:opentelemetry-sdk")
compileOnly("io.opentelemetry:opentelemetry-sdk-metrics")
compileOnly("io.opentelemetry:opentelemetry-sdk-logs")

implementation("io.opentelemetry:opentelemetry-exporter-otlp")
implementation("io.opentelemetry:opentelemetry-exporter-otlp-metrics")
implementation("io.opentelemetry:opentelemetry-exporter-otlp-logs")
implementation("io.opentelemetry:opentelemetry-exporter-otlp-http-trace")
implementation("io.opentelemetry:opentelemetry-exporter-otlp-http-metrics")
implementation("io.opentelemetry:opentelemetry-exporter-otlp-http-logs")
testImplementation("io.opentelemetry:opentelemetry-sdk")
testImplementation("io.opentelemetry:opentelemetry-sdk-metrics")
testImplementation("io.opentelemetry:opentelemetry-sdk-logs")
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
testImplementation("io.opentelemetry:opentelemetry-sdk-metrics-testing")

compileOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
// TODO(trask): update tests, no need to use this anymore
testImplementation("com.squareup.okio:okio:2.8.0")

Expand All @@ -96,8 +99,6 @@ dependencies {
testImplementation("uk.org.webcompere:system-stubs-jupiter:1.1.0")
testImplementation("io.github.hakky54:logcaptor")

testImplementation("io.opentelemetry:opentelemetry-sdk-testing")

testImplementation("com.microsoft.jfr:jfr-streaming")
testImplementation("com.azure:azure-storage-blob")

Expand Down
Loading

0 comments on commit 29c638e

Please sign in to comment.