Class GlobalTracer

  • All Implemented Interfaces:
    Tracer

    public class GlobalTracer
    extends java.lang.Object
    implements Tracer
    • Method Detail

      • get

        public static Tracer get()
      • setNoop

        public static void setNoop()
      • init

        public static void init​(Tracer tracer)
      • isNoop

        public static boolean isNoop()
      • startRootTransaction

        @Nullable
        public Transaction startRootTransaction​(@Nullable
                                                java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a trace-root transaction
        Specified by:
        startRootTransaction in interface Tracer
        Parameters:
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.
        Returns:
        a transaction that will be the root of the current trace if the agent is currently RUNNING; null otherwise
      • startRootTransaction

        @Nullable
        public Transaction startRootTransaction​(@Nullable
                                                java.lang.ClassLoader initiatingClassLoader,
                                                long epochMicro)
        Specified by:
        startRootTransaction in interface Tracer
      • startRootTransaction

        @Nullable
        public Transaction startRootTransaction​(Sampler sampler,
                                                long epochMicros,
                                                @Nullable
                                                java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a trace-root transaction with a specified sampler and start timestamp
        Specified by:
        startRootTransaction in interface Tracer
        Parameters:
        sampler - the Sampler instance which is responsible for determining the sampling decision if this is a root transaction
        epochMicros - the start timestamp
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like the MDC, for log correlation.
        Returns:
        a transaction that will be the root of the current trace if the agent is currently RUNNING; null otherwise
      • startChildTransaction

        @Nullable
        public <C> Transaction startChildTransaction​(@Nullable
                                                     C headerCarrier,
                                                     TextHeaderGetter<C> textHeadersGetter,
                                                     @Nullable
                                                     java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a transaction as a child of the context headers obtained through the provided HeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.
        Specified by:
        startChildTransaction in interface Tracer
        Parameters:
        headerCarrier - the Object from which context headers can be obtained, typically a request or a message
        textHeadersGetter - provides the trace context headers required in order to create a child transaction
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.
        Returns:
        a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
      • startChildTransaction

        @Nullable
        public <C> Transaction startChildTransaction​(@Nullable
                                                     C headerCarrier,
                                                     TextHeaderGetter<C> textHeadersGetter,
                                                     @Nullable
                                                     java.lang.ClassLoader initiatingClassLoader,
                                                     long epochMicros)
        Specified by:
        startChildTransaction in interface Tracer
      • startChildTransaction

        @Nullable
        public <C> Transaction startChildTransaction​(@Nullable
                                                     C headerCarrier,
                                                     TextHeaderGetter<C> textHeadersGetter,
                                                     Sampler sampler,
                                                     long epochMicros,
                                                     @Nullable
                                                     java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a transaction as a child of the context headers obtained through the provided HeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.
        Specified by:
        startChildTransaction in interface Tracer
        Parameters:
        headerCarrier - the Object from which context headers can be obtained, typically a request or a message
        textHeadersGetter - provides the trace context headers required in order to create a child transaction
        sampler - the Sampler instance which is responsible for determining the sampling decision if this is a root transaction
        epochMicros - the start timestamp
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like the MDC, for log correlation.
        Returns:
        a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
      • startChildTransaction

        @Nullable
        public <C> Transaction startChildTransaction​(@Nullable
                                                     C headerCarrier,
                                                     BinaryHeaderGetter<C> binaryHeadersGetter,
                                                     @Nullable
                                                     java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a transaction as a child of the context headers obtained through the provided HeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.
        Specified by:
        startChildTransaction in interface Tracer
        Parameters:
        headerCarrier - the Object from which context headers can be obtained, typically a request or a message
        binaryHeadersGetter - provides the trace context headers required in order to create a child transaction
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name.
        Returns:
        a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
      • startChildTransaction

        @Nullable
        public <C> Transaction startChildTransaction​(@Nullable
                                                     C headerCarrier,
                                                     BinaryHeaderGetter<C> binaryHeadersGetter,
                                                     Sampler sampler,
                                                     long epochMicros,
                                                     @Nullable
                                                     java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Starts a transaction as a child of the context headers obtained through the provided HeaderGetter. If the created transaction cannot be started as a child transaction (for example - if no parent context header is available), then it will be started as the root transaction of the trace.
        Specified by:
        startChildTransaction in interface Tracer
        Parameters:
        headerCarrier - the Object from which context headers can be obtained, typically a request or a message
        binaryHeadersGetter - provides the trace context headers required in order to create a child transaction
        sampler - the Sampler instance which is responsible for determining the sampling decision if this is a root transaction
        epochMicros - the start timestamp
        initiatingClassLoader - the class loader corresponding to the service which initiated the creation of the transaction. Used to determine the service name and to load application-scoped classes like the MDC, for log correlation.
        Returns:
        a transaction which is a child of the provided parent if the agent is currently RUNNING; null otherwise
      • captureAndReportException

        public void captureAndReportException​(@Nullable
                                              java.lang.Throwable e,
                                              java.lang.ClassLoader initiatingClassLoader)
        Description copied from interface: Tracer
        Captures an exception without providing an explicit reference to a parent AbstractSpan
        Specified by:
        captureAndReportException in interface Tracer
        Parameters:
        e - the exception to capture
        initiatingClassLoader - the class
      • captureAndReportException

        @Nullable
        public java.lang.String captureAndReportException​(long epochMicros,
                                                          @Nullable
                                                          java.lang.Throwable e,
                                                          @Nullable
                                                          AbstractSpan<?> parent)
        Specified by:
        captureAndReportException in interface Tracer
      • captureException

        @Nullable
        public ErrorCapture captureException​(@Nullable
                                             java.lang.Throwable e,
                                             @Nullable
                                             AbstractSpan<?> parent,
                                             @Nullable
                                             java.lang.ClassLoader initiatingClassLoader)
        Specified by:
        captureException in interface Tracer
      • overrideServiceNameForClassLoader

        public void overrideServiceNameForClassLoader​(@Nullable
                                                      java.lang.ClassLoader classLoader,
                                                      @Nullable
                                                      java.lang.String serviceName)
        Description copied from interface: Tracer
        Overrides the service name for all Transactions, Spans and ErrorCaptures which are created by the service which corresponds to the provided ClassLoader.

        The main use case is being able to differentiate between multiple services deployed to the same application server.

        Specified by:
        overrideServiceNameForClassLoader in interface Tracer
        Parameters:
        classLoader - the class loader which corresponds to a particular service
        serviceName - the service name for this class loader
      • stop

        public void stop()
        Description copied from interface: Tracer
        Called when the container shuts down. Cleans up thread pools and other resources.
        Specified by:
        stop in interface Tracer
      • isRunning

        public boolean isRunning()
        Specified by:
        isRunning in interface Tracer