Interface LifecycleListener

    • Method Detail

      • init

        void init​(ElasticApmTracer tracer)
           throws java.lang.Exception
        Callback for tracer initialization. As opposed to 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.
        Parameters:
        tracer - the tracer
        Throws:
        java.lang.Exception
      • start

        void start​(ElasticApmTracer tracer)
            throws java.lang.Exception
        Callback for when the ElasticApmTracer starts.
        Parameters:
        tracer - The tracer.
        Throws:
        java.lang.Exception
      • pause

        void pause()
            throws java.lang.Exception
        Callback for when ElasticApmTracer.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.Exception
        Callback for when ElasticApmTracer.resume() has been called.

        Typically, used in order to revert the actions taken by the pause() method, allowing the agent to restore all tracing capabilities

        Exceptions 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 when ElasticApmTracer.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:

        1. The stop() method of all lifecycle listeners is called. The order in which lifecycle listeners are called is non-deterministic.
        2. 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. The Tracer.getState() will still be Tracer.TracerState.RUNNING in the tasks scheduled to ElasticApmTracer.getSharedSingleThreadedPool() within this method.
        3. The tracer state is set to Tracer.TracerState.STOPPED.
        4. The Reporter is closed.
        Throws:
        java.lang.Exception - When something goes wrong performing the cleanup.