在本机编译时,system_cpu_usage 为 Nan

发布于 2025-01-20 15:58:19 字数 423 浏览 2 评论 0 原文

在我的 quarkus 应用程序中,我使用千分尺来检索指标(如本指南中所示: https://quarkus.io/指南/千分尺)。 在 JVM 模式下一切正常,但在本机模式下 system_cpu_usage 为“Nan”。 我尝试将千分尺提高到 1.8.4 并添加 :

{
  "name":"com.sun.management.OperatingSystemMXBean", "allPublicMethods": true
},

到我的 Reflect-config.json 但没有成功。我还尝试使用 graalvm 跟踪代理生成 Reflect-config (和其他本机配置文件),但仍然没有成功。

In my quarkus application i'm using micrometer to retrieve metrics (like in this guide : https://quarkus.io/guides/micrometer).
In JVM mode everything works fine, but in native mode system_cpu_usage is "Nan".
I tried bumping micrometer to 1.8.4 and adding :

{
  "name":"com.sun.management.OperatingSystemMXBean", "allPublicMethods": true
},

to my reflect-config.json but no luck. I also tried generating the reflect-config (and other native configuration files) with the graalvm tracing agent but still no luck.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

永不分离 2025-01-27 15:58:19

这可能是一个错误。

Micrometer is looking for a few known implementations of the MXBean:

https://github.com/micrometer-metrics/micrometer/blob/b087856355667abf9bf2386265edef8642e0e077/micrometer-core/src/main/java/io/千分尺/核心/仪器/活页夹/系统/processormetrics.java#l55

    private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
        "com.ibm.lang.management.OperatingSystemMXBean", // J9
        "com.sun.management.OperatingSystemMXBean" // HotSpot
    );

以便可以找到应该调用的方法...

https://github.com/千分尺度/微米/blob/b087856355667abf9bf2386265Edef8642E0E077/mictotor-core/src/src/main/java/java/io/core/core/core/core/core/core/corem/instrument/instrument/instem/binder/binder/binder/binder/binder/processormetics.java #java#l80#l80 </

        this.operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
        this.operatingSystemBeanClass = getFirstClassFound(OPERATING_SYSTEM_BEAN_CLASS_NAMES);
        Method getCpuLoad = detectMethod("getCpuLoad");
        this.systemCpuUsage = getCpuLoad != null ? getCpuLoad : detectMethod("getSystemCpuLoad");
        this.processCpuUsage = detectMethod("getProcessCpuLoad");

getfir”受到第一个列表的约束)。

我的猜测,但我怀疑Graal正在返回另一种类型,这是从这里开始的:
https://github.com/oracle/graal/blob/6ba65dad76a4f54f54f59e1ed2a62a62dedddddddddddd3afe​​39928/ Management/Managementsupport.java#l166

需要一些挖掘才能知道哪个,但是我将对千分尺打开一个问题,以便我们可以对其进行整理。

This may be a bug.

Micrometer is looking for a few known implementations of the MXBean:

https://github.com/micrometer-metrics/micrometer/blob/b087856355667abf9bf2386265edef8642e0e077/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/system/ProcessorMetrics.java#L55

    private static final List<String> OPERATING_SYSTEM_BEAN_CLASS_NAMES = Arrays.asList(
        "com.ibm.lang.management.OperatingSystemMXBean", // J9
        "com.sun.management.OperatingSystemMXBean" // HotSpot
    );

so that it can find the methods that it should be invoking...

https://github.com/micrometer-metrics/micrometer/blob/b087856355667abf9bf2386265edef8642e0e077/micrometer-core/src/main/java/io/micrometer/core/instrument/binder/system/ProcessorMetrics.java#L80

        this.operatingSystemBean = ManagementFactory.getOperatingSystemMXBean();
        this.operatingSystemBeanClass = getFirstClassFound(OPERATING_SYSTEM_BEAN_CLASS_NAMES);
        Method getCpuLoad = detectMethod("getCpuLoad");
        this.systemCpuUsage = getCpuLoad != null ? getCpuLoad : detectMethod("getSystemCpuLoad");
        this.processCpuUsage = detectMethod("getProcessCpuLoad");

(Note specifically "getFirstClassFound", which is constrained against the first list).

Speculation on my part, but I suspect Graal is returning a different type, which is possible from here:
https://github.com/oracle/graal/blob/6ba65dad76a4f54fa59e1ed2a62dedd3afe39928/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementSupport.java#L166

would take some digging to know which, but I would open an issue with Micrometer so we can sort it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文