Interface AgentListener

  • All Superinterfaces:
    Ordered

    public interface AgentListener
    extends Ordered
    AgentListener can be used to execute code before/after Java agent installation, for example to install any implementation providers that are used by instrumentations. For instance, this project uses this SPI to install OpenTelemetry SDK.

    This is a service provider interface that requires implementations to be registered in a provider-configuration file stored in the META-INF/services resource directory.

    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void afterAgent​(io.opentelemetry.instrumentation.api.config.Config config)
      Runs after instrumentations are added to AgentBuilder and after the agent is installed on an Instrumentation.
      default void beforeAgent​(io.opentelemetry.instrumentation.api.config.Config config)
      Runs before the AgentBuilder construction, before any instrumentation is added.
      • Methods inherited from interface io.opentelemetry.javaagent.extension.Ordered

        order
    • Method Detail

      • beforeAgent

        default void beforeAgent​(io.opentelemetry.instrumentation.api.config.Config config)
        Runs before the AgentBuilder construction, before any instrumentation is added.

        Execute only a minimal code because any classes loaded before the agent installation will have to be retransformed, which takes extra time, and more importantly means that fields can't be added to those classes - which causes InstrumentationContext to fall back to the less performant Map implementation for those classes.

      • afterAgent

        default void afterAgent​(io.opentelemetry.instrumentation.api.config.Config config)
        Runs after instrumentations are added to AgentBuilder and after the agent is installed on an Instrumentation.