diff --git a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java index 66623769a00c7..b068d3e969832 100644 --- a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java +++ b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java @@ -6,6 +6,7 @@ import org.eclipse.microprofile.metrics.MetricType; import org.eclipse.microprofile.metrics.Tag; +import io.jaegertracing.internal.JaegerTracer; import io.quarkus.deployment.Capabilities; import io.quarkus.deployment.Capability; import io.quarkus.deployment.Feature; @@ -16,6 +17,7 @@ import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.pkg.steps.NativeBuild; import io.quarkus.jaeger.runtime.JaegerBuildTimeConfig; import io.quarkus.jaeger.runtime.JaegerConfig; import io.quarkus.jaeger.runtime.JaegerDeploymentRecorder; @@ -28,6 +30,12 @@ public class JaegerProcessor { @Inject BuildProducer extensionSslNativeSupport; + @BuildStep(onlyIf = NativeBuild.class) + @Record(ExecutionTime.STATIC_INIT) + void setVersion(JaegerDeploymentRecorder jdr) { + jdr.setJaegerVersion(JaegerTracer.getVersionFromProperties()); + } + @BuildStep @Record(ExecutionTime.RUNTIME_INIT) void setupTracer(JaegerDeploymentRecorder jdr, JaegerBuildTimeConfig buildTimeConfig, JaegerConfig jaeger, diff --git a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java index c025cb1ca2c15..ede6ed6df30a7 100644 --- a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java +++ b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java @@ -17,6 +17,12 @@ public class JaegerDeploymentRecorder { private static final Optional UNKNOWN_SERVICE_NAME = Optional.of("quarkus/unknown"); private static final QuarkusJaegerTracer quarkusTracer = new QuarkusJaegerTracer(); + public static String jaegerVersion; + + public void setJaegerVersion(String version) { + jaegerVersion = version; + } + synchronized public void registerTracerWithoutMetrics(JaegerConfig jaeger, ApplicationConfig appConfig) { registerTracer(jaeger, appConfig, new NoopMetricsFactory()); } diff --git a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/graal/Target_JaegerTracer.java b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/graal/Target_JaegerTracer.java index 02eaea77b090b..c02ebe61e0459 100644 --- a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/graal/Target_JaegerTracer.java +++ b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/graal/Target_JaegerTracer.java @@ -3,12 +3,13 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import io.quarkus.jaeger.runtime.JaegerDeploymentRecorder; + @TargetClass(className = "io.jaegertracing.internal.JaegerTracer") public final class Target_JaegerTracer { @Substitute - private static String loadVersion() { - // TODO: Obtain Jaeger version - return ""; + private static String getVersionFromProperties() { + return JaegerDeploymentRecorder.jaegerVersion; } } diff --git a/integration-tests/main/src/main/java/io/quarkus/it/opentracing/OpenTracingResource.java b/integration-tests/main/src/main/java/io/quarkus/it/opentracing/OpenTracingResource.java index ce7d3cea4319d..8583dfec54405 100644 --- a/integration-tests/main/src/main/java/io/quarkus/it/opentracing/OpenTracingResource.java +++ b/integration-tests/main/src/main/java/io/quarkus/it/opentracing/OpenTracingResource.java @@ -2,9 +2,13 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import org.eclipse.microprofile.opentracing.Traced; +import io.jaegertracing.internal.JaegerTracer; + @Path("/opentracing") public class OpenTracingResource { @@ -14,4 +18,11 @@ public String getTest() { return "TEST"; } + @GET + @Path("/version") + @Produces(MediaType.TEXT_PLAIN) + public String opentracingVersion() { + return JaegerTracer.getVersionFromProperties(); + } + } diff --git a/integration-tests/main/src/test/java/io/quarkus/it/main/OpenTracingTestCase.java b/integration-tests/main/src/test/java/io/quarkus/it/main/OpenTracingTestCase.java index 2d6e833d568a6..6c8b7699c128f 100644 --- a/integration-tests/main/src/test/java/io/quarkus/it/main/OpenTracingTestCase.java +++ b/integration-tests/main/src/test/java/io/quarkus/it/main/OpenTracingTestCase.java @@ -1,6 +1,8 @@ package io.quarkus.it.main; +import static org.hamcrest.Matchers.emptyString; import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; import org.junit.jupiter.api.Test; @@ -20,4 +22,10 @@ public void invokeResource() { .body(is("TEST")); } + @Test + public void testVersion() { + RestAssured.when().get("/opentracing/version").then() + .body(is(not(emptyString()))); + } + }