* Update SDK to 1.17.0 * Fix |
||
|---|---|---|
| .. | ||
| runtime-attach | ||
| runtime-attach-core | ||
| README.md | ||
README.md
Runtime attachment
If you can't update the JVM arguments to attach the OpenTelemetry Java agent (-javaagent:path/to/opentelemetry-javaagent.jar), this project allows you to do attachment programmatically.
The io.opentelemetry.contrib.attach.RuntimeAttach class has an attachJavaagentToCurrentJVM method allowing to trigger the attachment of the OTel agent for Java.
The attachment will not be initiated in the following cases:
- The
otel.javaagent.enabledproperty is set tofalse - The
OTEL_JAVAAGENT_ENABLEDenvironment variable is set tofalse - The attachment is not requested from the main thread
- The attachment is not requested from the
public static void main(String[] args)method - The agent is already attached
- The application is running on a JRE (a JDK is necessary)
- The application is running on a read-only file system
The attachment must be requested at the beginning of the public static void main(String[] args) method. We give below an example for Spring Boot applications:
@SpringBootApplication
public class SpringBootApp {
public static void main(String[] args) {
RuntimeAttach.attachJavaagentToCurrentJVM();
SpringApplication.run(SpringBootApp.class, args);
}
}
Component owners
- Jean Bisutti, Microsoft
- Nikita Salnikov-Tarnovski, Splunk
Learn more about component owners in component_owners.yml.