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

Sample Groovy yields "Found duplicate metric definition" #222

Closed
rkogelhe opened this issue Jan 31, 2022 · 9 comments
Closed

Sample Groovy yields "Found duplicate metric definition" #222

rkogelhe opened this issue Jan 31, 2022 · 9 comments
Assignees
Labels
component: jmx-metrics needs author feedback Waiting for additional feedback from the author Stale type: bug Something isn't working

Comments

@rkogelhe
Copy link

Description
jmxmetrics using the sample groovy works correctly on the first collection.
On the second collection, we get:
`WARNING: Found duplicate metric definition: my.admin.response.count
at unknown source
To enable better debugging, run your JVM with -Dotel.experimental.sdk.metrics.debug=true
Causes

  • InstrumentType [OBSERVABLE_GAUGE] is async and already registered
    Original instrument registered with same name but is incompatible.
    at unknown source
    To enable better debugging, run your JVM with -Dotel.experimental.sdk.metrics.debug=true

io.opentelemetry.sdk.metrics.internal.state.DuplicateMetricStorageException: Async metric with same name has already been created. Found previous metric: MetricDescriptor{name=my.admin.response.count, description=Count of the number of responses from the admin console, unit=By, sourceView=Optional[View{name=null, description=null, aggregation=DefaultAggregation, attributesProcessor=io.opentelemetry.sdk.metrics.internal.view.AttributesProcessor$1@249c65fd, sourceInfo=INSTANCE}], sourceInstrument=InstrumentDescriptor{name=my.admin.response.count, description=Count of the number of responses from the admin console, unit=By, type=OBSERVABLE_GAUGE, valueType=LONG, sourceInfo=INSTANCE}}, cannot register metric: MetricDescriptor{name=my.admin.response.count, description=Count of the number of responses from the admin console, unit=By, sourceView=Optional[View{name=null, description=null, aggregation=DefaultAggregation, attributesProcessor=io.opentelemetry.sdk.metrics.internal.view.AttributesProcessor$1@249c65fd, sourceInfo=INSTANCE}], sourceInstrument=InstrumentDescriptor{name=my.admin.response.count, description=Count of the number of responses from the admin console, unit=By, type=OBSERVABLE_GAUGE, valueType=LONG, sourceInfo=INSTANCE}}
at io.opentelemetry.sdk.metrics.internal.state.MetricStorageRegistry.register(MetricStorageRegistry.java:75)
at io.opentelemetry.sdk.metrics.internal.state.MeterSharedState.register(MeterSharedState.java:139)
...`

Steps to reproduce
Clone opentelemetry-java-contrib and only build jmx-metrics (full build isn't working)
Run with
jmx_jar="./opentelemetry-java-contrib/jmx-metrics/build/libs/opentelemetry-jmx-metrics-1.11.0-SNAPSHOT.jar" java -Dotel.jmx.groovy.script=./my.groovy -jar $jmx_jar -config ./session.properties
where my.groovy is
def adminResponseTime = otel.mbean("my:name=adminResponseTime") otel.instrument( adminResponseTime, "my.admin.response.count", "Count of the number of responses from the admin console", "By", "Count", otel.&longValueCallback )
and session.properties is
otel.jmx.service.url = service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi otel.jmx.interval.milliseconds = 5000 otel.jmx.username = jmxuser otel.jmx.password = password

Expectation
I would expect an example groovy that works however many collections occur.

What applicable config did you use?
(see reproduction above)

Relevant Environment Information
Version: 1.11.0
OS: MacOS 10.15.7
Compiler: AdoptOpenJDK (build 11.0.10+9)

Additional context
Verified that my JMX mbean was working via jmx term and JConsole.

@rkogelhe rkogelhe added the type: bug Something isn't working label Jan 31, 2022
@rmfitzpatrick
Copy link
Contributor

Apologies for missing this until now. @Mrod1598 do you think you'd be able to rule out 7184f00 for this?

@rmfitzpatrick
Copy link
Contributor

This appears to be introduced by open-telemetry/opentelemetry-java#4020 where there used to be a silent getOrCreate-like behavior. The underlying callback is updated w/ the most recent value via the proxied observer so no data loss should occur but the warning is distracting. The api is relatively in flux (open-telemetry/opentelemetry-java#4143) but we'll likely need to introduce another registry system for the OtelHelper's instruments to avoid this.

@anuraaga
Copy link
Contributor

We're hoping to not need any registries of async callbacks anymore. @jack-berg would be good to check on this and make sure it works smoothly with all the identity changes.

@rmfitzpatrick
Copy link
Contributor

@anuraaga given https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument-type-conflict-detection I think this is a symptom of the jmx-metric gatherer's groovy script running pattern that builds the declared instruments with every interval being at odds with the metric api for both sync and async. This has been the case for a while so having a GroovyMetricEnvironment instrument registry is needed for this library afaict: #253

@anuraaga
Copy link
Contributor

anuraaga commented Mar 12, 2022

@rmfitzpatrick They have the same identity though right? Also we can close instruments between runs now perhaps so I think there is a way to work without the cache. If there isn't, I want us to get there instead of bothering users with unrelated error messages.

@rmfitzpatrick
Copy link
Contributor

They're the same instruments in all cases and would be cached by their descriptor. The spec suggests to me that our current approach isn't supported without caching on the gatherer's end since there are conflicting registrations and a warning should be emitted. As a user I'd prefer this not be the case but can see it either way.

@jack-berg
Copy link
Member

If I understand correctly this should be resolved with #4222.

At this point:

  • Async instruments can have multiple callbacks associated with them.
  • You can request the same instrument multiple times. Because async instruments now support multiple callbacks, this applies to both sync and async instruments.
  • If all the parts of the metric identity match a previous instrument, measurements will be recorded to the same metric stream
  • If multiple instruments share the same name, but some other part of their identity is not equal, you've created an identity conflict. We'll log a diagnostic error message, but export the the measurements in separate metric streams. Its up to the backend to decide how to handle this error scenario.

@trask
Copy link
Member

trask commented May 23, 2023

@rkogelhe is this still an issue?

@trask trask added the needs author feedback Waiting for additional feedback from the author label May 23, 2023
@github-actions
Copy link
Contributor

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@github-actions github-actions bot added the Stale label May 30, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: jmx-metrics needs author feedback Waiting for additional feedback from the author Stale type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants