Interface Scope

  • All Superinterfaces:
    java.lang.AutoCloseable
    All Known Implementing Classes:
    Scope.NoopScope

    public interface Scope
    extends java.lang.AutoCloseable
    Within a scope, a AbstractSpan is active on the current thread. Calling close() detaches them from the active thread. In a scope, you can get the currently active AbstractSpan via ElasticApmTracer.getActive().

    During the duration of a AbstractSpan, it can be active multiple times on multiple threads. In applications with a single thread per request model, there is typically one scope which lasts for the lifetime of the AbstractSpan. In reactive applications, this model does not work, as a request is handled in multiple threads. These types of application still might find it useful to scope a AbstractSpan on the currently processing thread. For example, an instrumentation for ExecutorService might want to propagate the currently active AbstractSpan to thread which runs Executor.execute(Runnable), so that ElasticApmTracer.getActive() returns the expected AbstractSpan.

    Note: closing a scope does not end it's active AbstractSpan.

    • Method Detail

      • close

        void close()
        Specified by:
        close in interface java.lang.AutoCloseable