Skip to content

Conversation

@laurit
Copy link
Contributor

@laurit laurit commented Dec 3, 2025

Hopefully resolves #15486
When using composite registry micrometer creates instruments for all registries and stores them in a map. Values are recorded to all instruments. When reading a value it reads from the first element of the map. This PR adds wrapping for the iterator that is used to find the first element of the map that skips over instruments from our registry. Note that this works only for the javaagent instrumentation.

@laurit laurit requested a review from a team as a code owner December 3, 2025 16:44
Copy link
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - I think this is a longstanding issue.

Can this issue also occur with library instrumentation, e.g. spring starter?

@laurit
Copy link
Contributor Author

laurit commented Dec 4, 2025

Great - I think this is a longstanding issue.

Can this issue also occur with library instrumentation, e.g. spring starter?

I believe it can. We are already doing something in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/spring/spring-boot-actuator-autoconfigure-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/actuator/v2_0/OpenTelemetryMeterRegistryAutoConfiguration.java I think we needed to make sure our registry is returned last so actuator could look into other registries first. We could also wrap all the instruments and have the methods that return value look up the instrument from the original registry and get the value from there.
Alternative would be to implement value in our instruments, but the problem with that is that there are multiple ways to compute these values and what we implement might not be the same as what the original registry uses.

@zeitlinger
Copy link
Member

I think we needed to make sure our registry is returned last

Right - thanks for reminding me.
I think that's a good enough solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Micrometer instrumentation breaks Micrometer code

2 participants