Skip to content

Lots of duplicate metric definitions for micrometer shim #4381

@jack-berg

Description

@jack-berg

If you run a simple spring boot app with spring-boot-starter-actuator and with the micrometer1-shim, you get lots of duplicate metric definition warnings like:

14:57:23.351 [main] WARN  io.opentelemetry.sdk.metrics.internal.state.MetricStorageRegistry - Found duplicate metric definition: jvm.threads.states
        at unknown source
                To enable better debugging, run your JVM with -Dotel.experimental.sdk.metrics.debug=true
Causes
- Description [The current number of threads having RUNNABLE state] does not match [The current number of threads having NEW state]
- InstrumentDescription [The current number of threads having RUNNABLE state] does not match [The current number of threads having NEW state]
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

14:57:23.352 [main] WARN  io.opentelemetry.sdk.metrics.internal.state.MetricStorageRegistry - Found duplicate metric definition: jvm.threads.states
        at unknown source
                To enable better debugging, run your JVM with -Dotel.experimental.sdk.metrics.debug=true
....

I enabled better debugging with Dotel.experimental.sdk.metrics.debug=true and found that the issue seems to be an incompatibility between the micrometer definition of a metric description and the opentelemetry description. In micrometer it appears that each unique set of tags on an instrument can have its own description. Check out the JvmThreadMetrics for an example.

In opentelemetry an instrument is defined by its name, type, description, and unit. If an instrument with the same name, but a different type, description, or unit than one previously created, you've created a semantic error an we log the warnings I've included on this ticket.

We should probably drop micrometer instrument descriptions to ensure we don't create these semantic errors. The unit can be different for each set of tags as well, so we should consider dropping that as well. However, in practice I didn't see any conflicts created by differing units.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions