Class Tracing

  • All Implemented Interfaces:
    ExecutorLocal<TraceState>

    public abstract class Tracing
    extends java.lang.Object
    implements ExecutorLocal<TraceState>
    A trace session context. Able to track and store trace sessions. A session is usually a user initiated query, and may have multiple local and remote events before it is completed.
    • Field Detail

      • logger

        protected static final org.slf4j.Logger logger
      • sessions

        protected final java.util.concurrent.ConcurrentMap<java.util.UUID,​TraceState> sessions
      • instance

        public static final Tracing instance
    • Constructor Detail

      • Tracing

        public Tracing()
    • Method Detail

      • getSessionId

        public java.util.UUID getSessionId()
      • getTTL

        public int getTTL()
      • isTracing

        public static boolean isTracing()
        Indicates if the current thread's execution is being traced.
      • newSession

        public java.util.UUID newSession​(java.util.Map<java.lang.String,​java.nio.ByteBuffer> customPayload)
      • newSession

        public java.util.UUID newSession​(java.util.UUID sessionId,
                                         java.util.Map<java.lang.String,​java.nio.ByteBuffer> customPayload)
      • newSession

        protected java.util.UUID newSession​(java.util.UUID sessionId,
                                            Tracing.TraceType traceType,
                                            java.util.Map<java.lang.String,​java.nio.ByteBuffer> customPayload)
        This method is intended to be overridden in tracing implementations that need access to the customPayload
      • doneWithNonLocalSession

        public void doneWithNonLocalSession​(TraceState state)
      • stopSession

        public void stopSession()
        Stop the session and record its complete. Called by coodinator when request is complete.
      • stopSessionImpl

        protected abstract void stopSessionImpl()
      • get

        public TraceState get()
        Description copied from interface: ExecutorLocal
        This is called when scheduling the task, and also before calling ExecutorLocal.set(Object) when running on a executor thread.
        Specified by:
        get in interface ExecutorLocal<TraceState>
        Returns:
        The thread-local value that we want to copy across executor boundaries; may be null if not set.
      • get

        public TraceState get​(java.util.UUID sessionId)
      • set

        public void set​(TraceState tls)
        Description copied from interface: ExecutorLocal
        Before a task has been run, this will be called with the value from the thread that scheduled the task, and after the task is finished, the value that was previously retrieved from this thread is restored.
        Specified by:
        set in interface ExecutorLocal<TraceState>
        Parameters:
        tls - Value to use for the executor local state; may be null.
      • begin

        public TraceState begin​(java.lang.String request,
                                java.util.Map<java.lang.String,​java.lang.String> parameters)
      • begin

        public abstract TraceState begin​(java.lang.String request,
                                         java.net.InetAddress client,
                                         java.util.Map<java.lang.String,​java.lang.String> parameters)
      • initializeFromMessage

        public TraceState initializeFromMessage​(Message.Header header)
        Determines the tracing context from a message. Does NOT set the threadlocal state.
        Parameters:
        header - The internode message header
      • traceOutgoingMessage

        public void traceOutgoingMessage​(Message<?> message,
                                         int serializedSize,
                                         InetAddressAndPort sendTo)
        Record any tracing data, if enabled on this message.
      • addTraceHeaders

        public java.util.Map<ParamType,​java.lang.Object> addTraceHeaders​(java.util.Map<ParamType,​java.lang.Object> addToMutable)
      • traceRepair

        public static void traceRepair​(java.lang.String format,
                                       java.lang.Object... args)
      • trace

        public static void trace​(java.lang.String message)
      • trace

        public static void trace​(java.lang.String format,
                                 java.lang.Object arg)
      • trace

        public static void trace​(java.lang.String format,
                                 java.lang.Object arg1,
                                 java.lang.Object arg2)
      • trace

        public static void trace​(java.lang.String format,
                                 java.lang.Object... args)
      • trace

        public abstract void trace​(java.nio.ByteBuffer sessionId,
                                   java.lang.String message,
                                   int ttl)
        Called for non-local traces (traces that are not initiated by local node == coordinator).