Interface LifecycleListener
-
- All Known Implementing Classes:
AbstractLifecycleListener,ApmServerConfigurationSource,CGroupMetrics,CircuitBreaker,ClosableLifecycleListenerAdapter,JvmGcMetrics,JvmMemoryMetrics,MatcherTimerLifecycleListener,MetricRegistryReporter,StartupInfo,SystemMetrics,ThreadMetrics,WeakMapCleaner
public interface LifecycleListenerALifecycleListenernotifies about the start and stop event of theElasticApmTracer.Implement this interface and register it as a service under
src/main/resources/META-INF/services/co.elastic.apm.agent.context.LifecycleListener.Implementations may have a constructor with an
ElasticApmTracerargument
-
-
Method Summary
All Methods Instance Methods Abstract 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
void init(ElasticApmTracer tracer) throws java.lang.Exception
Callback for tracer initialization. As opposed tostart(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.- Parameters:
tracer- the tracer- Throws:
java.lang.Exception
-
start
void start(ElasticApmTracer tracer) throws java.lang.Exception
Callback for when theElasticApmTracerstarts.- Parameters:
tracer- The tracer.- Throws:
java.lang.Exception
-
pause
void pause() throws java.lang.ExceptionCallback 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.
- Throws:
java.lang.Exception- When something goes wrong performing the cleanup.
-
resume
void resume() throws java.lang.ExceptionCallback for whenElasticApmTracer.resume()has been called.Typically, used in order to revert the actions taken by the
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.
- Throws:
java.lang.Exception- When something goes wrong while attempting to resume.
-
stop
void stop() throws java.lang.Exception
Callback 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
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.
- Throws:
java.lang.Exception- When something goes wrong performing the cleanup.
-
The
-
-