Skip to content

Commit 962d637

Browse files
authored
Update to latest otel (#2257)
* Update to latest otel and reduce fork * Updates * Add missing lockfiles * Assemble * fix publishing * Fix * Update internal pipeline
1 parent d30a21b commit 962d637

File tree

77 files changed

+2903
-1210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2903
-1210
lines changed

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ jobs:
3939
- name: Build otel-fork
4040
working-directory: otel
4141
# javadoc fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
42-
run: ./gradlew publishToMavenLocal -x javadoc --stacktrace
42+
run: ./gradlew publishToMavenLocal -x javadoc
4343
- name: Test
4444
# TODO enable build cache, either --build-cache here, or org.gradle.caching=true in gradle.properties
45-
run: ./gradlew check --stacktrace
45+
run: ./gradlew check
4646
- name: Upload snapshot
4747
# only upload from windows since only that build includes etw
4848
if: matrix.os == 'windows-2019'
@@ -98,7 +98,7 @@ jobs:
9898
- name: Build otel-fork
9999
working-directory: otel
100100
# javadoc fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
101-
run: ./gradlew publishToMavenLocal -x javadoc --stacktrace
101+
run: ./gradlew publishToMavenLocal -x javadoc
102102
- name: Test
103103
# TODO enable build cache, either --build-cache here, or org.gradle.caching=true in gradle.properties
104104
run: ./gradlew ${{ matrix.module }}:smokeTest

.github/workflows/pr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ jobs:
4040
- name: Build otel-fork
4141
working-directory: otel
4242
# javadoc fails sporadically fetching https://docs.oracle.com/javase/8/docs/api/
43-
run: ./gradlew publishToMavenLocal -x javadoc --stacktrace
43+
run: ./gradlew publishToMavenLocal -x javadoc
4444
- name: Test
4545
# TODO enable build cache, either --build-cache here, or org.gradle.caching=true in gradle.properties
46-
run: ./gradlew check --stacktrace
46+
run: ./gradlew check assemble
4747
- name: Upload snapshot
4848
# only upload from windows since only that build includes etw
4949
if: matrix.os == 'windows-2019'

.pipelines/pipeline.user.windows.buddy.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,4 @@ build:
1313
artifacts:
1414
- to: 'Artifacts'
1515
include:
16-
- '**/build/libs/*.jar'
17-
- '**/build/libs/*-sources.jar'
18-
- '**/build/libs/*-javadoc.jar'
19-
- '**/build/libs/*.pom'
20-
exclude:
21-
- 'buildSrc/**/*'
16+
- 'agent/agent/build/libs/*.jar'

.pipelines/pipeline.user.windows.official.nonrelease.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,4 @@ build:
2020
artifacts:
2121
- to: 'Artifacts'
2222
include:
23-
- '**/build/libs/*.jar'
24-
- '**/build/libs/*-sources.jar'
25-
- '**/build/libs/*-javadoc.jar'
26-
- '**/build/libs/*.pom'
27-
exclude:
28-
- 'buildSrc/**/*'
23+
- 'agent/agent/build/libs/*.jar'

.pipelines/pipeline.user.windows.official.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ build:
1616
- !!buildcommand
1717
name: 'Assemble ApplicationInsights-Java JARs'
1818
command: '.scripts/gradle.cmd'
19-
arguments: 'assemble copyLibsToGlobalArtifactsFolder -DisRelease=true -Pai.etw.native.build=release'
19+
arguments: 'publishToMavenLocal -DisRelease=true -Pai.etw.native.build=release'
2020
artifacts:
2121
- to: 'Artifacts'
2222
include:
23-
- '**/build/libs/*.jar'
24-
- '**/build/libs/*-sources.jar'
25-
- '**/build/libs/*-javadoc.jar'
26-
- '**/build/libs/*.pom'
27-
exclude:
28-
- 'buildSrc/**/*'
23+
- '~/.m2/repository/com/microsoft/azure/applicationinsights-agent/*/*.jar'
24+
- '~/.m2/repository/com/microsoft/azure/applicationinsights-agent/*/*-sources.jar'
25+
- '~/.m2/repository/com/microsoft/azure/applicationinsights-agent/*/*-javadoc.jar'
26+
- '~/.m2/repository/com/microsoft/azure/applicationinsights-agent/*/*.pom'

agent/agent-bootstrap/build.gradle.kts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,16 @@ plugins {
33
id("ai.sdk-version-file")
44
}
55

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

88
dependencies {
9-
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap") {
10-
exclude("org.slf4j", "slf4j-simple")
11-
}
12-
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
13-
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv")
14-
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-annotation-support")
15-
implementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-appender-api-internal")
16-
implementation("io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api")
9+
// needed to access io.opentelemetry.instrumentation.api.aisdk.MicrometerUtil
10+
// TODO (heya) remove this when updating to upstream micrometer instrumentation
11+
compileOnly("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api")
12+
1713
implementation("ch.qos.logback:logback-classic")
1814
implementation("ch.qos.logback.contrib:logback-json-classic")
1915

20-
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-executors-bootstrap:$otelInstrumentationAlphaVersion")
21-
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-jaxrs-common-bootstrap:$otelInstrumentationAlphaVersion")
22-
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-kafka-clients-0.11-bootstrap:$otelInstrumentationAlphaVersion")
23-
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap:$otelInstrumentationAlphaVersion")
24-
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-undertow-1.4-bootstrap:$otelInstrumentationAlphaVersion")
25-
2616
// not using gson because it has dependency on java.sql.*, which is not available in Java 9+ bootstrap class loader
2717
// only complaint so far about moshi is that it doesn"t give line numbers when there are json formatting errors
2818
implementation("com.squareup.moshi:moshi")

agent/agent-bootstrap/gradle.lockfile

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,9 @@ com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
99
com.squareup.moshi:moshi:1.11.0=runtimeClasspath
1010
com.squareup.okio:okio:1.17.5=runtimeClasspath
1111
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
12-
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-annotation-support:1.13.0+ai.patches-alpha=runtimeClasspath
13-
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:1.13.0+ai.patches-alpha=runtimeClasspath
14-
io.opentelemetry.instrumentation:opentelemetry-instrumentation-api:1.13.0+ai.patches-alpha=runtimeClasspath
15-
io.opentelemetry.instrumentation:opentelemetry-instrumentation-appender-api-internal:1.13.0+ai.patches-alpha=runtimeClasspath
16-
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.13.0+ai.patches-alpha=runtimeClasspath
17-
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-executors-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
18-
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-jaxrs-common-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
19-
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-kafka-clients-0.11-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
20-
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
21-
io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-undertow-1.4-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
22-
io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap:1.13.0+ai.patches-alpha=runtimeClasspath
23-
io.opentelemetry.javaagent:opentelemetry-javaagent-instrumentation-api:1.13.0+ai.patches-alpha=runtimeClasspath
24-
io.opentelemetry:opentelemetry-api:1.13.0=runtimeClasspath
12+
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
2513
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
2614
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
27-
io.opentelemetry:opentelemetry-context:1.13.0=runtimeClasspath
28-
io.opentelemetry:opentelemetry-semconv:1.13.0-alpha=runtimeClasspath
2915
org.junit:junit-bom:5.7.2=runtimeClasspath
3016
org.slf4j:slf4j-api:1.7.36=runtimeClasspath
3117
empty=
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* ApplicationInsights-Java
3+
* Copyright (c) Microsoft Corporation
4+
* All rights reserved.
5+
*
6+
* MIT License
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this
8+
* software and associated documentation files (the ""Software""), to deal in the Software
9+
* without restriction, including without limitation the rights to use, copy, modify, merge,
10+
* publish, distribute, sublicense, and/or sell copies of the Software, and to permit
11+
* persons to whom the Software is furnished to do so, subject to the following conditions:
12+
* The above copyright notice and this permission notice shall be included in all copies or
13+
* substantial portions of the Software.
14+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
17+
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19+
* DEALINGS IN THE SOFTWARE.
20+
*/
21+
22+
package com.microsoft.applicationinsights.agent.bootstrap;
23+
24+
public class AiLazyConfiguration {
25+
26+
private static volatile Accessor accessor;
27+
28+
public static void setAccessor(Accessor accessor) {
29+
AiLazyConfiguration.accessor = accessor;
30+
}
31+
32+
public static void lazyLoad() {
33+
if (accessor != null) {
34+
accessor.lazyLoad();
35+
}
36+
}
37+
38+
public interface Accessor {
39+
void lazyLoad();
40+
}
41+
42+
private AiLazyConfiguration() {}
43+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+
3+
plugins {
4+
id("ai.java-conventions")
5+
id("ai.shadow-conventions")
6+
}
7+
8+
// this configuration collects libs that will be placed in the bootstrap classloader
9+
val bootstrapLibs: Configuration by configurations.creating {
10+
isCanBeResolved = true
11+
isCanBeConsumed = false
12+
}
13+
// this configuration collects libs that will be placed in the agent classloader, isolated from the instrumented application code
14+
val javaagentLibs: Configuration by configurations.creating {
15+
isCanBeResolved = true
16+
isCanBeConsumed = false
17+
}
18+
// this configuration stores the upstream agent dep that's extended by this project
19+
val upstreamAgent: Configuration by configurations.creating {
20+
isCanBeResolved = true
21+
isCanBeConsumed = false
22+
}
23+
24+
dependencies {
25+
// include everything from otel agent for testing
26+
upstreamAgent("io.opentelemetry.javaagent:opentelemetry-agent-for-testing")
27+
}
28+
29+
tasks {
30+
jar {
31+
enabled = false
32+
}
33+
34+
// building the final javaagent jar is done in 3 steps:
35+
36+
// 1. all distro-specific javaagent libs are relocated (by the ai.shadow-conventions plugin)
37+
val relocateJavaagentLibs by registering(ShadowJar::class) {
38+
configurations = listOf(javaagentLibs)
39+
40+
archiveFileName.set("javaagentLibs-relocated.jar")
41+
}
42+
43+
// 2. the distro javaagent libs are then isolated - moved to the inst/ directory
44+
// having a separate task for isolating javaagent libs is required to avoid duplicates with the upstream javaagent
45+
// duplicatesStrategy in shadowJar won't be applied when adding files with with(CopySpec) because each CopySpec has
46+
// its own duplicatesStrategy
47+
val isolateJavaagentLibs by registering(Copy::class) {
48+
dependsOn(relocateJavaagentLibs)
49+
isolateClasses(relocateJavaagentLibs.get().outputs.files)
50+
51+
into("$buildDir/isolated/javaagentLibs")
52+
}
53+
54+
// 3. the relocated and isolated javaagent libs are merged together with the bootstrap libs (which undergo relocation
55+
// in this task) and the upstream javaagent jar; duplicates are removed
56+
shadowJar {
57+
configurations = listOf(bootstrapLibs, upstreamAgent)
58+
59+
dependsOn(isolateJavaagentLibs)
60+
from(isolateJavaagentLibs.get().outputs)
61+
62+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
63+
64+
manifest {
65+
attributes(
66+
mapOf(
67+
"Main-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
68+
"Agent-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
69+
"Premain-Class" to "io.opentelemetry.javaagent.OpenTelemetryAgent",
70+
"Can-Redefine-Classes" to true,
71+
"Can-Retransform-Classes" to true
72+
)
73+
)
74+
}
75+
}
76+
77+
assemble {
78+
dependsOn(shadowJar)
79+
}
80+
}
81+
82+
fun CopySpec.isolateClasses(jars: Iterable<File>) {
83+
jars.forEach {
84+
from(zipTree(it)) {
85+
into("inst")
86+
rename("^(.*)\\.class\$", "\$1.classdata")
87+
}
88+
}
89+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is a Gradle generated file for dependency locking.
2+
# Manual edits can break the build and are not advised.
3+
# This file is expected to be part of source control.
4+
com.google.guava:guava-bom:31.0.1-jre=runtimeClasspath
5+
io.netty:netty-bom:4.1.72.Final=runtimeClasspath
6+
io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:1.14.0.1-alpha=runtimeClasspath
7+
io.opentelemetry:opentelemetry-bom-alpha:1.13.0-alpha=runtimeClasspath
8+
io.opentelemetry:opentelemetry-bom:1.13.0=runtimeClasspath
9+
org.junit:junit-bom:5.7.2=runtimeClasspath
10+
empty=

0 commit comments

Comments
 (0)