I use the quarkus-smallrye-metrics to get some data about the performance of my app.
Every metric from the microprofile works, except of the one that i need the most - Gauge.
Here is the method:
@Gauge(name = "uploadFiles_Gauge", unit = MetricUnits.MILLISECONDS, absolute = true)
public Response uploadFiles(@NotEmpty @QueryParam("fileIds") String fileIds, @QueryParam("tags") @DefaultValue("") String tags) {
return Response.ok(mibService.uploadFiles(tags.isEmpty() ? Collections.emptyList() : Arrays.asList(tags.split(",")), Arrays.asList(fileIds.split(",")))).build();
}
And the error:
2022-04-22 21:00:09,846 [WARN ] [io.smallrye.metrics] [vert.x-worker-thread-1] [] [] Unable to export metric uploadFiles_Gauge: java.lang.IllegalArgumentException
at jdk.internal.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.smallrye.metrics.interceptors.MetricsInterceptor.invokeMethod(MetricsInterceptor.java:92)
at io.smallrye.metrics.interceptors.MetricsInterceptor.access$100(MetricsInterceptor.java:48)
at io.smallrye.metrics.interceptors.MetricsInterceptor$ForwardingGauge.getValue(MetricsInterceptor.java:112)
at io.smallrye.metrics.interceptors.MetricsInterceptor$ForwardingGauge.getValue(MetricsInterceptor.java:98)
at io.smallrye.metrics.exporters.OpenMetricsExporter.createSimpleValueLine(OpenMetricsExporter.java:493)
at io.smallrye.metrics.exporters.OpenMetricsExporter.exposeEntries(OpenMetricsExporter.java:193)
at io.smallrye.metrics.exporters.OpenMetricsExporter.getEntriesForScope(OpenMetricsExporter.java:159)
at io.smallrye.metrics.exporters.OpenMetricsExporter.exportAllScopes(OpenMetricsExporter.java:110)
at io.smallrye.metrics.MetricsRequestHandler.handleRequest(MetricsRequestHandler.java:116)
at io.smallrye.metrics.MetricsRequestHandler_ClientProxy.handleRequest(MetricsRequestHandler_ClientProxy.zig:239)
at io.quarkus.smallrye.metrics.runtime.SmallRyeMetricsHandler.handle(SmallRyeMetricsHandler.java:36)
at io.quarkus.smallrye.metrics.runtime.SmallRyeMetricsHandler.handle(SmallRyeMetricsHandler.java:18)
at io.vertx.ext.web.impl.BlockingHandlerDecorator.lambda$handle$0(BlockingHandlerDecorator.java:48)
at io.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
As you can see, there is some problem with the reflection which I can't solve.
quarkus-smallrye-metrics version is 1.9.2, same for the quarkus and java 11 is used.
What I have using @SimplyTimed: @SimplyTimed
What I would like to achieve: @Here
This is not valid usage of a gauge. A gauge metric is a single number and has to be applied on methods that return a number, but your method returns a Response
. I think you wanted to add @Timed
instead, to track the time it takes to call that method.