From milan.mimica at gmail.com Thu Jul 23 12:25:44 2020 From: milan.mimica at gmail.com (Milan Mimica) Date: Thu, 23 Jul 2020 14:25:44 +0200 Subject: jmx-dev MBean attribute deprecation Message-ID: Hello list With deprecation of OperatingSystem#SystemCpuLoad in favor of OperatingSystem#CpuLoad [1] an issue raised with generic tools that query all MBean attributes. Querying CPU usage is not side-effect-free: the immediate subsequent query for CPU load will often return a skewed value (on Linux at least, haven't checked others)[2]. This results in exported data where either new or deprecated MBean value is wrong and misleading. There are many tools and libraries that generically export JMX metrics, so I think this should be addressed somehow. Maybe we could add a property in MBeanAttributeInfo which would mark the attribute as deprecated? These tools could then skip such metrics. [1] https://docs.oracle.com/en/java/javase/14/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getSystemCpuLoad() [2] https://medium.com/@milan.mimica/the-java-cpu-usage-observer-effect-18808b18323f -- Milan Mimica -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.fuchs at oracle.com Thu Jul 23 13:36:06 2020 From: daniel.fuchs at oracle.com (Daniel Fuchs) Date: Thu, 23 Jul 2020 14:36:06 +0100 Subject: jmx-dev MBean attribute deprecation In-Reply-To: References: Message-ID: <3197874e-e2be-891a-74c3-efc2013ad04c@oracle.com> Hi Milan, JMX is being maintained by serviceability these days. I am forwarding your question there. This is an interesting observation. JMX makes it possible to define and use annotations on methods/getters/setters, to add key/value pairs to the Descriptor of the corresponding MBeanFeatureInfo. The mechanism should probably be extended so that the standard @Deprecated annotation is also reflected in the Descriptor. best regards, -- daniel On 23/07/2020 13:25, Milan Mimica wrote: > Hello list > > With deprecation of OperatingSystem#SystemCpuLoad in favor of > OperatingSystem#CpuLoad [1] an issue raised with generic tools that > query all MBean attributes. Querying CPU usage is not side-effect-free: > the immediate subsequent query for CPU load will often return a skewed > value (on Linux at least, haven't checked others)[2]. This results in > exported data where either new or deprecated MBean value is wrong and > misleading. > > There are many tools and libraries that generically export JMX metrics, > so I think this should be addressed somehow. Maybe we could add a > property in MBeanAttributeInfo which would mark the attribute as > deprecated? These tools could then skip such metrics. > > > [1] > https://docs.oracle.com/en/java/javase/14/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getSystemCpuLoad() > [2] > https://medium.com/@milan.mimica/the-java-cpu-usage-observer-effect-18808b18323f > > -- > Milan Mimica >