Skip to content

Commit

Permalink
Merge pull request #10405 from geoand/#10399
Browse files Browse the repository at this point in the history
Fix missing Jaeger client version in native mode
  • Loading branch information
gsmet authored Jul 1, 2020
2 parents 7af8f21 + 75c7d53 commit 6a45fbd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -28,6 +30,12 @@ public class JaegerProcessor {
@Inject
BuildProducer<ExtensionSslNativeSupportBuildItem> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -14,4 +18,11 @@ public String getTest() {
return "TEST";
}

@GET
@Path("/jaegerversion")
@Produces(MediaType.TEXT_PLAIN)
public String opentracingVersion() {
return JaegerTracer.getVersionFromProperties();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.junit.jupiter.api.Test;

import io.jaegertracing.internal.JaegerTracer;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;

Expand All @@ -20,4 +21,10 @@ public void invokeResource() {
.body(is("TEST"));
}

@Test
public void testVersion() {
RestAssured.when().get("/opentracing/jaegerversion").then()
.body(is(JaegerTracer.getVersionFromProperties()));
}

}

0 comments on commit 6a45fbd

Please sign in to comment.