Package 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 Description static class
Tracing.TraceType
-
Field Summary
Fields Modifier and Type Field Description static Tracing
instance
protected static org.slf4j.Logger
logger
protected java.util.concurrent.ConcurrentMap<java.util.UUID,TraceState>
sessions
static IVersionedSerializer<Tracing.TraceType>
traceTypeSerializer
-
Fields inherited from interface org.apache.cassandra.concurrent.ExecutorLocal
all
-
-
Constructor Summary
Constructors Constructor Description Tracing()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Map<ParamType,java.lang.Object>
addTraceHeaders(java.util.Map<ParamType,java.lang.Object> addToMutable)
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 callingExecutorLocal.set(Object)
when running on a executor thread.TraceState
get(java.util.UUID sessionId)
java.util.UUID
getSessionId()
Tracing.TraceType
getTraceType()
int
getTTL()
TraceState
initializeFromMessage(Message.Header header)
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(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 customPayloadjava.util.UUID
newSession(Tracing.TraceType traceType)
protected abstract TraceState
newTraceState(InetAddressAndPort 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()
static void
trace(java.lang.String message)
static void
trace(java.lang.String format, java.lang.Object arg)
static void
trace(java.lang.String format, java.lang.Object... args)
static void
trace(java.lang.String format, java.lang.Object arg1, java.lang.Object arg2)
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).void
traceOutgoingMessage(Message<?> message, int serializedSize, InetAddressAndPort sendTo)
Record any tracing data, if enabled on this message.static void
traceRepair(java.lang.String format, java.lang.Object... args)
-
-
-
Field Detail
-
traceTypeSerializer
public static final IVersionedSerializer<Tracing.TraceType> traceTypeSerializer
-
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
-
-
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 callingExecutorLocal.set(Object)
when running on a executor thread.- Specified by:
get
in interfaceExecutorLocal<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 interfaceExecutorLocal<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)
-
newTraceState
protected abstract TraceState newTraceState(InetAddressAndPort 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 for non-local traces (traces that are not initiated by local node == coordinator).
-
-