0

I have been exploring the native-image with one of my applications. In the current architecture of my application, it's an akka-grpc powered java app that publishes messages to Kafka. I have been using the apache-kafka library as a Kafka producer client. My application has a large memory footprint, so I've been exploring the native-image feature from GraalVM. With native image, my new application requires 1/8th of resources than the previous version - this a great win for me. But... I'm losing metrics.

I've been using cinnamon, a Lightbend's telemetry metrics tool which provides me observability for the grpc, the JMX provides me metrics for the GC and Dispatchers [i.e. number of loaded class, number of thread running, etc.] and I also get metrics for apache-kafka client (i.e. success and error rate for message publishing, message bytes size, latency, retries, apache-kafka queue size, etc.)

I cannot get any of the metrics with the new version of my application, i.e., with the native image. I reckon for JMX to work it requires JVM and Java bytecode which is no longer present in the native executable. I can sacrifice some of the metrics from JMX but is there a way I can get the Kafka and the grpc metrics?

Would anyone be kind enough to point me to some tools I can use to get the above metrics?

sphoenix
  • 3,327
  • 5
  • 22
  • 40
  • JMX has been supported since recently, see `--enable-monitoring=jfr` option. Number of loaded classes does not make sense for native images, but GC and some of thread events should be working – peterz Dec 09 '22 at 07:50
  • As for third party metrics, I think there's hope, unless they do bytecode rewriting. The first step is to figure out why they do not work out of the box. Maybe they use reflection or resources that need to be configured? Try to run your app with GraalVM agent enabled, and see if there's anything related in the config files it generates – peterz Dec 09 '22 at 07:54
  • The kafka metrics are also coming from the JMX [importer](https://developer.lightbend.com/docs/telemetry/current//extensions/jmximporter/predefined.html#apache-kafka-importers). – sphoenix Dec 09 '22 at 09:18
  • The `--enable-monitoring=jfr` is going to record the VM and the output will be a [binary file](https://www.graalvm.org/22.3/reference-manual/native-image/guides/build-and-run-native-executable-with-jfr/#:~:text=It%20runs%20the%20application%20as%20a%20native%20executable.%20The%20%2DXX%3A%2BFlightRecorder%20flag%20enables%20the%20built%2Din%20Flight%20Recorder%20and%20starts%20recording%20to%20a%20specified%20binary%20file%2C%20recording.jfr.). But in my set up I can't have the scope to keep the recording in a file because I can't take out the file. I'm running on Docker. – sphoenix Dec 09 '22 at 09:22
  • Ah, you need JFR streaming. It's not there yet, though they are [working on it](https://github.com/oracle/graal/issues/5079) – peterz Dec 09 '22 at 10:22

0 Answers0