microprofile-metrics has test failure in jvm mode
See original GitHub issuemicroprofile-metrics quickstart has test failure in jvm mode running against Quarkus master 7404e8e0f - (HEAD -> master, upstream/master, origin/master, origin/HEAD) Merge pull request #3799 from stuartwdouglas/blocking-op-detection (3 hours ago) <Stéphane Épardaud>
@jmartisk can you take a look ?
[INFO] Running org.acme.metrics.PrimeNumberCheckerTest
2019-09-03 14:25:05,655 INFO [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
2019-09-03 14:25:06,893 INFO [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 1238ms
2019-09-03 14:25:07,551 INFO [io.quarkus] (main) Quarkus 999-SNAPSHOT started in 0.656s. Listening on: http://0.0.0.0:8081
2019-09-03 14:25:07,552 INFO [io.quarkus] (main) Installed features: [cdi, resteasy, smallrye-metrics, vertx, vertx-web]
2019-09-03 14:25:09,029 ERROR [io.und.req.io] (executor-thread-1) Exception handling request ae775d31-07d9-4986-adf0-6941f106bb44-1 to /33: org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Error invoking aroundConstructs
at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:381)
at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:503)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
at io.quarkus.resteasy.runtime.ResteasyFilter$ResteasyResponseWrapper.sendError(ResteasyFilter.java:65)
at io.undertow.servlet.handlers.DefaultServlet.doGet(DefaultServlet.java:172)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at io.quarkus.resteasy.runtime.ResteasyFilter.doFilter(ResteasyFilter.java:28)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.quarkus.resteasy.runtime.ResteasyAsyncWrappingFilter.doFilter(ResteasyAsyncWrappingFilter.java:16)
at javax.servlet.http.HttpFilter.doFilter(HttpFilter.java:127)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:63)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:133)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:65)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:270)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:116)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:113)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.quarkus.undertow.runtime.UndertowDeploymentRecorder$9$1$1.call(UndertowDeploymentRecorder.java:439)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:250)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:59)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:82)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:290)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:665)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at java.lang.Thread.run(Thread.java:748)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.RuntimeException: Error invoking aroundConstructs
at org.acme.metrics.PrimeNumberChecker_Bean.create(PrimeNumberChecker_Bean.zig:175)
at org.acme.metrics.PrimeNumberChecker_Bean.get(PrimeNumberChecker_Bean.zig:299)
at org.acme.metrics.PrimeNumberChecker_Bean.get(PrimeNumberChecker_Bean.zig:34)
at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:329)
at io.quarkus.arc.ArcContainerImpl.beanInstanceHandle(ArcContainerImpl.java:341)
at io.quarkus.arc.ArcContainerImpl$1.get(ArcContainerImpl.java:206)
at io.quarkus.arc.ArcContainerImpl$1.get(ArcContainerImpl.java:203)
at io.quarkus.arc.runtime.ArcRecorder$2$1.create(ArcRecorder.java:70)
at io.quarkus.resteasy.server.common.runtime.QuarkusConstructorInjector.construct(QuarkusConstructorInjector.java:56)
at org.jboss.resteasy.plugins.server.resourcefactory.POJOResourceFactory.createResource(POJOResourceFactory.java:69)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:364)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
... 53 more
Caused by: java.lang.IllegalArgumentException: A metric with metricID MetricID{name='org.acme.metrics.PrimeNumberChecker.highestPrimeNumberSoFar', tags=[]} already exists
at io.smallrye.metrics.MetricsRegistryImpl.register(MetricsRegistryImpl.java:129)
at io.smallrye.metrics.MetricRegistries_ProducerMethod_getApplicationRegistry_3084f885749d4d534e6c1a0434dc45444ee9cbec_ClientProxy.register(MetricRegistries_ProducerMethod_getApplicationRegistry_3084f885749d4d534e6c1a0434dc45444ee9cbec_ClientProxy.zig:1406)
at io.smallrye.metrics.interceptors.MetricsInterceptor.metrics(MetricsInterceptor.java:77)
at io.smallrye.metrics.interceptors.MetricsInterceptor_Bean.intercept(MetricsInterceptor_Bean.zig:127)
at io.quarkus.arc.InvocationContextImpl$InterceptorInvocation.invoke(InvocationContextImpl.java:254)
at io.quarkus.arc.InvocationContextImpl.invokeNext(InvocationContextImpl.java:133)
at io.quarkus.arc.InvocationContextImpl.proceed(InvocationContextImpl.java:154)
at org.acme.metrics.PrimeNumberChecker_Bean.create(PrimeNumberChecker_Bean.zig:162)
... 64 more
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 4.882 s <<< FAILURE! - in org.acme.metrics.PrimeNumberCheckerTest
[ERROR] checkCounter Time elapsed: 1.577 s <<< FAILURE!
java.lang.AssertionError:
1 expectation failed.
JSON path 'org.acme.metrics.PrimeNumberChecker.performedChecks' doesn't match.
Expected: is <2>
Actual: 1
at org.acme.metrics.PrimeNumberCheckerTest.assertMetricValue(PrimeNumberCheckerTest.java:31)
at org.acme.metrics.PrimeNumberCheckerTest.checkCounter(PrimeNumberCheckerTest.java:19)
2019-09-03 14:25:09,219 INFO [io.quarkus] (main) Quarkus stopped in 0.074s
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] PrimeNumberCheckerTest.checkCounter:19->assertMetricValue:31 1 expectation failed.
JSON path 'org.acme.metrics.PrimeNumberChecker.performedChecks' doesn't match.
Expected: is <2>
Actual: 1
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Monitoring the metrics of Java microservices using Eclipse ...
The MicroProfile Metrics API is included in the MicroProfile dependency ... To determine whether the tests detect a failure, go to the MetricsIT.java...
Read more >Measuring Performance - Quarkus
When measuring the footprint of a Quarkus application, we measure Resident Set Size (RSS) and not the JVM heap size which is only...
Read more >Collecting metrics in your Quarkus applications
As an application developer, you can collect metrics using Micrometer to improve the performance of your Quarkus application. Prerequisites.
Read more >MicroProfile Metrics - Apache Camel
What's inside; Maven coordinates; Usage; Camel Context metrics; Camel Route metrics; Additional Camel Quarkus configuration. JVM since0.2.0 Native since0.2.
Read more >WildFly Admin Guide
Running a managed domain mode can be helpful in some advanced ... A metric (e.g. number of requests serviced) is a typical example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem is that we’ve recently started adding a @Dependent annotation to classes where we find metric annotations and they don’t have any explicit CDI scope, this is to enable them as CDI beans so that the metrics will work on them. Unfortunately it turns out that if we do this for a REST endpoint, like the
PrimeNumberChecker
, so it turns into a@Dependent
bean, for every HTTP request a new instance will be created, but there is aGauge
in the bean and gauges are allowed to exist only for beans that create only one instance (so when a new instance is being created, the gauge is attempted to be re-registered, and that is forbidden). Possible solutions@ApplicationScoped
, but that sounds just not right@Dependent
annotation to classes which are detected to be REST endpoints - they don’t need this and metrics will work without it and only once instance will be created - I suppose this is the correct solution. Do you guys agree?I’ll also think how to improve the error so that it’s clearer that the problem is having a gauge on a bean that creates multiple instances
microprofile-metrics quickstart passes in jvm mode, thanks