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

Update gauge example in documentation #107

Closed
zeelshah90 opened this issue Nov 14, 2019 · 2 comments
Closed

Update gauge example in documentation #107

zeelshah90 opened this issue Nov 14, 2019 · 2 comments
Labels

Comments

@zeelshah90
Copy link

zeelshah90 commented Nov 14, 2019

In this doc[1] section 9.1 please change the example from

AtomicInteger n = registry.gauge("numberGauge", new AtomicInteger(0));
n.set(1);
n.set(2);

TO

AtomicInteger atomicInteger = new AtomicInteger(0);
AtomicInteger n = registry.gauge("numberGauge", atomicInteger);
n.set(1);
n.set(2);

As above example does not work due to weakreference of new AtomicIntger(0).
[1] https://micrometer.io/docs/concepts#_gauges

@izeye
Copy link
Contributor

izeye commented Dec 9, 2019

@zeelshah90 The example you mentioned seems to be valid for me if you retain any reference to n. Am I missing something?

@shakuzen
Copy link
Member

shakuzen commented Dec 9, 2019

I have updated the example code with comments that hopefully clarify things. Let me know if anyone thinks further clarification is still necessary.

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

3 participants