Class OpenTelemetryAgent

java.lang.Object
io.opentelemetry.javaagent.OpenTelemetryAgent

public final class OpenTelemetryAgent extends Object
Premain-Class for the OpenTelemetry Java agent.

The bootstrap process of the agent is somewhat complicated and care has to be taken to make sure things do not get broken by accident.

JVM loads this class onto app's class loader, afterwards agent needs to inject its classes onto bootstrap classpath. This leads to this class being visible on bootstrap. This in turn means that this class may be loaded again on bootstrap by accident if we ever reference it after bootstrap has been setup.

In order to avoid this we need to make sure we do a few things:

  • Do as little as possible here
  • Never reference this class after we have setup bootstrap and jumped over to 'real' agent code
  • Do not store any static data in this class
  • Do dot touch any logging facilities here so we can configure them later
  • Method Details

    • premain

      public static void premain(String agentArgs, Instrumentation inst)
    • agentmain

      public static void agentmain(String agentArgs, Instrumentation inst)
    • main

      public static void main(String... args)
      Main entry point.
      Parameters:
      args - command line arguments