Repository: quarkusio/quarkus
Issue: OpenTracing quickstart native build failing

The OpenTracing quickstart native build is failing with current Quarkus master + quickstart development branch:

https://github.com/quarkusio/quarkus-quickstarts/runs/586602480?check_suite_focus=true
```
Error: com.oracle.graal.pointsto.constraints.UnresolvedElementException: Discovered unresolved method during parsing: io.quarkus.jaeger.runtime.QuarkusJaegerMetricsFactory.<init>(). To diagnose the issue you can use the --allow-incomplete-classpath option. The missing method is then reported at run time when it is accessed the first time.
Trace: 
	at parsing io.quarkus.jaeger.runtime.QuarkusJaegerTracer.tracer(QuarkusJaegerTracer.java:45)
Call path from entry point to io.quarkus.jaeger.runtime.QuarkusJaegerTracer.tracer(): 
	at io.quarkus.jaeger.runtime.QuarkusJaegerTracer.tracer(QuarkusJaegerTracer.java:42)
	at io.quarkus.jaeger.runtime.QuarkusJaegerTracer.toString(QuarkusJaegerTracer.java:31)
	at java.lang.String.valueOf(String.java:2994)
	at java.nio.charset.IllegalCharsetNameException.<init>(IllegalCharsetNameException.java:55)
	at java.nio.charset.Charset.checkName(Charset.java:315)
	at com.oracle.svm.core.jdk.Target_java_nio_charset_Charset.lookup(CharsetSubstitutions.java:78)
	at java.nio.charset.Charset.isSupported(Charset.java:505)
	at com.oracle.svm.jni.JNIJavaCallWrappers.jniInvoke_ARRAY:Ljava_nio_charset_Charset_2_0002eisSupported_00028Ljava_lang_String_2_00029Z(generated:0)
```

Changed files:
extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/JaegerDeploymentRecorder.java
extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/QuarkusJaegerTracer.java
extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java

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 5a44493fa4c..1c754e3cb1f 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
@@ -30,7 +30,11 @@ void setupTracer(JaegerDeploymentRecorder jdr, JaegerBuildTimeConfig buildTimeCo
         if (buildTimeConfig.enabled) {
             boolean metricsEnabled = capabilities.isCapabilityPresent(Capabilities.METRICS);
 
-            jdr.registerTracer(jaeger, appConfig, metricsEnabled);
+            if (metricsEnabled) {
+                jdr.registerTracerWithMetrics(jaeger, appConfig);
+            } else {
+                jdr.registerTracerWithoutMetrics(jaeger, appConfig);
+            }
         }
     }
 
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 5481c0d9b22..c025cb1ca2c 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
@@ -5,6 +5,8 @@
 
 import org.jboss.logging.Logger;
 
+import io.jaegertracing.internal.metrics.NoopMetricsFactory;
+import io.jaegertracing.spi.MetricsFactory;
 import io.opentracing.util.GlobalTracer;
 import io.quarkus.runtime.ApplicationConfig;
 import io.quarkus.runtime.annotations.Recorder;
@@ -15,7 +17,15 @@ public class JaegerDeploymentRecorder {
     private static final Optional UNKNOWN_SERVICE_NAME = Optional.of("quarkus/unknown");
     private static final QuarkusJaegerTracer quarkusTracer = new QuarkusJaegerTracer();
 
-    synchronized public void registerTracer(JaegerConfig jaeger, ApplicationConfig appConfig, boolean metricsEnabled) {
+    synchronized public void registerTracerWithoutMetrics(JaegerConfig jaeger, ApplicationConfig appConfig) {
+        registerTracer(jaeger, appConfig, new NoopMetricsFactory());
+    }
+
+    synchronized public void registerTracerWithMetrics(JaegerConfig jaeger, ApplicationConfig appConfig) {
+        registerTracer(jaeger, appConfig, new QuarkusJaegerMetricsFactory());
+    }
+
+    private void registerTracer(JaegerConfig jaeger, ApplicationConfig appConfig, MetricsFactory metricsFactory) {
         if (!jaeger.serviceName.isPresent()) {
             if (appConfig.name.isPresent()) {
                 jaeger.serviceName = appConfig.name;
@@ -24,7 +34,7 @@ synchronized public void registerTracer(JaegerConfig jaeger, ApplicationConfig a
             }
         }
         initTracerConfig(jaeger);
-        quarkusTracer.setMetricsEnabled(metricsEnabled);
+        quarkusTracer.setMetricsFactory(metricsFactory);
         quarkusTracer.reset();
         // register Quarkus tracer to GlobalTracer.
         // Usually the tracer will be registered only here, although consumers
diff --git a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/QuarkusJaegerTracer.java b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/QuarkusJaegerTracer.java
index 7764e7fbc91..3a67636bf2b 100644
--- a/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/QuarkusJaegerTracer.java
+++ b/extensions/jaeger/runtime/src/main/java/io/quarkus/jaeger/runtime/QuarkusJaegerTracer.java
@@ -2,7 +2,6 @@
 
 import io.jaegertracing.Configuration;
 import io.jaegertracing.internal.JaegerTracer;
-import io.jaegertracing.internal.metrics.NoopMetricsFactory;
 import io.jaegertracing.spi.MetricsFactory;
 import io.opentracing.ScopeManager;
 import io.opentracing.Span;
@@ -16,14 +15,14 @@ public class QuarkusJaegerTracer implements Tracer {
     private volatile JaegerTracer tracer;
 
     private boolean logTraceContext;
-    private boolean metricsEnabled;
+    private MetricsFactory metricsFactory;
 
     void setLogTraceContext(boolean logTraceContext) {
         this.logTraceContext = logTraceContext;
     }
 
-    void setMetricsEnabled(boolean metricsEnabled) {
-        this.metricsEnabled = metricsEnabled;
+    void setMetricsFactory(MetricsFactory metricsFactory) {
+        this.metricsFactory = metricsFactory;
     }
 
     @Override
@@ -42,9 +41,6 @@ private Tracer tracer() {
         if (tracer == null) {
             synchronized (this) {
                 if (tracer == null) {
-                    MetricsFactory metricsFactory = metricsEnabled
-                            ? new QuarkusJaegerMetricsFactory()
-                            : new NoopMetricsFactory();
                     tracer = Configuration.fromEnv()
                             .withMetricsFactory(metricsFactory)
                             .getTracerBuilder()