client_java
client_java copied to clipboard
Handle possible ThreadMXBean findDeadlockedThreads UnsupportedOperationException
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
https://github.com/prometheus/client_java/blob/a8902cb4718bcbb369b50b64cf7e851362193dd6/prometheus-metrics-instrumentation-jvm/src/main/java/io/prometheus/metrics/instrumentation/jvm/JvmThreadsMetrics.java#L102-L107