Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore gc alloc metrics when unsupported #3225

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -35,6 +35,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes:
===== Bug fixes
* Fixed agent programmatic attach with immutable config - {pull}3170[#3170]
* Prevent overriding `ELASTIC_APM_AWS_LAMBDA_HANDLER` in AWS lambda execution when explicitly set - {pull}3205[#3205]
* Ignore gc allocation metrics when unsupported - {pull}3225[#3225]

[[release-notes-1.x]]
=== Java Agent version 1.x
Expand Down
Expand Up @@ -62,11 +62,17 @@ public double get() {
// J9 does contain com.sun.management.ThreadMXBean in classpath
// but the actual MBean it uses (com.ibm.lang.management.internal.ExtendedThreadMXBeanImpl) does not implement it
if (sunBeanClass.isInstance(ManagementFactory.getThreadMXBean())) {

DoubleSupplier supplier = (DoubleSupplier) Class.forName(getClass().getName() + "$HotspotAllocationSupplier").getEnumConstants()[0];

// attempt to read it at least once before registering
supplier.get();

// in reference to JMH's GC profiler (gc.alloc.rate)
registry.add("jvm.gc.alloc", Labels.EMPTY,
(DoubleSupplier) Class.forName(getClass().getName() + "$HotspotAllocationSupplier").getEnumConstants()[0]);
registry.add("jvm.gc.alloc", Labels.EMPTY, supplier);
}
} catch (ClassNotFoundException ignore) {
} catch (UnsupportedOperationException ignore){
}
}

Expand Down