Using percentiles in Micrometer leads to NoClassDefFound

282 views
Skip to first unread message

Rudi Araújo

unread,
Jul 9, 2024, 10:42:30 AM7/9/24
to WildFly
Hi folks,

I'm trying to define client-side percentiles with the Micrometer extension. Here is (a simplification of) the code I'm using:

        meterRegistry.config().meterFilter(new MeterFilter() {
            @Override
            public DistributionStatisticConfig configure(Meter.Id id, DistributionStatisticConfig config) {
                return DistributionStatisticConfig.builder()
                        .percentiles(0.10, 0.25, 0.50, 0.75, 0.90, 0.95, 0.99)
                        .percentilesHistogram(true)
                        .build()
                        .merge(config);
            }
        });


However, I'm getting the following runtime error:

java.lang.NoClassDefFoundError: org/HdrHistogram/DoubleRecorder

            at io.mic...@1.9.3//io.micrometer.core.instrument.distribution.TimeWindowPercentileHistogram.<init>(TimeWindowPercentileHistogram.java:41)

            at io.mic...@1.9.3//io.micrometer.core.instrument.AbstractDistributionSummary.<init>(AbstractDistributionSummary.java:33)

            at io.mic...@1.9.3//io.micrometer.core.instrument.cumulative.CumulativeDistributionSummary.<init>(CumulativeDistributionSummary.java:52)

            at io.mic...@1.9.3//io.micrometer.registry.otlp.OtlpDistributionSummary.<init>(OtlpDistributionSummary.java:37)

            at io.mic...@1.9.3//io.micrometer.registry.otlp.OtlpMeterRegistry.newDistributionSummary(OtlpMeterRegistry.java:136)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.lambda$summary$3(MeterRegistry.java:331)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:618)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:570)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.summary(MeterRegistry.java:330)

            at io.mic...@1.9.3//io.micrometer.core.instrument.DistributionSummary$Builder.register(DistributionSummary.java:398)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.summary(MeterRegistry.java:417)

            at io.mic...@1.9.3//io.micrometer.core.instrument.MeterRegistry.summary(MeterRegistry.java:428)

            at *SNIP! The method where I'm attempting to register the summary, followed by many more lines of stack trace*

Caused by: java.lang.ClassNotFoundException: org.HdrHistogram.DoubleRecorder from [Module "io.micrometer" version 1.9.3 from local module loader @27216cd (finder: local module finder @558bdf1f (roots: /opt/wildfly/modules,/opt/wildfly/modules/system/layers/base))]

            at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:200)

            at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)

            at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

            at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)

            ... 72 more


According to the documentation, it seems that Micrometer declares HdrHistogram as an optional dependency, and it is up to the client to decide whether to provide it or not. However, this does not seem to be the case for version 1.9.3 of Micrometer (the version used in the WildFly 29) which should include it as a compile-time dependency. Nevertheless, I have tried to explicitly include the HdrHistogram dependency in my POM. I have tried including it as a module as well, both by using versions 2.2.1 and 2.2.2 of the package, and by explicitly defining the module itself in a module.xml file. Nothing seems to work, so I thought I'd reach out for some guidance.

I'm using WildFly 29.0.1. If it helps, here is the config I'm using, with slight modifications. And the CLI commands I'm using to enable micrometer:

if (outcome != success) of /extension=org.wildfly.extension.micrometer:read-resource
    /extension=org.wildfly.extension.micrometer:add
    /subsystem=micrometer:add()
end-if


/subsystem=micrometer:write-attribute(name=endpoint, value="${OTEL_COLLECTOR_URL}")
/subsystem=micrometer:write-attribute(name=step, value=1)

And of course I'm reloading the server after this.

Any guidance, hints or tips would be greatly appreciated.

Thanks for your time.

Kind regards,
Rudi Araujo.

Jason Lee

unread,
Jul 10, 2024, 12:03:17 PM7/10/24
to Rudi Araújo, WildFly
Hi, Rudi. Could you share a simple reproducer (minus your attempts at a fix)? I can take a look at that and see what I can do from the WF side. It's too late for a fix in 33.0.0.Final (though maybe a .1), but I might be able to get you a fix you can apply to your installation in the meantime.

Jason Lee

Principal Software Engineer

Red Hat JBoss EAP

Java Champion



--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/32912805-59a6-4b7e-84e3-03b2fa14f4efn%40googlegroups.com.

Rudi Araújo

unread,
Jul 11, 2024, 8:36:30 AM7/11/24
to Jason Lee, WildFly
Hi Jason,

Thanks for the quick response.

While I did come up with a small example: https://github.com/autoluminescent/wildfly-percentiles-example

This is no longer a concern for us, because the issue occurs on WildFly versions 29 and 30, but on 31 and 32 it seems to go away. The version of the application on which we are building is currently based on WildFly 29, but fortunately there's a newer version based on 31, so all we need to do is to upgrade it, which we plan to do very soon anyway.

In conclusion, no need for action on your side. Apologies for the noise, but at least now you are aware that client-side percentiles don't work on WildFly 29 and 30. Hope that knowledge is useful. 😊

Kind regards,
Rudi.
Reply all
Reply to author
Forward
0 new messages