diff --git a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java index 685eb59992..6790682864 100644 --- a/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java +++ b/apm-agent-plugins/apm-jmx-plugin/src/main/java/co/elastic/apm/agent/jmx/JmxMetricTracker.java @@ -355,15 +355,14 @@ private static String metricPrepend(Labels labels) { return ""; } - private static void addJmxMetricRegistration(JmxMetric jmxMetric, List registrations, ObjectName objectName, Object value, JmxMetric.Attribute attribute, String attributeName, String metricPrepend) throws AttributeNotFoundException { + private static void addJmxMetricRegistration(JmxMetric jmxMetric, List registrations, ObjectName objectName, Object value, JmxMetric.Attribute attribute, String attributeName, @Nullable String metricPrepend) throws AttributeNotFoundException { + String effectiveAttributeName = metricPrepend == null ? attributeName : metricPrepend + attributeName; if (value instanceof Number) { logger.debug("Found number attribute {}={}", attribute.getJmxAttributeName(), value); registrations.add( new JmxMetricRegistration( attribute.getMetricName( - metricPrepend == null ? - attributeName : - metricPrepend + attributeName + effectiveAttributeName ), attribute.getLabels(objectName), attributeName, @@ -380,10 +379,7 @@ private static void addJmxMetricRegistration(JmxMetric jmxMetric, List