Skip to content

Commit

Permalink
Run opentelemetry api bridge tests agains the bridged api version (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Apr 10, 2024
1 parent 96c4922 commit c20e157
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,12 @@ dependencies {
// @WithSpan annotation is used to generate spans in ContextBridgeTest
testImplementation(project(":instrumentation-annotations"))
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
// earliest version that works with out test harness
force("io.opentelemetry:opentelemetry-api:1.4.0")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ dependencies {
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent"))
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.10.0")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import io.opentelemetry.api.metrics.ObservableLongUpDownCounter;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.sdk.common.InstrumentationScopeInfo;
import java.lang.reflect.Method;
import org.assertj.core.api.AbstractIterableAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -116,7 +117,7 @@ void observableLongCounter() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableCounter.close();
close(observableCounter);

// sleep exporter interval
Thread.sleep(100);
Expand Down Expand Up @@ -192,7 +193,7 @@ void observableDoubleCounter() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableCounter.close();
close(observableCounter);

// sleep exporter interval
Thread.sleep(100);
Expand Down Expand Up @@ -267,7 +268,7 @@ void observableLongUpDownCounter() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableCounter.close();
close(observableCounter);

// sleep exporter interval
Thread.sleep(100);
Expand Down Expand Up @@ -343,7 +344,7 @@ void observableDoubleUpDownCounter() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableCounter.close();
close(observableCounter);

// sleep exporter interval
Thread.sleep(100);
Expand Down Expand Up @@ -448,7 +449,7 @@ void longGauge() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableGauge.close();
close(observableGauge);

// sleep exporter interval
Thread.sleep(100);
Expand Down Expand Up @@ -490,7 +491,7 @@ void doubleGauge() throws InterruptedException {
.hasAttributesSatisfying(
equalTo(AttributeKey.stringKey("q"), "r"))))));

observableGauge.close();
close(observableGauge);

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

testing.waitAndAssertMetrics(instrumentationName, "test", AbstractIterableAssert::isEmpty);
}

private static void close(Object observableInstrument) {
// our bridge includes close method, although it was added in 1.12
try {
Method close = observableInstrument.getClass().getDeclaredMethod("close");
close.invoke(observableInstrument);
} catch (Exception exception) {
throw new IllegalStateException("Failed to call close", exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ dependencies {
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent"))
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.15.0")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ dependencies {
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.15:javaagent"))
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.27.0")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ dependencies {
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.31:javaagent"))
}

configurations.configureEach {
if (name.endsWith("testRuntimeClasspath", true) || name.endsWith("testCompileClasspath", true)) {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.32.0")
}
}
}

testing {
suites {
val incubatorTest by registering(JvmTestSuite::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ dependencies {
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.32:javaagent"))
}

configurations.configureEach {
if (name.endsWith("testRuntimeClasspath", true) || name.endsWith("testCompileClasspath", true)) {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.37.0")
}
}
}

testing {
suites {
val incubatorTest by registering(JvmTestSuite::class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ dependencies {
compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "shadow"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.4.0")
}
}
}

0 comments on commit c20e157

Please sign in to comment.