helidon-io / helidon

Java libraries for writing microservices
https://helidon.io
Apache License 2.0
3.44k stars 562 forks source link

Unable to disable application scope metrics: "allGets" and "personalisedGets" #8906

Closed gitglyoxal closed 6 days ago

gitglyoxal commented 1 week ago

Environment Details


Problem Description

In a Helidon MP Quickstart application, there are two application scope metrics personalisedGets and allGets defined in the SimpleGreetResource.java file. I tried to disable these two metrics by adding the following two lines in the META-INF/microprofile-config.properties : metrics.scoping.scopes.0.name=application metrics.scoping.scopes.0.filter.exclude=.*Gets

Current behaviour:

Expected behaviour:

The problem is easily reproducible.

The exception thrown and stack trace:

Exception in thread "main" java.lang.IllegalArgumentException: Attempt to look up or register a metric for annotation org.eclipse.microprofile.metrics.annotation.Counted at public labs.helidon.mp.Message labs.helidon.mp.SimpleGreetResource.getMessage(java.lang.String) failed; the metadata implied by the annotation DefaultMetadata{name='personalizedGets', unit='null', description='Counts personalized GET operations'} does not match the pre-existing metadata DefaultMetadata{name='personalizedGets', unit='', description=null} for [description] at io.helidon.microprofile.metrics.MetricAnnotationInfo$RegistrationPrep.validateMetadata(MetricAnnotationInfo.java:166) at io.helidon.microprofile.metrics.MetricAnnotationInfo$RegistrationPrep.register(MetricAnnotationInfo.java:134) at io.helidon.microprofile.metrics.MetricsCdiExtension.lambda$registerMetricsForAnnotatedSites$14(MetricsCdiExtension.java:564) at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) at io.helidon.microprofile.metrics.MetricsCdiExtension.registerMetricsForAnnotatedSites(MetricsCdiExtension.java:561) at io.helidon.microprofile.metrics.MetricsCdiExtension.registerService(MetricsCdiExtension.java:323) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:95) at org.jboss.weld.injection.StaticMethodInjectionPoint.invoke(StaticMethodInjectionPoint.java:85) at org.jboss.weld.injection.MethodInvocationStrategy$DefaultMethodInvocationStrategy.invoke(MethodInvocationStrategy.java:144) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:330) at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:126) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:308) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:286) at jakarta.enterprise.inject.spi.ObserverMethod.notify(ObserverMethod.java:142) at org.jboss.weld.util.Observers.notify(Observers.java:166) at org.jboss.weld.event.ObserverNotifier.notifySyncObservers(ObserverNotifier.java:285) at org.jboss.weld.event.ObserverNotifier.notify(ObserverNotifier.java:273) at org.jboss.weld.event.EventImpl.fire(EventImpl.java:96) at io.helidon.microprofile.cdi.HelidonContainerImpl.doStart(HelidonContainerImpl.java:311) at io.helidon.common.context.Contexts.runInContext(Contexts.java:137) at io.helidon.microprofile.cdi.HelidonContainerImpl.start(HelidonContainerImpl.java:258) at io.helidon.microprofile.cdi.Main.main(Main.java:80) at io.helidon.microprofile.cdi.CdiStartupProvider.start(CdiStartupProvider.java:39) at io.helidon.Main.main(Main.java:85)

Steps to reproduce

  1. Create a Helidon MP Quickstart application using helidon init: version 4.0.10 and cd into the application directory.
  2. Add the following two lines in the src/main/java/resources/META-INF/microprofile-config.properties: metrics.scoping.scopes.0.name=application metrics.scoping.scopes.0.filter.exclude=.*Gets
  3. Run using "helidon dev" or "mvn clean package -DskipTests && java -jar target/quickstart-mp.jar".

I am attaching my zipped test folder here.

quickstart-mp.zip