Skip to content

[jmx-gatherer] Transformation Closure not working #1868

@john-hyun-eb

Description

@john-hyun-eb

Component(s)

jmx-metrics

What happened?

Description

The transformation closure feature, and thus the ability to utilize non-numeric metrics, is not working. The feature was added via !960 but I believe some interaction with !949 is causing the problem. Not sure if this is the cause but InstrumentHelper.groovy is invoking the static MBeanHelper.getBeanAttribute which ignores transformations.

Steps to Reproduce

Run a simple Java program that waits forever and exposes a JMX port.

Run the jmx gatherer with the following groovy collection script:

`def jvmMetrics = otel.mbean("java.lang:type=Runtime",
["my.mbean.jvm.vendor": { mbean -> mbean.getProperty("VmVendor") == "Eclipse Adoptium" ? 1 : 0 }]
)

otel.instrument(jvmMetrics,
"my.metric.jvm.vendor",
"my.mbean.jvm.vendor",
otel.&longValueCallback)
`

Expected Result

If run on a Termurin JDK it should report a my.metric.jvm.vendor value of 1

Actual Result

The logs show:

WARNING: Expected attribute my.mbean.jvm.vendor not found in mbean java.lang:type=Runtime

Component version

1.45.0

Log output

No response

Additional context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions