org.usergrid.persistence.cassandra.util
Class TraceTagManager

java.lang.Object
  extended by org.usergrid.persistence.cassandra.util.TraceTagManager

public class TraceTagManager
extends Object

Keeps the TraceTag as a ThreadLocal

Author:
zznate

Constructor Summary
TraceTagManager()
           
 
Method Summary
 TraceTag acquire()
          Get the tag from a ThreadLocal.
 void addTimer(TimedOpTag timedOpTag)
          Add this TimedOpTag to the underlying trace if there is one.
 void attach(TraceTag traceTag)
          Attache the tag to the current Thread.
 TraceTag create(String tagName)
          Create a TraceTag
 TraceTag createMetered(String tagName)
           
 TraceTag detach()
          Detach the tag from the current thread.
 boolean getExplicitOnly()
          Allow for/check against traces in piecemeal.
 int getFlushAtOpCount()
          The maximum number of o TimedOpTag objects we can attach to a tracing instance.
 boolean getTraceEnabled()
           
 boolean isActive()
          Returns true if there is a trace in progress
 void setExplicitOnly(boolean explicitOnly)
           
 void setFlushAtOpCount(int flushAtOpCount)
           
 void setReportUnattached(boolean reportUnattached)
          If set to true we log all TimedOpTag objects not attached to a Trace
 void setTraceEnabled(boolean traceEnabled)
          Enable tracing.
 TimedOpTag timerInstance()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TraceTagManager

public TraceTagManager()
Method Detail

setTraceEnabled

public void setTraceEnabled(boolean traceEnabled)
Enable tracing. Off by default.

Parameters:
traceEnabled -

getTraceEnabled

public boolean getTraceEnabled()

getFlushAtOpCount

public int getFlushAtOpCount()
The maximum number of o TimedOpTag objects we can attach to a tracing instance. Excess of this will for a blocking flush on the current thread to the configured reporter instance. The default is 100. If you have other ThreadLocal variables, you should probably lower this value.

Returns:

setFlushAtOpCount

public void setFlushAtOpCount(int flushAtOpCount)

setReportUnattached

public void setReportUnattached(boolean reportUnattached)
If set to true we log all TimedOpTag objects not attached to a Trace

Parameters:
reportUnattached -

getExplicitOnly

public boolean getExplicitOnly()
Allow for/check against traces in piecemeal. Use this when setTraceEnabled(boolean) is set to false and you want callers to control whether or not to initiate a trace. An example would be initiating traces in a ServletFilter by looking for a header or parameter as tracing all requests would be expensive.

Returns:

setExplicitOnly

public void setExplicitOnly(boolean explicitOnly)

acquire

public TraceTag acquire()
Get the tag from a ThreadLocal. Will return null if no tag is attached.

Returns:

timerInstance

public TimedOpTag timerInstance()

addTimer

public void addTimer(TimedOpTag timedOpTag)
Add this TimedOpTag to the underlying trace if there is one. Optionally log it's contents if no trace is active. If an active trace was found and TraceTag.getOpCount() exceeded getFlushAtOpCount(), then the trace is dumped to the reporter and TraceTag.removeOps() is invoked. The TraceTag stay attached with the same name and ID, but now with no pending ops.

Parameters:
timedOpTag -

isActive

public boolean isActive()
Returns true if there is a trace in progress

Returns:

attach

public void attach(TraceTag traceTag)
Attache the tag to the current Thread. Will throw an IllegalStateException if there is already a trace in progress.

Parameters:
traceTag -

detach

public TraceTag detach()
Detach the tag from the current thread. Throws an IllegalStateException if there is no trace in progress.


create

public TraceTag create(String tagName)
Create a TraceTag

Returns:

createMetered

public TraceTag createMetered(String tagName)


Copyright © 2013. All Rights Reserved.