-
- All Known Implementing Classes:
TracerImpl
public interface TracerA simple tool for hierarchical measurement of durations in your code.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ActiveTraceactiveTrace()Returns the deepest currently active trace of the current context or a no-op dummy if none is available.static TraceContextcontext()Returns the currently open tracer context or a no-op dummy if none is available.static booleanhasContext()Returns whether a tracer context is currently open for the current thread.default TraceContextopenContext(String fullContextName, String contextLabel)Opens a new tracer context.TraceContextopenContext(String fullContextName, String contextLabel, Object... labelFormatArgs)Opens a new trace context.
-
-
-
Method Detail
-
openContext
default TraceContext openContext(String fullContextName, String contextLabel)
Opens a new tracer 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.- 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- Returns:
- the started trace session
-
openContext
TraceContext openContext(String fullContextName, String contextLabel, Object... labelFormatArgs)
Opens a new trace 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.- 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
-
hasContext
static boolean hasContext()
Returns whether a tracer context is currently open for the current thread.- Returns:
- whether a tracer context is currently open for the current thread
-
context
static TraceContext context()
Returns the currently open tracer context or a no-op dummy if none is available.- Returns:
- the currently open tracer context or a no-op dummy; never null
-
activeTrace
static ActiveTrace activeTrace()
Returns the deepest currently active trace of the current context or a no-op dummy if none is available.- Returns:
- the deepest currently active trace of the current context or a no-op dummy if none is available.
-
-