Interface Tracer

  • All Known Implementing Classes:
    TracerImpl

    public interface Tracer
    A simple tool for hierarchical measurement of durations in your code.
    • 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 warnings
        contextLabel - a label for the context; in contrast to fullContextName this 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 warnings
        contextLabel - a label for the context; in contrast to fullContextName this 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 sequence
        labelFormatArgs - 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.