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

JMX gatherer logs warnings "Instrument ... has recorded multiple values for the same attributes" #936

Open
sirianni opened this issue Jun 27, 2023 · 7 comments
Assignees
Labels

Comments

@sirianni
Copy link

sirianni commented Jun 27, 2023

Component(s)

jmx-metrics

What happened?

Description

Using JMX Gatherer otel.mbeans to match a collection of MBeans consistently emits the warning Instrument ...has recorded multiple values for the same attributes

Steps to Reproduce

Run jmx-gatherer with the following configuration:

otel.jmx.service.url=service:jmx:rmi:///jndi/rmi://:7203/jmxrmi
otel.jmx.groovy.script=./script.groovy
otel.jmx.interval.milliseconds=5000
def garbageCollector = otel.mbeans("java.lang:type=GarbageCollector,*")
otel.instrument(garbageCollector, "jvm.gc.collections.count", "total number of collections that have occurred",
        "1", ["name" : { mbean -> mbean.name().getKeyProperty("name") }],
        "CollectionCount", otel.&longCounterCallback)

(Groovy script snippet copied from jvm metrics)

Expected Result

I expected no warnings to be logged

Actual Result

I got warning messages WARNING: Instrument jvm.gc.collections.count has recorded multiple values for the same attributes.

Jun 27, 2023 8:03:23 PM io.opentelemetry.sdk.internal.ThrottlingLogger doLog
WARNING: Instrument jvm.gc.collections.count has recorded multiple values for the same attributes.
Jun 27, 2023 8:03:23 PM io.opentelemetry.exporter.logging.LoggingMetricExporter export
INFO: Received a collection of 2 metrics for export.
Jun 27, 2023 8:03:23 PM io.opentelemetry.exporter.logging.LoggingMetricExporter export
INFO: metric: ImmutableMetricData{resource=Resource{schemaUrl=https://opentelemetry.io/schemas/1.20.0, attributes={service.name="unknown_service:java", telemetry.sdk.language="java", telemetry.sdk.name="opentelemetry", telemetry.sdk.version="1.27.0"}}, instrumentationScopeInfo=InstrumentationScopeInfo{name=io.opentelemetry.sdk.logs, version=null, schemaUrl=null, attributes={}}, name=queueSize, description=The number of logs queued, unit=1, type=LONG_GAUGE, data=ImmutableGaugeData{points=[ImmutableLongPointData{startEpochNanos=1687896193925000000, epochNanos=1687896203931000000, attributes={logRecordProcessorType="BatchLogRecordProcessor"}, value=0, exemplars=[]}]}}
Jun 27, 2023 8:03:23 PM io.opentelemetry.exporter.logging.LoggingMetricExporter export
INFO: metric: ImmutableMetricData{resource=Resource{schemaUrl=https://opentelemetry.io/schemas/1.20.0, attributes={service.name="unknown_service:java", telemetry.sdk.language="java", telemetry.sdk.name="opentelemetry", telemetry.sdk.version="1.27.0"}}, instrumentationScopeInfo=InstrumentationScopeInfo{name=io.opentelemetry.contrib.jmxmetrics, version=1.27.0-alpha, schemaUrl=null, attributes={}}, name=jvm.gc.collections.count, description=total number of collections that have occurred, unit=1, type=LONG_SUM, data=ImmutableSumData{points=[ImmutableLongPointData{startEpochNanos=1687896193925000000, epochNanos=1687896203931000000, attributes={name="G1 Old Generation"}, value=0, exemplars=[]}, ImmutableLongPointData{startEpochNanos=1687896193925000000, epochNanos=1687896203931000000, attributes={name="G1 Young Generation"}, value=1, exemplars=[]}], monotonic=true, aggregationTemporality=CUMULATIVE}}

Component version

1.27.0-alpha

Log output

No response

Additional context

No response

@sirianni sirianni changed the title JMX gatherer: otel.mbeand() only collects attributes of a single matched MBean JMX gatherer: otel.mbeans() only collects attributes of a single matched MBean Jun 27, 2023
@sirianni sirianni changed the title JMX gatherer: otel.mbeans() only collects attributes of a single matched MBean JMX gatherer logs warnings "Instrument ... has recorded multiple values for the same attributes" Jun 27, 2023
@trask
Copy link
Member

trask commented Jun 27, 2023

cc: jmx-metrics component owners @breedx-splk @Mrod1598 @rmfitzpatrick @dehaansa

@breedx-splk
Copy link
Contributor

I was able to repeat the test and verify the behavior (warning is emitted).

@breedx-splk breedx-splk added the type: bug Something isn't working label Jun 28, 2023
@rmfitzpatrick
Copy link
Contributor

#253 was opened to resolve this issue but there was pushback to the workaround and I wasn't able to track down the issue in how we interact w/ the sdk (or if it was in sdk itself). cc @aunshc for prioritization.

@jack-berg
Copy link
Member

#253 was about duplicate instrument registration. This is about one (or more) callbacks for an instrument recording values for the same set of attributes, which is indeed an error that the SDK should warn about.

@sirianni
Copy link
Author

Is the issue that the name tag on the MBean may not be unique?

["name" : { mbean -> mbean.name().getKeyProperty("name") }],

?

@dehaansa
Copy link
Contributor

@sirianni the issue is that the existing code will register a new callback each time metrics are collected, which each attempts to record the metric value collected when that callback was registered. I believe i've resolved this (and several other issues) in #949

@dehaansa
Copy link
Contributor

#949 was merged and should be available in 1.29.0. Let us know if the issue persists after integrating the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants