java.lang.Object
de.codecamp.tracer.impl.NoOpTraceContext
- All Implemented Interfaces:
TraceContext,AutoCloseable
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this trace context.Returns the deepest currently active trace of the current context or a no-op dummy if none is available.getId()booleanTrace contexts can be nested.openContext(String fullContextName, String contextLabel, Object... labelFormatArgs) Opens a new sub-context.voidsetExitThrowable(Throwable exitThrowable) Setting a throwable indicates that the trace context hasn't exited regularly.startTrace(String label, Object... labelFormatArgs) Starts a new sub-trace within this trace context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.codecamp.tracer.TraceContext
openContext, startTrace
-
Field Details
-
INSTANCE
-
-
Method Details
-
getId
- Specified by:
getIdin interfaceTraceContext
-
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
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
-
openContext
public TraceContext openContext(String fullContextName, String contextLabel, Object... labelFormatArgs) Description copied from interface:TraceContextOpens a new sub-context. Each context will implicitly have an associated root trace. All traces started through that context will be sub-traces (i.e. children) of that root trace. If the context is started within another active context (i.e. also bound to the current thread), the new context's root trace will be a sub-trace of the currently active trace.- Specified by:
openContextin interfaceTraceContext- Parameters:
fullContextName- the full context name, typically the fully qualified name of the traced class suffixed with '#' and the method name, if applicable; this name is used for selection, e.g. in includes, excludes and warningscontextLabel- a label for the context; in contrast tofullContextNamethis is supposed to be a shorter label better suited for logging; may contain{}as placeholders that will be replaced with the given format arguments in sequencelabelFormatArgs- the format arguments for the context label- Returns:
- the started trace context
- See Also:
-
startTrace
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
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()Description copied from interface:TraceContextCloses this trace context. Closing a trace context is the responsibility of the one opening it.Overridden from
AutoCloseable.close()to remove thrownException.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceTraceContext
-