Metrics NPE query

Question originally posted in Google Groups


I’m happily using microprofile metrics.

However when my server has just started and my application has deployed and when I start posting requests I sometimes see

Caused by: java.lang.NullPointerException
at fish.payara.microprofile.metrics.cdi.interceptor.AbstractInterceptor.getMetric(
at fish.payara.microprofile.metrics.cdi.interceptor.SimplyTimedInterceptor.getMetric(
at fish.payara.microprofile.metrics.cdi.interceptor.AbstractInterceptor.apply(
at fish.payara.microprofile.metrics.cdi.interceptor.SimplyTimedInterceptor.proceedTimed(
at fish.payara.microprofile.metrics.cdi.interceptor.SimplyTimedInterceptor.applyInterceptor(
at fish.payara.microprofile.metrics.cdi.interceptor.AbstractInterceptor.preInterceptor(
at fish.payara.microprofile.metrics.cdi.interceptor.AbstractInterceptor.methodInvocation(

This only happens during startup so it looks like some race condition.

Could it be that metrics has not been fully initialized when my applications starts running?

I tried to reproduce this in a simple application but without success. Usually the problem with race conditions :frowning:

I hope you can help.



This may be the issue, since metrics are lazily loaded and may not be fully initialised at the point you start making requests.

For example, metrics for a JDBC Connection Pool will not be gathered until an application has used the Connection Pool at least once - this is an attempt to not collect metrics on unused resources.


Thanks for your response. But would this account for the NPE? I would not expect so.