Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Support direct access to com.sun.management.OperatingSystemMXBean#278

Closed
PaulSandoz wants to merge 1 commit intoprometheus:masterprometheus/client_java:masterfrom
PaulSandoz:masterPaulSandoz/client_java:masterCopy head branch name to clipboard
Closed

Support direct access to com.sun.management.OperatingSystemMXBean#278
PaulSandoz wants to merge 1 commit intoprometheus:masterprometheus/client_java:masterfrom
PaulSandoz:masterPaulSandoz/client_java:masterCopy head branch name to clipboard

Conversation

@PaulSandoz
Copy link

Obtaining the counter metric process_cpu_seconds_total fails on Java 9 because the setAccessible call throws an Exception. This is because the reflective method is obtained from the concrete implementing class rather than the interface. In Java 9 classes may be encapsulated within a module and not exported and therefore not accessible.

We can check that the OS bean is an instance of com.sun.management.OperatingSystemMXBean (as is already done for com.sun.management.UnixOperatingSystemMXBean, the latter inherits from the former).

For interface com.ibm.lang.management.OperatingSystemMXBean we still need to perform reflective access but we should operate on the method whose declaring class is that interface to ensure access (note i have not tested this since i don't have a distribution of the IBM JDK).

reflective access to com.ibm.lang.management.OperatingSystemMXBean.
@brian-brazil
Copy link
Contributor

This looks okay to me in principle.

@davidkarlsen Can you confirm this still works on IBM Java?

@davidkarlsen
Copy link
Contributor

A bit disconnected from the grid until the weekend - if it compiles with an IBM JDK 7/8 (or whatever lower-boundary for JDK version) it should be ok - but I suspect the class might not be present on an IBM JDK.

@brian-brazil
Copy link
Contributor

Superseded by #281

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.

3 participants

Comments

Close sidebar
Morty Proxy This is a proxified and sanitized view of the page, visit original site.