Skip to content

Commit b253603

Browse files
authored
Upgrade otel to 1.33.0 (#402)
* 1st attempt otel upgrade * temp trying * test using javaagent * fix client tests * otel 1.33.0, and fix netty and blocking extension * fix netty 4.1 * fix servlet-3.0 * fix servlet-3.0, rw * fix spark * fix spring-webflux * fix struts and undertow * fix vertx * fix grpc * fix tests * cleanup * spotless apply * fix grpc 1.30.0 * fix micronaut * fix smoke tests * fix smoke tests * fix netty client * fix smoke tests * fix smoke tests * debug * increase timeout for flake test * increase timeout for flaky test, try to fix vertx test * disable flaky test
1 parent ae81663 commit b253603

File tree

98 files changed

+2385
-3177
lines changed

Some content is hidden

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

98 files changed

+2385
-3177
lines changed

.gitmodules

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
[submodule "javaagent-core/src/main/proto"]
1+
[submodule "otel-extensions/src/main/proto"]
22
path = otel-extensions/src/main/proto
33
url = https://github.com/hypertrace/agent-config.git
4+
5+
[submodule "testing-common/src/main/proto"]
6+
path = testing-common/src/main/proto
7+
url = https://github.com/open-telemetry/opentelemetry-proto.git

build.gradle.kts

+8-7
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ subprojects {
5454
extra.set("versions", mapOf(
5555
// when updating these values, some values must also be updated in buildSrc as this map
5656
// cannot be accessed there
57-
"opentelemetry" to "1.24.0",
58-
"opentelemetry_semconv" to "1.24.0-alpha",
59-
"opentelemetry_proto" to "0.11.0-alpha",
60-
"opentelemetry_java_agent" to "1.24.0-alpha",
61-
"opentelemetry_java_agent_all" to "1.24.0",
62-
"opentelemetry_java_agent-tooling" to "1.24.0-alpha",
57+
"opentelemetry" to "1.33.0",
58+
"opentelemetry_semconv" to "1.21.0-alpha",
59+
"opentelemetry_api_semconv" to "1.33.0-alpha",
60+
"opentelemetry_proto" to "0.20.0-alpha",
61+
"opentelemetry_java_agent" to "1.33.0-alpha",
62+
"opentelemetry_java_agent_all" to "1.33.0",
63+
"opentelemetry_java_agent-tooling" to "1.33.0-alpha",
6364

64-
"opentelemetry_gradle_plugin" to "1.24.0-alpha",
65+
"opentelemetry_gradle_plugin" to "1.33.0-alpha",
6566
"byte_buddy" to "1.12.10",
6667
"slf4j" to "2.0.7"
6768
))

buildSrc/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ tasks {
3333
dependencies {
3434
compileOnly(gradleApi())
3535
implementation(localGroovy())
36-
val otelInstrumentationVersion = "1.24.0-alpha"
36+
val otelInstrumentationVersion = "1.33.0-alpha"
3737
implementation("io.opentelemetry.javaagent:opentelemetry-muzzle:$otelInstrumentationVersion")
3838
implementation("io.opentelemetry.instrumentation.muzzle-generation:io.opentelemetry.instrumentation.muzzle-generation.gradle.plugin:$otelInstrumentationVersion")
3939
implementation("io.opentelemetry.instrumentation.muzzle-check:io.opentelemetry.instrumentation.muzzle-check.gradle.plugin:$otelInstrumentationVersion")

buildSrc/src/main/java/io/opentelemetry/instrumentation/gradle/AutoInstrumentationPlugin.java

-14
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,6 @@ public void apply(Project project) {
3333
project.getPlugins().apply(JavaLibraryPlugin.class);
3434
createLibraryConfiguration(project);
3535
addDependencies(project);
36-
project
37-
.getTasks()
38-
.withType(
39-
Test.class,
40-
task -> {
41-
task.dependsOn(":testing-bootstrap:shadowJar");
42-
File testingBootstrapJar =
43-
new File(
44-
project.project(":testing-bootstrap").getBuildDir(),
45-
"libs/testing-bootstrap.jar");
46-
// Make sure tests get rerun if the contents of the testing-bootstrap.jar change
47-
task.getInputs().property("testing-bootstrap-jar", testingBootstrapJar);
48-
task.getJvmArgumentProviders().add(new InstrumentationTestArgs(testingBootstrapJar));
49-
});
5036
}
5137

5238
private void addDependencies(Project project) {

instrumentation/apache-httpasyncclient-4.1/build.gradle.kts

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ dependencies {
3232
api(project(":instrumentation:apache-httpclient-4.0"))
3333

3434
implementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpasyncclient-4.1:${versions["opentelemetry_java_agent"]}")
35-
testImplementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-4.0:${versions["opentelemetry_java_agent"]}")
36-
testImplementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:${versions["opentelemetry_semconv"]}")
3735
library("org.apache.httpcomponents:httpasyncclient:4.1")
38-
testImplementation(testFixtures(project(":testing-common")))
36+
testImplementation(project(":testing-common"))
3937
}
40-

instrumentation/apache-httpasyncclient-4.1/src/test/java/io/opentelemetry/instrumentation/hypertrace/apachehttpasyncclient/ApacheAsyncClientInstrumentationModuleTest.java

+30-23
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package io.opentelemetry.instrumentation.hypertrace.apachehttpasyncclient;
1818

19-
import io.opentelemetry.sdk.trace.data.SpanData;
19+
import io.opentelemetry.proto.trace.v1.Span;
2020
import java.io.BufferedReader;
2121
import java.io.ByteArrayInputStream;
2222
import java.io.IOException;
@@ -41,7 +41,6 @@
4141
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
4242
import org.apache.http.impl.nio.client.HttpAsyncClients;
4343
import org.apache.http.message.BasicHeader;
44-
import org.hypertrace.agent.core.instrumentation.HypertraceSemanticAttributes;
4544
import org.hypertrace.agent.testing.AbstractInstrumenterTest;
4645
import org.hypertrace.agent.testing.TestHttpServer;
4746
import org.hypertrace.agent.testing.TestHttpServer.GetJsonHandler;
@@ -84,27 +83,33 @@ public void getJson()
8483
Assertions.assertEquals(GetJsonHandler.RESPONSE_BODY, responseBody);
8584

8685
TEST_WRITER.waitForTraces(1);
87-
// TODO : It needs some time to create second span for responseBody
88-
TEST_WRITER.waitForSpans(2);
89-
List<List<SpanData>> traces = TEST_WRITER.getTraces();
86+
// exclude server spans
87+
List<List<Span>> traces =
88+
TEST_WRITER.waitForSpans(
89+
2, span -> span.getKind().equals(Span.SpanKind.SPAN_KIND_SERVER), 123);
9090
Assertions.assertEquals(1, traces.size());
9191
Assertions.assertEquals(2, traces.get(0).size());
92-
SpanData clientSpan = traces.get(0).get(0);
92+
Span clientSpan = traces.get(0).get(1);
93+
Span responseBodySpan = traces.get(0).get(0);
94+
if (traces.get(0).get(0).getKind().equals(Span.SpanKind.SPAN_KIND_CLIENT)) {
95+
clientSpan = traces.get(0).get(0);
96+
responseBodySpan = traces.get(0).get(1);
97+
}
9398

9499
Assertions.assertEquals(
95100
"test-value",
96-
clientSpan
97-
.getAttributes()
98-
.get(HypertraceSemanticAttributes.httpResponseHeader("test-response-header")));
101+
TEST_WRITER
102+
.getAttributesMap(clientSpan)
103+
.get("http.response.header.test-response-header")
104+
.getStringValue());
99105
Assertions.assertEquals(
100106
"bar",
101-
clientSpan.getAttributes().get(HypertraceSemanticAttributes.httpRequestHeader("foo")));
102-
Assertions.assertNull(
103-
clientSpan.getAttributes().get(HypertraceSemanticAttributes.HTTP_REQUEST_BODY));
104-
SpanData responseBodySpan = traces.get(0).get(1);
107+
TEST_WRITER.getAttributesMap(clientSpan).get("http.request.header.foo").getStringValue());
108+
Assertions.assertNull(TEST_WRITER.getAttributesMap(clientSpan).get("http.request.body"));
109+
105110
Assertions.assertEquals(
106111
GetJsonHandler.RESPONSE_BODY,
107-
responseBodySpan.getAttributes().get(HypertraceSemanticAttributes.HTTP_RESPONSE_BODY));
112+
TEST_WRITER.getAttributesMap(responseBodySpan).get("http.response.body").getStringValue());
108113
}
109114

110115
@Test
@@ -136,22 +141,24 @@ public void postJsonEntity(HttpEntity entity)
136141
Assertions.assertEquals(204, response.getStatusLine().getStatusCode());
137142

138143
TEST_WRITER.waitForTraces(1);
139-
List<List<SpanData>> traces = TEST_WRITER.getTraces();
144+
// exclude server spans
145+
List<List<Span>> traces =
146+
TEST_WRITER.waitForSpans(1, span -> span.getKind().equals(Span.SpanKind.SPAN_KIND_SERVER));
140147
Assertions.assertEquals(1, traces.size());
141148
Assertions.assertEquals(1, traces.get(0).size());
142-
SpanData clientSpan = traces.get(0).get(0);
149+
Span clientSpan = traces.get(0).get(0);
143150

144151
String requestBody = readInputStream(entity.getContent());
145152
Assertions.assertEquals(
146153
"test-value",
147-
clientSpan
148-
.getAttributes()
149-
.get(HypertraceSemanticAttributes.httpResponseHeader("test-response-header")));
154+
TEST_WRITER
155+
.getAttributesMap(clientSpan)
156+
.get("http.response.header.test-response-header")
157+
.getStringValue());
150158
Assertions.assertEquals(
151159
requestBody,
152-
clientSpan.getAttributes().get(HypertraceSemanticAttributes.HTTP_REQUEST_BODY));
153-
Assertions.assertNull(
154-
clientSpan.getAttributes().get(HypertraceSemanticAttributes.HTTP_RESPONSE_BODY));
160+
TEST_WRITER.getAttributesMap(clientSpan).get("http.request.body").getStringValue());
161+
Assertions.assertNull(TEST_WRITER.getAttributesMap(clientSpan).get("http.response.body"));
155162
}
156163

157164
private static String readInputStream(InputStream inputStream) throws IOException {
@@ -168,7 +175,7 @@ private static String readInputStream(InputStream inputStream) throws IOExceptio
168175
return textBuilder.toString();
169176
}
170177

171-
class NonRepeatableStringEntity extends StringEntity {
178+
static class NonRepeatableStringEntity extends StringEntity {
172179

173180
public NonRepeatableStringEntity(String s) throws UnsupportedEncodingException {
174181
super(s);

instrumentation/apache-httpclient-4.0/build.gradle.kts

+1-4
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ val versions: Map<String, String> by extra
4141

4242
dependencies {
4343
api(project(":instrumentation:java-streams"))
44-
testImplementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-apache-httpclient-4.0:${versions["opentelemetry_java_agent"]}")
4544
library("org.apache.httpcomponents:httpclient:4.0")
46-
47-
testImplementation(testFixtures(project(":testing-common")))
48-
testImplementation("io.opentelemetry.instrumentation:opentelemetry-instrumentation-api-semconv:${versions["opentelemetry_semconv"]}")
45+
testImplementation(project(":testing-common"))
4946
}

instrumentation/build.gradle.kts

+108
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,111 @@ tasks {
6262
relocate("io.opentelemetry.extension.aws", "io.opentelemetry.javaagent.shaded.io.opentelemetry.extension.aws")
6363
}
6464
}
65+
66+
subprojects {
67+
class JavaagentTestArgumentsProvider(
68+
@InputFile
69+
@PathSensitive(org.gradle.api.tasks.PathSensitivity.RELATIVE)
70+
val agentShadowJar: File,
71+
72+
@InputFile
73+
@PathSensitive(org.gradle.api.tasks.PathSensitivity.RELATIVE)
74+
val shadowJar: File,
75+
76+
@InputFile
77+
@PathSensitive(org.gradle.api.tasks.PathSensitivity.RELATIVE)
78+
val extensionJar: File,
79+
) : CommandLineArgumentProvider {
80+
override fun asArguments(): Iterable<String> = listOf(
81+
"-Dotel.javaagent.debug=true",
82+
"-javaagent:${agentShadowJar.absolutePath}",
83+
"-Dht.javaagent.filter.jar.paths=${extensionJar.absolutePath}",
84+
"-Dotel.exporter.otlp.protocol=http/protobuf",
85+
"-Dotel.exporter.otlp.traces.endpoint=http://localhost:4318/v1/traces",
86+
"-Dotel.metrics.exporter=none",
87+
// make the path to the javaagent available to tests
88+
"-Dotel.javaagent.testing.javaagent-jar-path=${agentShadowJar.absolutePath}",
89+
"-Dotel.javaagent.experimental.initializer.jar=${shadowJar.absolutePath}",
90+
91+
// prevent sporadic gradle deadlocks, see SafeLogger for more details
92+
"-Dotel.javaagent.testing.transform-safe-logging.enabled=true",
93+
// Reduce noise in assertion messages since we don't need to verify this in most tests. We check
94+
// in smoke tests instead.
95+
"-Dotel.javaagent.add-thread-details=false",
96+
// suppress repeated logging of "No metric data to export - skipping export."
97+
// since PeriodicMetricReader is configured with a short interval
98+
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.opentelemetry.sdk.metrics.export.PeriodicMetricReader=INFO",
99+
// suppress a couple of verbose ClassNotFoundException stack traces logged at debug level
100+
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ServerImplBuilder=INFO",
101+
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.internal.ManagedChannelImplBuilder=INFO",
102+
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.perfmark.PerfMark=INFO",
103+
"-Dio.opentelemetry.javaagent.slf4j.simpleLogger.log.io.grpc.Context=INFO"
104+
)
105+
}
106+
107+
tasks.withType<Test>().configureEach {
108+
val instShadowTask: Jar = project(":instrumentation").tasks.named<Jar>("shadowJar").get()
109+
inputs.files(layout.files(instShadowTask))
110+
val instShadowJar = instShadowTask.archiveFile.get().asFile
111+
112+
val shadowTask: Jar = project(":javaagent").tasks.named<Jar>("shadowJar").get()
113+
inputs.files(layout.files(shadowTask))
114+
val agentShadowJar = shadowTask.archiveFile.get().asFile
115+
116+
val extensionBuild: Jar = project(":tests-extension").tasks.named<Jar>("shadowJar").get()
117+
inputs.files(layout.files(extensionBuild))
118+
val extensionJar = extensionBuild.archiveFile.get().asFile
119+
120+
dependsOn(":instrumentation:shadowJar")
121+
122+
dependsOn(":javaagent:shadowJar")
123+
124+
dependsOn(":tests-extension:shadowJar")
125+
126+
jvmArgumentProviders.add(JavaagentTestArgumentsProvider(agentShadowJar, instShadowJar, extensionJar))
127+
128+
// We do fine-grained filtering of the classpath of this codebase's sources since Gradle's
129+
// configurations will include transitive dependencies as well, which tests do often need.
130+
classpath = classpath.filter {
131+
if (file(layout.buildDirectory.dir("resources/main")).equals(it) || file(layout.buildDirectory.dir("classes/java/main")).equals(
132+
it
133+
)
134+
) {
135+
// The sources are packaged into the testing jar, so we need to exclude them from the test
136+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
137+
return@filter false
138+
}
139+
140+
val lib = it.absoluteFile
141+
if (lib.name.startsWith("opentelemetry-javaagent-")) {
142+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
143+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
144+
return@filter false
145+
}
146+
if (lib.name.startsWith("javaagent-core")) {
147+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
148+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
149+
return@filter false
150+
}
151+
if (lib.name.startsWith("filter-api")) {
152+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
153+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
154+
return@filter false
155+
}
156+
if (lib.name.startsWith("opentelemetry-") && lib.name.contains("-autoconfigure-")) {
157+
// These dependencies should not be on the test classpath, because they will auto-instrument
158+
// the library and the tests could pass even if the javaagent instrumentation fails to apply
159+
return@filter false
160+
}
161+
return@filter true
162+
}
163+
}
164+
165+
configurations.configureEach {
166+
if (name.endsWith("testruntimeclasspath", ignoreCase = true)) {
167+
// Added by agent, don't let Gradle bring it in when running tests.
168+
exclude("io.opentelemetry.javaagent", "opentelemetry-javaagent-bootstrap")
169+
}
170+
}
171+
172+
}

instrumentation/grpc-1.6/build.gradle.kts

+37-8
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ idea {
3535
}
3636
}
3737

38-
val testGrpcVersion = "1.30.0"
39-
4038
protobuf {
4139
protoc {
4240
// The artifact spec for the Protobuf Compiler
@@ -61,7 +59,6 @@ val grpcVersion = "1.6.0"
6159

6260
dependencies {
6361
api("io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:${versions["opentelemetry_java_agent"]}")
64-
testImplementation("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.6:${versions["opentelemetry_java_agent"]}")
6562
implementation(project(":instrumentation:grpc-common"))
6663
implementation(project(":shaded-protobuf-java-util", "shadow"))
6764

@@ -74,7 +71,7 @@ dependencies {
7471

7572
implementation("javax.annotation:javax.annotation-api:1.3.2")
7673

77-
testImplementation(testFixtures(project(":testing-common")))
74+
testImplementation(project(":testing-common"))
7875

7976
testImplementation(files(project(":instrumentation:grpc-shaded-netty-1.9").artifacts))
8077

@@ -128,20 +125,52 @@ for (version in listOf("1.30.0")) {
128125
extendsFrom(configurations.runtimeClasspath.get())
129126
}
130127
dependencies {
131-
versionedConfiguration(testFixtures(project(":testing-common")))
132-
versionedConfiguration("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-grpc-1.6:${versions["opentelemetry_java_agent"]}")
133-
versionedConfiguration("io.opentelemetry.instrumentation:opentelemetry-grpc-1.6:${versions["opentelemetry_java_agent"]}")
128+
versionedConfiguration(project(":testing-common"))
134129
versionedConfiguration(project(":instrumentation:grpc-shaded-netty-1.9"))
135130
versionedConfiguration(platform("io.grpc:grpc-bom:$version"))
136131
versionedConfiguration("io.grpc:grpc-core")
137132
versionedConfiguration("io.grpc:grpc-protobuf")
138133
versionedConfiguration("io.grpc:grpc-stub")
139134
versionedConfiguration("io.grpc:grpc-netty")
140-
141135
}
142136
val versionedTest = task<Test>("test_${version}") {
143137
group = "verification"
144138
classpath = versionedConfiguration + sourceSets.main.get().output + sourceSets.test.get().output + sourceSets.named(computeSourceSetNameForVersion(version)).get().output
139+
// We do fine-grained filtering of the classpath of this codebase's sources since Gradle's
140+
// configurations will include transitive dependencies as well, which tests do often need.
141+
classpath = classpath.filter {
142+
if (file(layout.buildDirectory.dir("resources/main")).equals(it) || file(layout.buildDirectory.dir("classes/java/main")).equals(
143+
it
144+
)
145+
) {
146+
// The sources are packaged into the testing jar, so we need to exclude them from the test
147+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
148+
return@filter false
149+
}
150+
151+
val lib = it.absoluteFile
152+
if (lib.name.startsWith("opentelemetry-javaagent-")) {
153+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
154+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
155+
return@filter false
156+
}
157+
if (lib.name.startsWith("javaagent-core")) {
158+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
159+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
160+
return@filter false
161+
}
162+
if (lib.name.startsWith("filter-api")) {
163+
// These dependencies are packaged into the testing jar, so we need to exclude them from the test
164+
// classpath, which automatically inherits them, to ensure our shaded versions are used.
165+
return@filter false
166+
}
167+
if (lib.name.startsWith("opentelemetry-") && lib.name.contains("-autoconfigure-")) {
168+
// These dependencies should not be on the test classpath, because they will auto-instrument
169+
// the library and the tests could pass even if the javaagent instrumentation fails to apply
170+
return@filter false
171+
}
172+
return@filter true
173+
}
145174
useJUnitPlatform()
146175
}
147176
tasks.check { dependsOn(versionedTest) }

0 commit comments

Comments
 (0)