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

fix gauge registration with Micrometer #847

Merged
merged 2 commits into from
Jun 21, 2023

Conversation

Ladicek
Copy link
Contributor

@Ladicek Ladicek commented Jun 21, 2023

No description provided.

Ladicek added 2 commits June 21, 2023 13:05
Gauges in Micrometer by default hold the state object weakly. Since we used
the gauge value supplier as the state object, extracted the gauge value
from the state object, and the supplier isn't used anywhere else, it was
easily possible for the supplier to be garbage collected, leading to `NaN`
reported gauge values.

With this commit, we no longer rely on the gauge state object. Instead,
the function that extracts the gauge value from the state object refers
to the value supplier directly.

We still need to pass a non-`null` state object to Micrometer, otherwise
the gauge would never have a value. And for the gauge to keep having a value,
that state object must be strongly reachable from somewhere. Since the value
extraction function is held strongly by Micrometer, and the function holds
a strong reference to the supplier, we use the supplier as the state object,
even if we don't use it for anything else.
@Ladicek Ladicek added this to the 6.2.4 milestone Jun 21, 2023
@Ladicek Ladicek requested a review from a team as a code owner June 21, 2023 11:07
@Ladicek Ladicek merged commit 02dd298 into smallrye:main Jun 21, 2023
@Ladicek Ladicek deleted the fix-micrometer-gauges branch June 21, 2023 11:45
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.

1 participant