Package com.appoptics.api.ext
Class TraceContext
- java.lang.Object
-
- com.appoptics.api.ext.TraceContext
-
public abstract class TraceContext extends java.lang.Object
Allows explicit control on tracing context, which is used to manage the linkage ofTraceEvent
s.This determines the current state/context of tracing, when
TraceEvent
s are reported, the context would be updated. The context then provides references such that new events created can link and point to previous events to form extents/trace.Under most circumstances, context is set and managed automatically. This explicit control might only be necessary for trace that crosses multiple threads with top extent thread not being the parent thread of all the other events.
Example:
TraceContext currentContext = TraceContext.getDefault(); threadPoolExecutor.submit(new MyCallable(currentContext)); ... private class MyCallable { private TraceContext traceContext; private MyCallable(TraceContext context) { this.traceContext = context; } public call() { if (traceContext != null) { traceContext.setAsDefault(); TraceEvent entryEvent = Trace.createEntryEvent("ThreadedJob"); ... } } }
- See Also:
Context
-
-
Constructor Summary
Constructors Constructor Description TraceContext()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static void
clearDefault()
Resets the current thread's contextstatic TraceContext
getDefault()
Returns the Context currently associated with this thread.static boolean
isSampled(java.lang.String xTraceID)
abstract void
setAsDefault()
Sets the current thread's context to this context
-
-
-
Method Detail
-
getDefault
public static TraceContext getDefault()
Returns the Context currently associated with this thread. Note that this context is Clone of the context: modifications will NOT affect the current thread unless setAsDefault is called.- Returns:
- ITraceContextHandler
-
clearDefault
public static void clearDefault()
Resets the current thread's context
-
setAsDefault
public abstract void setAsDefault()
Sets the current thread's context to this context
-
isSampled
public static boolean isSampled(java.lang.String xTraceID)
-
-