6

Together with our SpringBoot (3.0.3) application we are using Application Insights (Azure) for monitoring.

Currently we are trying to compile the application natively with the GraalVM. That works quite well and gives us a lot of benefits (startup time and memory consumption). The only thing that does not yet work is Application Insights which is started as a Java agent. I found almost no useful information about the whole topic and asked myself if we are trying to do something that is currently not supported at all.

Here's what we've tried so far:

Is there a solution to add javaagents also in native compiled builds, or are there any alternatives to send monitoring data from a SpringBoot application to ApplicationInsights?

  • Maybe https://github.com/oracle/graal/issues/5912 helps to shed a bit of light on the situation. _Disclaimer: I am not a GraalVM user and found this question due to the 'javaagents' tag only._ – kriegaex Mar 13 '23 at 13:52

1 Answers1

1

I couldn't find anything in the GraalVM documentation for native images that talks about attaching runtime agents to native apps. This suggests that it is not supported.

I then searched for "application insights graalvm native image" and found this on the Application Insights issue tracker:

https://github.com/microsoft/ApplicationInsights-Java/issues/1266

We are currently using a custom implementation of the OpenTracing SPI to send our tracing data to Application Insights (the implementation is based on the Application Insights SDK 2.6.1) from a Quarkus application. Our plan is to move to OpenTelemetry as soon as it is supported by Quarkus.

Since Quarkus also supports native image generation (using GraalVM) auto-instrumentation using a Java agent won't be possible and a "deep integration" with Quarkus will be required. I would like to know if use cases like this one are on the radar and if builds (i.e. Maven artifacts) will be provided, which cater for this use case. I imagine there would be a build which provides an exporter only.

The highlighted phrase aligns with what I deduced from the (lack of) documentation. And it is further confirmed by the response to this GraalVM issue: https://github.com/oracle/graal/issues/5912

You said:

Use the OpenTelemetry library [...]. For me it still seems to use a kind of a javaagent jar to work properly.

The alternative would be to include the OpenTelemetry JAR in your SpringBoot application and enable it programatically rather than via a javaagent. It would be converted to native code by the GraalVM native image builder.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thanks a lot for your answer Stephen. Unfortunately, it is using the same mechanism to "enable it programatically". I uses ByteBuddy to attach a JAR (even if stated "programmatically") to the JVM (which is obviously not present) `ByteBuddyAgent.attach(javaagentFile, getPid());` – Rolf Nyffenegger Mar 13 '23 at 13:12
  • @RolfNyffenegger did you solve the issue with graalVM and opentelemetry-javaagent. i am able to run from locally but i coulnt' able to generate native image. i am getting errors like below [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.1.1:process-aot (process-aot) on project MongoDbService: Unable to compile generated source [ERROR] cannot find symbol [ERROR]: class OpenTelemetryMeterRegistryAutoConfiguration io.opentelemetry.javaagent.instrumentation.spring.actuator.v2_0.OpenTelemetryMeterRegistryAutoConfiguration__BeanDefinitions – Manikanta Reddy Pasala Jul 15 '23 at 08:01