- java.lang.Object
-
- de.codecamp.tracer.impl.TraceContextImpl
-
- All Implemented Interfaces:
TraceContext,AutoCloseable
public class TraceContextImpl extends Object implements TraceContext
A trace context that may contain a number of traces.
-
-
Field Summary
Fields Modifier and Type Field Description static ThreadLocal<TraceContext>CURRENT_CONTEXTthe current profiler context
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this trace context.ActiveTracegetActiveTrace()Returns the deepest currently active trace of the current context or a no-op dummy if none is available.de.codecamp.tracer.impl.FilterModegetFilterMode()UUIDgetId()StringgetName()TraceContextImplgetParentContext()TracegetRootTrace()booleanisRootContext()Trace contexts can be nested.voidsetExitThrowable(Throwable exitThrowable)Setting a throwable indicates that the trace context hasn't exited regularly.ActiveTracestartTrace(String label, Object... labelFormatArgs)Starts a new sub-trace within this trace context.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.codecamp.tracer.TraceContext
startTrace
-
-
-
-
Field Detail
-
CURRENT_CONTEXT
public static final ThreadLocal<TraceContext> CURRENT_CONTEXT
the current profiler context
-
-
Method Detail
-
getId
public UUID getId()
- Specified by:
getIdin interfaceTraceContext
-
getName
public String getName()
-
getParentContext
public TraceContextImpl getParentContext()
-
getFilterMode
public de.codecamp.tracer.impl.FilterMode getFilterMode()
-
getRootTrace
public Trace getRootTrace()
-
isRootContext
public boolean isRootContext()
Description copied from interface:TraceContextTrace contexts can be nested. This method returns whether this is the root context.- Specified by:
isRootContextin interfaceTraceContext- Returns:
- whether this is the root context
-
setExitThrowable
public void setExitThrowable(Throwable exitThrowable)
Description copied from interface:TraceContextSetting a throwable indicates that the trace context hasn't exited regularly. As a consequence, durations can't necessarily be compared to other traces.- Specified by:
setExitThrowablein interfaceTraceContext- Parameters:
exitThrowable- the throwable that exited the trace
-
startTrace
public ActiveTrace startTrace(String label, Object... labelFormatArgs)
Description copied from interface:TraceContextStarts a new sub-trace within this trace context. Ends the currently active trace of this trace context, if there is one.v *
- Specified by:
startTracein interfaceTraceContext- Parameters:
label- the label to use for this trace; may contain placeholderslabelFormatArgs- the format arguments for the placeholders in the label- Returns:
- an
ActiveTracethat can be used in a try-with-resource
-
getActiveTrace
public ActiveTrace getActiveTrace()
Description copied from interface:TraceContextReturns the deepest currently active trace of the current context or a no-op dummy if none is available.- Specified by:
getActiveTracein interfaceTraceContext- Returns:
- the deepest currently active trace of the current context or a no-op dummy if none is available.
-
close
public void close()
Closes this trace context. This will end any currently active trace of that context.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTraceContext
-
-