Class AbstractLifecycleListener
- java.lang.Object
-
- co.elastic.apm.agent.context.AbstractLifecycleListener
-
- All Implemented Interfaces:
LifecycleListener
- Direct Known Subclasses:
CGroupMetrics,CircuitBreaker,ClosableLifecycleListenerAdapter,JvmGcMetrics,JvmMemoryMetrics,MatcherTimerLifecycleListener,MetricRegistryReporter,StartupInfo,SystemMetrics,ThreadMetrics,WeakMapCleaner
public abstract class AbstractLifecycleListener extends java.lang.Object implements LifecycleListener
-
-
Constructor Summary
Constructors Constructor Description AbstractLifecycleListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidinit(ElasticApmTracer tracer)Callback for tracer initialization.voidpause()Callback for whenElasticApmTracer.pause()has been called.voidresume()Callback for whenElasticApmTracer.resume()has been called.voidstart(ElasticApmTracer tracer)Callback for when theElasticApmTracerstarts.voidstop()Callback for whenElasticApmTracer.stop()has been called.
-
-
-
Method Detail
-
init
public void init(ElasticApmTracer tracer) throws java.lang.Exception
Description copied from interface:LifecycleListenerCallback for tracer initialization. As opposed toLifecycleListener.start(ElasticApmTracer), which may be called in a delay, this callback is called at the bootstrap of the JVM, before anything else start. This may be useful for listeners that need to operate very early on, for example such that setup class loading requirement to support OSGi systems.- Specified by:
initin interfaceLifecycleListener- Parameters:
tracer- the tracer- Throws:
java.lang.Exception
-
start
public void start(ElasticApmTracer tracer) throws java.lang.Exception
Description copied from interface:LifecycleListenerCallback for when theElasticApmTracerstarts.- Specified by:
startin interfaceLifecycleListener- Parameters:
tracer- The tracer.- Throws:
java.lang.Exception
-
pause
public void pause() throws java.lang.ExceptionDescription copied from interface:LifecycleListenerCallback for whenElasticApmTracer.pause()has been called.Typically, this method is used to reduce overhead on the application to a minimum. This can be done by cleaning up resources like object pools, as well as by avoiding tracing-related overhead.
Exceptions thrown from this method are caught and handled so that they don't prevent further cleanup actions.
- Specified by:
pausein interfaceLifecycleListener- Throws:
java.lang.Exception- When something goes wrong performing the cleanup.
-
resume
public void resume() throws java.lang.ExceptionDescription copied from interface:LifecycleListenerCallback for whenElasticApmTracer.resume()has been called.Typically, used in order to revert the actions taken by the
LifecycleListener.pause()method, allowing the agent to restore all tracing capabilitiesExceptions thrown from this method are caught and handled so that they don't prevent further resume actions.
- Specified by:
resumein interfaceLifecycleListener- Throws:
java.lang.Exception- When something goes wrong while attempting to resume.
-
stop
public void stop() throws java.lang.ExceptionDescription copied from interface:LifecycleListenerCallback for whenElasticApmTracer.stop()has been called.Typically, this method is used to clean up resources like thread pools so that there are no class loader leaks when a webapp is redeployed in an application server.
Exceptions thrown from this method are caught and handled so that they don't prevent further cleanup actions.
The order of the shutdown process is as follows:
-
The
LifecycleListener.stop()method of all lifecycle listeners is called. The order in which lifecycle listeners are called is non-deterministic. -
The
ElasticApmTracer.getSharedSingleThreadedPool()is shut down gracefully, waiting a moment for the already scheduled tasks to be completed. This means that implementations of this method can schedule a last command to this pool that is executed before shutdown. TheTracer.getState()will still beTracer.TracerState.RUNNINGin the tasks scheduled toElasticApmTracer.getSharedSingleThreadedPool()within this method. -
The tracer state is set to
Tracer.TracerState.STOPPED. -
The
Reporteris closed.
- Specified by:
stopin interfaceLifecycleListener- Throws:
java.lang.Exception- When something goes wrong performing the cleanup.
-
The
-
-