Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle possible ThreadMXBean findDeadlockedThreads UnsupportedOperationException #866

Open
dhoard opened this issue Sep 26, 2023 · 0 comments
Assignees

Comments

@dhoard
Copy link
Collaborator

dhoard commented Sep 26, 2023

While testing the JMX Exporter against the latest JVM versions...

https://github.com/prometheus/jmx_exporter/blob/main/integration_test_suite/integration_tests/src/test/resources/docker-image-names.all.txt

It seems that azul/prime:8, azul/prime:11, and azul/prime:17 have changed behavior and no longer support findDeadlockedThreads, throwing an UnsupportedOperationException

java.lang.UnsupportedOperationException: Monitoring of Synchronizer Usage is not supported.
at java.management/sun.management.ThreadImpl.findDeadlockedThreads(ThreadImpl.java:431)
at io.prometheus.jmx.shaded.io.prometheus.client.hotspot.ThreadExports.addThreadMetrics(ThreadExports.java:98)
at io.prometheus.jmx.shaded.io.prometheus.client.hotspot.ThreadExports.collect(ThreadExports.java:175)
at io.prometheus.jmx.shaded.io.prometheus.client.hotspot.ThreadExports.collect(ThreadExports.java:169)

This exists in the pre-1.0.0 code, but will also cause issues in the 1.0.0 code.

The code below needs to be changed to handle such scenarios since the JVM is not required to support findDeadlockedThreads

if (!isNativeImage) {
GaugeWithCallback.builder(config)
.name(JVM_THREADS_DEADLOCKED)
.help("Cycles of JVM-threads that are in deadlock waiting to acquire object monitors or ownable synchronizers")
.callback(callback -> callback.call(nullSafeArrayLength(threadBean.findDeadlockedThreads())))
.register(registry);

sladkoff added a commit to sladkoff/minecraft-prometheus-exporter that referenced this issue Jan 2, 2024
This does not fix the underlying bug (prometheus/client_java#866) but allows the plugin to start without the JVM metrics.

Partially fixes #197.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants