- All Known Implementing Classes:
TracerImpl
public interface Tracer
A simple tool for hierarchical measurement of durations in your code.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ActiveTraceReturns 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 booleanReturns whether a tracer context is currently open for the current thread.default TraceContextopenContext(Class<?> tracedClass, String methodName, Object... paramValues) Opens a new trace context.default TraceContextopenContext(String fullContextName, String contextLabel) Opens a new tracer context.openContext(String fullContextName, String contextLabel, Object... labelFormatArgs) Opens a new trace context.
-
Method Details
-
openContext
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
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
-
openContext
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:
tracedClass- the traced classmethodName- the traced methodparamValues- the method parameter values- 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
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
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.
-