opentelemetry-java-contrib/runtime-attach
Trask Stalnaker da6dd00ea1
Update SDK to 1.17.0 (#420)
* Update SDK to 1.17.0

* Fix
2022-08-19 10:42:42 -07:00
..
runtime-attach Update SDK to 1.17.0 (#420) 2022-08-19 10:42:42 -07:00
runtime-attach-core Prevent the runtime attachment from launching multiple times (#409) 2022-07-26 07:18:23 +02:00
README.md Improve exception handling and documentation of runtime attachment (#388) 2022-07-12 09:13:25 -07:00

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.enabled property is set to false
  • The OTEL_JAVAAGENT_ENABLED environment variable is set to false
  • 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

Learn more about component owners in component_owners.yml.