Skip to content

Commit

Permalink
Fix JMX invalid composite value type log message (#3849)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasKunz authored Oct 25, 2024
1 parent 52b5679 commit 1545f3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Use subheadings with the "=====" level for adding notes for unreleased changes:
=== Unreleased
[float]
===== Bug fixes
* Fix JMX metric warning message about unsupported composite value types - {pull}3849[#3849]
[[release-notes-1.x]]
=== Java Agent version 1.x
Expand Down
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 1545f3b

Please sign in to comment.