Allow closing observers in oshi library #10358
Labels
contribution welcome
Request makes sense, maintainers probably won't have time, contribution would be welcome
enhancement
New feature or request
Is your feature request related to a problem? Please describe.
oshi library helps to capture the Process and System metrics.
All observers are built with a callback but none of the returned
AutoCloseables
are captured for a clean shutdown at the end.https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/oshi/library/src/main/java/io/opentelemetry/instrumentation/oshi/ProcessMetrics.java#L23C3-L38C16
Describe the solution you'd like
I would like the
registerObserver
method to return a list of AutoCloseables instead of void. I am happy to send a PR if the proposed change is okay.This will then allow any calling classes to manage the cleanup.
Java runtime metrics utilizes this proposed approach.
Describe alternatives you've considered
I can create a custom implementation in my code and re-implement this but I would prefer to use this standard library instead. I am happy to send a PR if the proposed change is okay.
Additional context
No response
The text was updated successfully, but these errors were encountered: