-
Notifications
You must be signed in to change notification settings - Fork 266
Add GraalVM native image demo for agent support #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
steverao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, I suggest that use graalvm-demo to replace the graalvm-native-image-demo and create a directory named ot-demo under graalvm-demo. then, replace spring-boot-ot by spring-boot. In this way, it looks like more clearly and we can add other frameworks demo easily.
| This project adds GraalVM native image support for [OpenTelemetry-java-instrumentation](https://github.com/open-telemetry/opentelemetry-java-instrumentation). It serves as an input for native image building of OT agent-enabled applications. | ||
|
|
||
| There are two things that the GraalVM [agent support PR](https://github.com/oracle/graal/pull/8077) can't automatically handle when supporting the agent instrumentation in native image: | ||
| 1. The actions in agent `premain`. Java agent usually initializes the context and registers the class transformations in the premain phase. Native image needs the `premain` to do part of such works, e.g. initializations to activate the agent at runtime is necessary, but the actual bytecode transformations should be excluded. In this project, we provide a native version of OT agent premain via GraalVM's substitution mechanism. See src/main/java/com/alibaba/jvm/Target_io_opentelemetry_javaagent_OpenTelemetryAgent.java for details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 1. The actions in agent `premain`. Java agent usually initializes the context and registers the class transformations in the premain phase. Native image needs the `premain` to do part of such works, e.g. initializations to activate the agent at runtime is necessary, but the actual bytecode transformations should be excluded. In this project, we provide a native version of OT agent premain via GraalVM's substitution mechanism. See src/main/java/com/alibaba/jvm/Target_io_opentelemetry_javaagent_OpenTelemetryAgent.java for details. | |
| 1. The actions in agent `premain`. Java agent usually initializes the context and registers the class transformations in the premain phase. Native image needs the `premain` to do part of such works, e.g. initializations to activate the agent at runtime is necessary, but the actual bytecode transformations should be excluded. In this project, we provide a native version of OT agent premain via GraalVM's substitution mechanism. See `src/main/java/com/alibaba/jvm/Target_io_opentelemetry_javaagent_OpenTelemetryAgent.java` for details. |
| ### Steps | ||
| 1. cd to the root of this project | ||
| 2. `mvn package`: Build the jar package of this project | ||
| 3. `./run.sh --jvm --collect --log`: Execute the project in JVM mode, enabling OpenTelemetry agent to log monitoring data. Meanwhile, native-image-agent is enbeled to collect transformation classes and other dynamic data. When this step ends, data is dumped to `native-configs` directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 3. `./run.sh --jvm --collect --log`: Execute the project in JVM mode, enabling OpenTelemetry agent to log monitoring data. Meanwhile, native-image-agent is enbeled to collect transformation classes and other dynamic data. When this step ends, data is dumped to `native-configs` directory. | |
| 3. `./run.sh --jvm --collect --log`: Execute the project in JVM mode, enabling OpenTelemetry agent to log monitoring data. Meanwhile, native-image-agent is enabled to collect transformation classes and other dynamic data. When this step ends, data is dumped to `native-configs` directory. |
| @@ -0,0 +1,81 @@ | |||
| #!/bin/bash | |||
| JAVA="$HOME/tools/GRAALVM21" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line is correct? If users set export GRAALVM_HOME=/root/graalvm-test/graalvm-17-23.0.2-ali-1.1-instru according to README.md, it seems they can't locate to relevant directory.
|
Graalvm-demo is not accurate. Because Graalvm could be Graalvm JIT or Graalvm native image. Graalvm-native-image is more accurate. |
No description provided.