Tracing (apache-cassandra API)
Date: 2018-02-14

org.apache.cassandra.tracing

## Class Tracing

- java.lang.Object
- - org.apache.cassandra.tracing.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.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Tracing.TraceType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Tracing` | `instance`
    `protected static org.slf4j.Logger` | `logger`
    `protected java.util.concurrent.ConcurrentMap<java.util.UUID,TraceState>` | `sessions`
    `static java.lang.String` | `TRACE_HEADER`
    `static java.lang.String` | `TRACE_TYPE`

    - ### Fields inherited from interface org.apache.cassandra.concurrent.ExecutorLocal

      `all`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Tracing()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract TraceState` | `begin(java.lang.String request, java.net.InetAddress client, java.util.Map<java.lang.String,java.lang.String> parameters)`
    `TraceState` | `begin(java.lang.String request, java.util.Map<java.lang.String,java.lang.String> parameters)`
    `void` | `doneWithNonLocalSession(TraceState state)`
    `TraceState` | `get()` This is called when scheduling the task, and also before calling `ExecutorLocal.set(Object)` when running on a executor thread.
    `TraceState` | `get(java.util.UUID sessionId)`
    `java.util.UUID` | `getSessionId()`
    `java.util.Map<java.lang.String,byte[]>` | `getTraceHeaders()`
    `Tracing.TraceType` | `getTraceType()`
    `int` | `getTTL()`
    `TraceState` | `initializeFromMessage(MessageIn<?> message)` Determines the tracing context from a message.
    `static boolean` | `isTracing()` Indicates if the current thread's execution is being traced.
    `java.util.UUID` | `newSession(java.util.Map<java.lang.String,java.nio.ByteBuffer> customPayload)`
    `java.util.UUID` | `newSession(Tracing.TraceType traceType)`
    `java.util.UUID` | `newSession(java.util.UUID sessionId, java.util.Map<java.lang.String,java.nio.ByteBuffer> customPayload)`
    `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
    `protected abstract TraceState` | `newTraceState(java.net.InetAddress coordinator, java.util.UUID sessionId, Tracing.TraceType traceType)`
    `void` | `set(TraceState tls)` 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.
    `void` | `stopSession()` Stop the session and record its complete.
    `protected abstract void` | `stopSessionImpl()`
    `abstract void` | `trace(java.nio.ByteBuffer sessionId, java.lang.String message, int ttl)` Called from `OutboundTcpConnection` for non-local traces (traces that are not initiated by local node == coordinator).
    `static void` | `trace(java.lang.String message)`
    `static void` | `trace(java.lang.String format, java.lang.Object... args)`
    `static void` | `trace(java.lang.String format, java.lang.Object arg)`
    `static void` | `trace(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)`
    `static void` | `traceRepair(java.lang.String format, java.lang.Object... args)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### TRACE_HEADER

          public static final java.lang.String TRACE_HEADER

      See Also:
        Constant Field Values

    - #### TRACE_TYPE

          public static final java.lang.String TRACE_TYPE

      See Also:
        Constant Field Values

    - #### 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()

    - #### getTraceType

          public Tracing.TraceType getTraceType()

    - #### 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(Tracing.TraceType traceType)

    - #### 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(MessageIn<?> message)

      Determines the tracing context from a message. Does NOT set the threadlocal state.
      Parameters:
        `message` - The internode message

    - #### getTraceHeaders

          public java.util.Map<java.lang.String,byte[]> getTraceHeaders()

    - #### newTraceState

          protected abstract TraceState newTraceState(java.net.InetAddress coordinator,
                                                      java.util.UUID sessionId,
                                                      Tracing.TraceType traceType)

    - #### 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 from `OutboundTcpConnection` for non-local traces (traces that are not initiated by local node == coordinator).

Copyright © 2018 The Apache Software Foundation