Repository: quarkusio/quarkus
Issue: Gauges annotation are not showing up his value, on a resteasy endpoint

### Describe the bug

If a gauge is declared in a Resteasy endpoint through an annotation, the gauge value is not pushed to `/metrics`

Example: 
```
@Path("/using-microprofile-pingpong")
public class UsingMicroProfilePingPongResource {

    private static final String PING_PONG = "ping pong";
    private static final long DEFAULT_GAUGE_VALUE = 100L;

    // counters works as expected
    @GET
    @Counted(name = "simple_counter_mp", absolute = true)
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/counter")
    public String simpleScenario() {
        return PING_PONG;
    }

    //TODO gauges are not promoting their values to /metrics
    @GET
    @Gauge(name = "simple_gauge_mp", unit = MetricUnits.NONE)
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/gauge")
    public long highestPrimeNumberSoFar() {
        return DEFAULT_GAUGE_VALUE;
    }
}
```

But If I move on the gauge to a separate public method, then works as expected: 

```
@Path("/using-microprofile-pingpong")
public class UsingMicroProfilePingPongResource {

    private static final String PING_PONG = "ping pong";
    private static final long DEFAULT_GAUGE_VALUE = 100L;

    @GET
    @Counted(name = "simple_counter_mp", absolute = true)
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/counter")
    public String simpleScenario() {
        return PING_PONG;
    }

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/gauge")
    public long highestPrimeNumberSoFar() {
        return getDefaultGauge();
    }

    @Gauge(name = "simple_gauge_mp", unit = MetricUnits.NONE)
    public long getDefaultGauge() {
        return DEFAULT_GAUGE_VALUE;
    }
}
```

Additional when the gauge is not promoted I am getting the following warning message:
```
2022-01-05 16:48:04,996 WARN  [io.mic.cor.ins.int.DefaultGauge] (vert.x-worker-thread-0) Failed to apply the value function for the gauge 'io.quarkus.ts.micrometer.prometheus.UsingMicroProfilePingPongResource.simple_gauge_mp'. Note that subsequent logs will be logged at debug level.: javax.enterprise.context.ContextNotActiveException
	at io.quarkus.arc.impl.ClientProxies.getDelegate(ClientProxies.java:46)
	at io.quarkus.vertx.http.runtime.CurrentVertxRequest_ClientProxy.arc$delegate(Unknown Source)
```

From a developer experience point of view, would be great to have the same behavior in all metrics data structures. So, if counter annotations is available in an endpoint declaration then gauges should be also valid. 



### Expected behavior

_No response_

### Actual behavior

_No response_

### How to Reproduce?

_No response_

### Output of `uname -a` or `ver`

_No response_

### Output of `java -version`

openjdk 11.0.11 2021-04-20 OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9) OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

_No response_

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java
extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java
integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java

diff --git a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java
index 820e93c7411..835b0e6e831 100644
--- a/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java
+++ b/extensions/micrometer/runtime/src/main/java/io/quarkus/micrometer/runtime/binder/mpmetrics/MetricDescriptor.java
@@ -10,7 +10,7 @@
 
 import io.micrometer.core.instrument.Tags;
 
-class MetricDescriptor {
+public class MetricDescriptor {
     final String name;
     final Tags tags;
     ExtendedMetricID metricId = null;
diff --git a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java
index 232fa2cc10d..80df6d2aee8 100644
--- a/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java
+++ b/extensions/resteasy-classic/resteasy/runtime/src/main/java/io/quarkus/resteasy/runtime/QuarkusRestPathTemplateInterceptor.java
@@ -4,6 +4,7 @@
 import java.util.Set;
 
 import javax.annotation.Priority;
+import javax.enterprise.context.ContextNotActiveException;
 import javax.inject.Inject;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.Interceptor;
@@ -12,6 +13,7 @@
 import io.quarkus.arc.ArcInvocationContext;
 import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
 import io.vertx.core.http.impl.HttpServerRequestInternal;
+import io.vertx.ext.web.RoutingContext;
 
 @SuppressWarnings("unused")
 @QuarkusRestPathTemplate
@@ -24,7 +26,13 @@ public class QuarkusRestPathTemplateInterceptor {
     @AroundInvoke
     Object restMethodInvoke(InvocationContext context) throws Exception {
         QuarkusRestPathTemplate annotation = getAnnotation(context);
-        if ((annotation != null) && (request.getCurrent() != null)) {
+        RoutingContext routingContext = null;
+        try {
+            routingContext = request.getCurrent();
+        } catch (ContextNotActiveException ex) {
+            // just leave routingContext as null
+        }
+        if ((annotation != null) && (routingContext != null)) {
             ((HttpServerRequestInternal) request.getCurrent().request()).context().putLocal("UrlPathTemplate",
                     annotation.value());
         }
diff --git a/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java b/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java
index 8504a49f242..0545b7477f9 100644
--- a/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java
+++ b/integration-tests/micrometer-mp-metrics/src/main/java/io/quarkus/it/micrometer/mpmetrics/PrimeResource.java
@@ -70,6 +70,8 @@ String checkPrime(long number) {
     }
 
     @Gauge(name = "highestPrimeNumberSoFar", unit = MetricUnits.NONE, description = "Highest prime number so far.")
+    @GET
+    @Path("/blabla") // make this a REST method just to verify that a gauge will still work on it
     public Long highestPrimeNumberSoFar() {
         return highestPrimeSoFar.get();
     }