DiskSpaceMetrics returns NaN when garbage collected
See original GitHub issueWhen using standard DiskSpaceMetrics, metrics returned are always NaN Jon said that it is a known issue:
there is an issue with that binder where we should have used a strong reference gauge
Jon also has given a workaround:
Iterable<Tag> tagsWithPath = Tags.concat(tags, "path", absolutePath);
Gauge.builder("disk.free", path, File::getUsableSpace)
.strongReference(true)
.tags(tagsWithPath)
.description("Usable space for path")
.baseUnit("bytes")
.register(registry);
Gauge.builder("disk.total", path, File::getTotalSpace)
.strongReference(true)
.tags(tagsWithPath)
.description("Total space for path")
.baseUnit("bytes")
.register(registry);
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Why do reading Micrometer measurement returns NaN ...
Since the gauge doesn't hold a strong reference to the object, when the object is garbage collected, the value becomes NaN .
Read more >gc — Garbage Collector interface — Python 3.11.1 ...
Returns a list of all objects tracked by the collector, excluding the list returned. If generation is not None, return only the objects...
Read more >gc: Garbage Collection - Rdrr.io
gc returns a matrix with rows "Ncells" (cons cells), usually 28 bytes each on 32-bit systems and 56 bytes on 64-bit systems, and...
Read more >Is there Garbage Collection in C and C++? - YouTube
Patreon ➤ https://www.patreon.com/jacobsorberCourses ➤ https://jacobsorber.thinkific.comWebsite ➤ https://www.jacobsorber.com---Is there ...
Read more >Writing a Mark-Sweep Garbage Collector - Dmitry Soshnikov
By itself the “garbage collection” topic relates to abstract ... the most popular of which are the Tagged pointers and NaN-boxing.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@roded thank you for having the patience to explain how this could be reproduced. I have now reproduced this and we’ll get it fixed.
I’m experiencing the same issue with micrometer 1.1.4. Setting the Gauge’s
strongReference
totrue
has resolved the issue as suggested.@shakuzen, regarding the
path
reference: I think that that would work if a reference toDiskSpaceMetrics
was retained in using code. However, I assume some (or most?) users do the following:new DiskSpaceMetrics(new File("/"), tags).bindTo(compositeRegistry);
in which case thepath
as well as theDiskSpaceMetrics
object won’t be retained.I believe that this issue should be reopened.