java.lang.Object
de.codecamp.tracer.Trace
A
Trace represents a time interval an application has spent within a certain piece of
code. A trace can be part of a hierarchy, i.e. i can have a parent trace and it can have
sub-traces.-
Method Summary
Modifier and TypeMethodDescriptionvoidSets the trace as ended and records theend time.voidSets this trace and all still active sub-traces as ended and records theend time.getActiveTrace(boolean includeRoot) getData()<T> T<T> TReturns the duration of this trace.Returns the end time of this trace.Returns the throwable that exited the trace.getLabel()Returns the label of this trace.Returns the parent trace or null.Returns the start time of this trace.Returns the list of sub-traces.booleanhasEnded()Returns whether the trace has already ended.booleanReturns whether this trace is the root of aTraceContextImpl.booleanisGap()Returns whether this trace represents a gap.booleanisWarn()static TracenewContextRoot(Trace parentTrace, Instant startTime, String label, Object[] labelFormatArgs) static TracenewExplicit(Trace parentTrace, Instant startTime, String label, Object[] labelFormatArgs) static Trace<T> voidvoidvoidvoidsetWarn(boolean warn) toString()
-
Method Details
-
newGap
-
newExplicit
-
newContextRoot
-
getLabel
Returns the label of this trace.- Returns:
- the label of this trace
-
getStartTime
Returns the start time of this trace.- Returns:
- the start time of this trace
-
getEndTime
Returns the end time of this trace.- Returns:
- the end time of this trace
- Throws:
IllegalStateException- if the trace has not yet finished
-
hasEnded
public boolean hasEnded()Returns whether the trace has already ended.- Returns:
- whether the trace has already ended
-
end
Sets the trace as ended and records theend time.- Parameters:
endTime- the end time for the trace
-
end
Sets this trace and all still active sub-traces as ended and records theend time.- Parameters:
endTime- the end time for the traceexitThrowable- the throwable that exited the trace
-
getDuration
Returns the duration of this trace.- Returns:
- the duration of this trace
- Throws:
IllegalStateException- if the trace has not yet finished
-
getParentTrace
Returns the parent trace or null.- Returns:
- the parent trace or null
-
isContextRoot
public boolean isContextRoot()Returns whether this trace is the root of aTraceContextImpl.- Returns:
- whether this trace is the root of a
TraceContextImpl
-
isGap
public boolean isGap()Returns whether this trace represents a gap. Gaps are periods of time between explicit traces. This can help locate costly segments of code that aren't explicitly traced (yet).- Returns:
- whether this trace represents a gap
-
getSubTraces
Returns the list of sub-traces.- Returns:
- the list of sub-traces
-
getLastSubTrace
-
getActiveTrace
-
getExitThrowable
Returns the throwable that exited the trace.- Returns:
- the throwable that exited the trace
-
isWarn
public boolean isWarn() -
setWarn
public void setWarn(boolean warn) -
getData
-
setData
-
getData
-
getData
-
setData
-
getData
-
setData
-
toString
-