Skip to content

Commit

Permalink
Added code to skip RuntimeMXBean attributes SystemProperties, ClassPa…
Browse files Browse the repository at this point in the history
…th, (#859)

BootClassPath, and LibraryPath since the calls to get the attribute
values are very expensive the values are ultimately ignored

Added code to skip FlightRecorderMXBean since the calls are very
expensive and the values are ultimately ignored

Signed-off-by: Doug Hoard <doug.hoard@gmail.com>
  • Loading branch information
dhoard authored Jul 28, 2023
1 parent 700e60f commit 08a1515
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions collector/src/main/java/io/prometheus/jmx/JmxScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,20 @@ private void scrapeBean(MBeanServerConnection beanConn, ObjectName mBeanName) {
for (Object object : attributes) {
if (object instanceof Attribute) {
Attribute attribute = (Attribute) object;
String attributeName = attribute.getName();
if (mBeanName.toString().equals("java.lang:type=Runtime")
&& (attributeName.equalsIgnoreCase("SystemProperties")
|| attributeName.equalsIgnoreCase("ClassPath")
|| attributeName.equalsIgnoreCase("BootClassPath"))
|| attributeName.equalsIgnoreCase("LibraryPath")) {
// Skip attributes for the "java.lang:type=Runtime" MBean because
// getting the values is expensive and the values are ultimately ignored
continue;
} else if (mBeanName.toString().equals("jdk.management.jfr:type=FlightRecorder")) {
// Skip the FlightRecorderMXBean
continue;
}

MBeanAttributeInfo mBeanAttributeInfo = name2MBeanAttributeInfo.get(attribute.getName());
logScrape(mBeanName, mBeanAttributeInfo, "process");
processBeanValue(
Expand Down

0 comments on commit 08a1515

Please sign in to comment.