Skip to content

Commit

Permalink
Fix JMX invalid composite value type log message
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz committed Oct 24, 2024
1 parent 1fda0dd commit 23b3c27
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@
*/
package co.elastic.apm.agent.jmx;

import co.elastic.apm.agent.tracer.AbstractLifecycleListener;
import co.elastic.apm.agent.tracer.metrics.DoubleSupplier;
import co.elastic.apm.agent.tracer.Tracer;
import co.elastic.apm.agent.tracer.metrics.Labels;
import co.elastic.apm.agent.tracer.GlobalLocks;
import co.elastic.apm.agent.sdk.internal.util.ExecutorUtils;
import co.elastic.apm.agent.sdk.internal.util.PrivilegedActionUtils;
import co.elastic.apm.agent.sdk.logging.Logger;
import co.elastic.apm.agent.sdk.logging.LoggerFactory;
import co.elastic.apm.agent.tracer.AbstractLifecycleListener;
import co.elastic.apm.agent.tracer.GlobalLocks;
import co.elastic.apm.agent.tracer.Tracer;
import co.elastic.apm.agent.tracer.configuration.TimeDuration;
import co.elastic.apm.agent.tracer.metrics.DoubleSupplier;
import co.elastic.apm.agent.tracer.metrics.Labels;
import org.stagemonitor.configuration.ConfigurationOption;

import javax.annotation.Nullable;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.MBeanServerDelegate;
Expand All @@ -45,9 +46,8 @@
import javax.management.NotificationListener;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.RuntimeMBeanException;
import javax.management.MBeanException;
import javax.management.ReflectionException;
import javax.management.RuntimeMBeanException;
import javax.management.openmbean.CompositeData;
import javax.management.relation.MBeanServerNotificationFilter;
import java.lang.management.ManagementFactory;
Expand Down Expand Up @@ -436,7 +436,8 @@ private void addJmxMetricRegistration(JmxMetric jmxMetric, List<JmxMetricRegistr
} else if (value instanceof CompositeData) {
final CompositeData compositeValue = (CompositeData) value;
for (final String key : compositeValue.getCompositeType().keySet()) {
if (compositeValue.get(key) instanceof Number) {
Object entryValue = compositeValue.get(key);
if (entryValue instanceof Number) {
logger.debug("Found composite number attribute {}.{}={}", attribute.getJmxAttributeName(), key, value);
registrations.add(
new JmxMetricRegistration(
Expand All @@ -452,7 +453,7 @@ private void addJmxMetricRegistration(JmxMetric jmxMetric, List<JmxMetricRegistr
);
} else {
if (!isWildcard(attribute)) {
logger.warn("Can't create metric '{}' because composite value '{}' is not a number: '{}'", jmxMetric, key, value);
logger.warn("Can't create metric '{}' because composite value '{}' is not a number: '{}'", jmxMetric, key, entryValue);
}
}
}
Expand Down

0 comments on commit 23b3c27

Please sign in to comment.