Skip to content

Commit c20e157

Browse files
authored
Run opentelemetry api bridge tests agains the bridged api version (#11085)
1 parent 96c4922 commit c20e157

File tree

8 files changed

+74
-6
lines changed

8 files changed

+74
-6
lines changed

instrumentation/opentelemetry-api/opentelemetry-api-1.0/javaagent/build.gradle.kts

+9
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,12 @@ dependencies {
4242
// @WithSpan annotation is used to generate spans in ContextBridgeTest
4343
testImplementation(project(":instrumentation-annotations"))
4444
}
45+
46+
configurations.configureEach {
47+
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
48+
resolutionStrategy {
49+
// earliest version that works with out test harness
50+
force("io.opentelemetry:opentelemetry-api:1.4.0")
51+
}
52+
}
53+
}

instrumentation/opentelemetry-api/opentelemetry-api-1.10/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ dependencies {
77
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
88
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent"))
99
}
10+
11+
configurations.configureEach {
12+
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
13+
resolutionStrategy {
14+
force("io.opentelemetry:opentelemetry-api:1.10.0")
15+
}
16+
}
17+
}

instrumentation/opentelemetry-api/opentelemetry-api-1.10/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/opentelemetryapi/v1_10/metrics/MeterTest.java

+17-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import io.opentelemetry.api.metrics.ObservableLongUpDownCounter;
2626
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
2727
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
28+
import java.lang.reflect.Method;
2829
import org.assertj.core.api.AbstractIterableAssert;
2930
import org.junit.jupiter.api.BeforeEach;
3031
import org.junit.jupiter.api.Test;
@@ -116,7 +117,7 @@ void observableLongCounter() throws InterruptedException {
116117
.hasAttributesSatisfying(
117118
equalTo(AttributeKey.stringKey("q"), "r"))))));
118119

119-
observableCounter.close();
120+
close(observableCounter);
120121

121122
// sleep exporter interval
122123
Thread.sleep(100);
@@ -192,7 +193,7 @@ void observableDoubleCounter() throws InterruptedException {
192193
.hasAttributesSatisfying(
193194
equalTo(AttributeKey.stringKey("q"), "r"))))));
194195

195-
observableCounter.close();
196+
close(observableCounter);
196197

197198
// sleep exporter interval
198199
Thread.sleep(100);
@@ -267,7 +268,7 @@ void observableLongUpDownCounter() throws InterruptedException {
267268
.hasAttributesSatisfying(
268269
equalTo(AttributeKey.stringKey("q"), "r"))))));
269270

270-
observableCounter.close();
271+
close(observableCounter);
271272

272273
// sleep exporter interval
273274
Thread.sleep(100);
@@ -343,7 +344,7 @@ void observableDoubleUpDownCounter() throws InterruptedException {
343344
.hasAttributesSatisfying(
344345
equalTo(AttributeKey.stringKey("q"), "r"))))));
345346

346-
observableCounter.close();
347+
close(observableCounter);
347348

348349
// sleep exporter interval
349350
Thread.sleep(100);
@@ -448,7 +449,7 @@ void longGauge() throws InterruptedException {
448449
.hasAttributesSatisfying(
449450
equalTo(AttributeKey.stringKey("q"), "r"))))));
450451

451-
observableGauge.close();
452+
close(observableGauge);
452453

453454
// sleep exporter interval
454455
Thread.sleep(100);
@@ -490,7 +491,7 @@ void doubleGauge() throws InterruptedException {
490491
.hasAttributesSatisfying(
491492
equalTo(AttributeKey.stringKey("q"), "r"))))));
492493

493-
observableGauge.close();
494+
close(observableGauge);
494495

495496
// sleep exporter interval
496497
Thread.sleep(100);
@@ -499,4 +500,14 @@ void doubleGauge() throws InterruptedException {
499500

500501
testing.waitAndAssertMetrics(instrumentationName, "test", AbstractIterableAssert::isEmpty);
501502
}
503+
504+
private static void close(Object observableInstrument) {
505+
// our bridge includes close method, although it was added in 1.12
506+
try {
507+
Method close = observableInstrument.getClass().getDeclaredMethod("close");
508+
close.invoke(observableInstrument);
509+
} catch (Exception exception) {
510+
throw new IllegalStateException("Failed to call close", exception);
511+
}
512+
}
502513
}

instrumentation/opentelemetry-api/opentelemetry-api-1.15/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ dependencies {
88
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent"))
99
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent"))
1010
}
11+
12+
configurations.configureEach {
13+
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
14+
resolutionStrategy {
15+
force("io.opentelemetry:opentelemetry-api:1.15.0")
16+
}
17+
}
18+
}

instrumentation/opentelemetry-api/opentelemetry-api-1.27/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ dependencies {
99
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent"))
1010
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.15:javaagent"))
1111
}
12+
13+
configurations.configureEach {
14+
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
15+
resolutionStrategy {
16+
force("io.opentelemetry:opentelemetry-api:1.27.0")
17+
}
18+
}
19+
}

instrumentation/opentelemetry-api/opentelemetry-api-1.32/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ dependencies {
1414
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.31:javaagent"))
1515
}
1616

17+
configurations.configureEach {
18+
if (name.endsWith("testRuntimeClasspath", true) || name.endsWith("testCompileClasspath", true)) {
19+
resolutionStrategy {
20+
force("io.opentelemetry:opentelemetry-api:1.32.0")
21+
}
22+
}
23+
}
24+
1725
testing {
1826
suites {
1927
val incubatorTest by registering(JvmTestSuite::class) {

instrumentation/opentelemetry-api/opentelemetry-api-1.37/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ dependencies {
1515
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.32:javaagent"))
1616
}
1717

18+
configurations.configureEach {
19+
if (name.endsWith("testRuntimeClasspath", true) || name.endsWith("testCompileClasspath", true)) {
20+
resolutionStrategy {
21+
force("io.opentelemetry:opentelemetry-api:1.37.0")
22+
}
23+
}
24+
}
25+
1826
testing {
1927
suites {
2028
val incubatorTest by registering(JvmTestSuite::class) {

instrumentation/opentelemetry-api/opentelemetry-api-1.4/javaagent/build.gradle.kts

+8
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ dependencies {
66
compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "shadow"))
77
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
88
}
9+
10+
configurations.configureEach {
11+
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
12+
resolutionStrategy {
13+
force("io.opentelemetry:opentelemetry-api:1.4.0")
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)