graal icon indicating copy to clipboard operation
graal copied to clipboard

[Native Image] jvm_gc_* and jvm_buffer_* metrics missing

Open patpatpat123 opened this issue 1 year ago • 9 comments

Describe the Issue

For a springboot 3.4 ( latest as of this writing) and GraalVM JDK23, project, there are missing metrics.

For background, the same app https://github.com/patpatpat123/nativejvmmetricsissueminimal running in "normal" (not native) will have the jvm_gc_* and jvm_buffer_* metrics

The exact same app, running as native image, will not have the metrics, which is the issue.

Not having GC, buffer etc metrics greatly impact the observability of the native image app.

Thank you for looking into this.

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

java 23 2024-09-17 Java(TM) SE Runtime Environment Oracle GraalVM 23+37.1 (build 23+37-jvmci-b01) Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 23+37.1 (build 23+37-jvmci-b01, mixed mode, sharing)

Operating System and Version

Mac os

Diagnostic Flag Confirmation

  • [ ] I tried the -H:ThrowMissingRegistrationErrors= flag.

Run Command

mvn -Pnative spring-boot:build-image

docker run docker.io/library/sre-demo:0.0.1-SNAPSHOT

Expected Behavior

to see jvm_gc_* and jvm_buffer_* in both non native and native image

Actual Behavior

jvm_gc_* and jvm_buffer_* are present only in non native run, but absent when running native image.

Steps to Reproduce

mvn -Pnative spring-boot:build-image

docker run docker.io/library/sre-demo:0.0.1-SNAPSHOT

Additional Context

https://github.com/patpatpat123/nativejvmmetricsissueminimal

Run-Time Log Output and Error Messages

No response

patpatpat123 avatar Oct 17 '24 20:10 patpatpat123

reading jvm events with native image is not a straightforward process and requires some tweaking, there are a few example using OpenTelemetry with GraalVM native image that you can find online, also it would make sense to check with Spring Boot on what they support and with which GraalVM version

oubidar-Abderrahim avatar Oct 21 '24 14:10 oubidar-Abderrahim

@patpatpat123 Wouldn't JFR be an option for you?

Karm avatar Oct 21 '24 15:10 Karm

@patpatpat123 I'm not sure if this will work for you use-case, but I think micrometer uses GC Notifications for gc related metrics. There's a PR up for adding notification support, which might solve your problem: https://github.com/oracle/graal/pull/9799

Otherwise, like Karm said, I think JFR could help you too.

roberttoyonaga avatar Oct 21 '24 16:10 roberttoyonaga

Hello @oubidar-Abderrahim ,

Your comment is not very clear, and it seems you are trying to offload a graalvm issue to other teams. Furthermore, the closing of this issue seems inappropriate as well.

After some investigation, it seems this issue is indeed related to graalvm https://github.com/oracle/graal/issues/8237 Please feel free to close this as duplicate, but the issue is clear and accepted.

Furthermore, I do not think this issue should be closed, as https://github.com/oracle/graal/issues/8237 only addresses part of the issue. For the buffer metrics, SubstrateVM needs to provide an implementation of BufferPoolMXBean which I believe it currently doesn't. I didn't find any issue in their issue tracker requesting it

Would you like me to open an issue reflecting this as well? Thank you

patpatpat123 avatar Oct 22 '24 03:10 patpatpat123

Hi @patpatpat123

Furthermore, I do not think this issue should be closed, as https://github.com/oracle/graal/issues/8237 only addresses part of the issue. For the buffer metrics, SubstrateVM needs to provide an implementation of BufferPoolMXBean which I believe it currently doesn't. I didn't find any issue in their issue tracker requesting it Would you like me to open an issue reflecting this as well?

Hmm I don't think it's necessary to open another separate issue. Maybe just mention briefly in the description that https://github.com/oracle/graal/issues/8237 already covers the GC metrics, but you're still concerned about the buffer metrics.

roberttoyonaga avatar Oct 23 '24 13:10 roberttoyonaga

Hi @oubidar-Abderrahim, I see that you've assigned me to this issue. I probably won't end up working on this for a while and don't want to give the impression that this is actively being worked on, in case someone else wants to give it a shot.

However, if no one at Oracle plans on taking this issue, feel free to keep me assigned in the meantime.

roberttoyonaga avatar Oct 23 '24 13:10 roberttoyonaga

@patpatpat123 @roberttoyonaga Spring boot uses micrometer which in turn uses GC notifications to add these metrics, so work on #8237 should fix the problem, I fixed a test with micrometer at the time I opened the problem and the metrics are now displayed in the latest build available.

viniciusxyz avatar Dec 02 '24 12:12 viniciusxyz

Hello @viniciusxyz @patpatpat123 ,

I am using springboot 3 and micrometer with graalvm24.

I am not using JFR.

I am seeing those metrics are still missing.

Can this be implemented?

ryleighmikami avatar May 06 '25 02:05 ryleighmikami

Hi @ryleighmikami, we're still waiting on https://github.com/oracle/graal/pull/9799 to be integrated (which handles the GC metrics side of things). As far as I know, no work has been started on implementing jvm_buffer_* metrics.

roberttoyonaga avatar May 06 '25 13:05 roberttoyonaga