Skip to content

Commit

Permalink
Bridge opentelemetry api 1.32 (#10026)
Browse files Browse the repository at this point in the history
Co-authored-by: Mateusz Rzeszutek <[email protected]>
  • Loading branch information
laurit and Mateusz Rzeszutek authored Dec 8, 2023
1 parent bbc7836 commit e8b06c0
Show file tree
Hide file tree
Showing 22 changed files with 1,019 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,39 @@ public ContextPropagators getPropagators() {
}

private static ApplicationMeterFactory getMeterFactory() {
try {
// this class is defined in opentelemetry-api-1.32
ApplicationMeterFactory meterFactory =
getMeterFactory(
"io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_32.incubator.metrics.ApplicationMeterFactory132Incubator");
if (meterFactory == null) {
// this class is defined in opentelemetry-api-1.32
meterFactory =
getMeterFactory(
"io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_32.metrics.ApplicationMeterFactory132");
}
if (meterFactory == null) {
// this class is defined in opentelemetry-api-1.31
Class<?> clazz =
Class.forName(
meterFactory =
getMeterFactory(
"io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_31.metrics.ApplicationMeterFactory131");
}
if (meterFactory == null) {
meterFactory = new ApplicationMeterFactory115();
}

return meterFactory;
}

private static ApplicationMeterFactory getMeterFactory(String className) {
try {
Class<?> clazz = Class.forName(className);
return (ApplicationMeterFactory) clazz.getConstructor().newInstance();
} catch (ClassNotFoundException
| NoSuchMethodException
| InstantiationException
| IllegalAccessException
| InvocationTargetException exception) {
return new ApplicationMeterFactory115();
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ dependencies {

testImplementation("io.opentelemetry:opentelemetry-extension-incubator")
}

configurations.configureEach {
if (name == "testRuntimeClasspath" || name == "testCompileClasspath") {
resolutionStrategy {
force("io.opentelemetry:opentelemetry-api:1.31.0")
force("io.opentelemetry:opentelemetry-extension-incubator:1.31.0-alpha")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import application.io.opentelemetry.api.metrics.LongHistogramBuilder;
import application.io.opentelemetry.extension.incubator.metrics.ExtendedDoubleHistogramBuilder;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_10.metrics.ApplicationDoubleHistogramBuilder;
import java.util.List;

final class ApplicationDoubleHistogramBuilder131 extends ApplicationDoubleHistogramBuilder132
final class ApplicationDoubleHistogramBuilder131 extends ApplicationDoubleHistogramBuilder
implements ExtendedDoubleHistogramBuilder {

private final io.opentelemetry.api.metrics.DoubleHistogramBuilder agentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import application.io.opentelemetry.api.common.AttributeKey;
import application.io.opentelemetry.extension.incubator.metrics.ExtendedLongHistogramBuilder;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_10.metrics.ApplicationLongHistogramBuilder;
import java.util.List;

final class ApplicationLongHistogramBuilder131 extends ApplicationLongHistogramBuilder132
final class ApplicationLongHistogramBuilder131 extends ApplicationLongHistogramBuilder
implements ExtendedLongHistogramBuilder {

private final io.opentelemetry.api.metrics.LongHistogramBuilder agentBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import application.io.opentelemetry.api.metrics.LongUpDownCounterBuilder;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.v1_15.metrics.ApplicationMeter115;

class ApplicationMeter131 extends ApplicationMeter115 {
public class ApplicationMeter131 extends ApplicationMeter115 {

private final io.opentelemetry.api.metrics.Meter agentMeter;

ApplicationMeter131(io.opentelemetry.api.metrics.Meter agentMeter) {
protected ApplicationMeter131(io.opentelemetry.api.metrics.Meter agentMeter) {
super(agentMeter);
this.agentMeter = agentMeter;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
plugins {
id("otel.javaagent-instrumentation")
}

dependencies {
compileOnly(project(":opentelemetry-api-shaded-for-instrumenting", configuration = "v1_32"))
compileOnly("io.opentelemetry:opentelemetry-extension-incubator")

implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.0:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.4:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.10:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.15:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.27:javaagent"))
implementation(project(":instrumentation:opentelemetry-api:opentelemetry-api-1.31:javaagent"))
}

testing {
suites {
val incubatorTest by registering(JvmTestSuite::class) {
dependencies {
implementation("io.opentelemetry:opentelemetry-extension-incubator")
}
}
}
}

tasks {
check {
dependsOn(testing.suites)
}
}
Loading

0 comments on commit e8b06c0

Please sign in to comment.