Interface AgentListener
-
- All Superinterfaces:
Ordered
public interface AgentListener extends Ordered
AgentListenercan 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/servicesresource directory.
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default voidafterAgent(io.opentelemetry.instrumentation.api.config.Config config)Runs after instrumentations are added toAgentBuilderand after the agent is installed on anInstrumentation.default voidbeforeAgent(io.opentelemetry.instrumentation.api.config.Config config)Runs before theAgentBuilderconstruction, before any instrumentation is added.
-
-
-
Method Detail
-
beforeAgent
default void beforeAgent(io.opentelemetry.instrumentation.api.config.Config config)
Runs before theAgentBuilderconstruction, 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
VirtualFieldto fall back to the less performantCacheimplementation for those classes.
-
afterAgent
default void afterAgent(io.opentelemetry.instrumentation.api.config.Config config)
Runs after instrumentations are added toAgentBuilderand after the agent is installed on anInstrumentation.
-
-