Class NoOpTraceContext

java.lang.Object
de.codecamp.tracer.impl.NoOpTraceContext
All Implemented Interfaces:
TraceContext, AutoCloseable

public final class NoOpTraceContext extends Object implements TraceContext
  • Field Details

  • Method Details

    • getId

      public UUID getId()
      Specified by:
      getId in interface TraceContext
    • isRootContext

      public boolean isRootContext()
      Description copied from interface: TraceContext
      Trace contexts can be nested. This method returns whether this is the root context.
      Specified by:
      isRootContext in interface TraceContext
      Returns:
      whether this is the root context
    • setExitThrowable

      public void setExitThrowable(Throwable exitThrowable)
      Description copied from interface: TraceContext
      Setting 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:
      setExitThrowable in interface TraceContext
      Parameters:
      exitThrowable - the throwable that exited the trace
    • openContext

      public TraceContext openContext(String fullContextName, String contextLabel, Object... labelFormatArgs)
      Description copied from interface: TraceContext
      Opens 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:
      openContext in interface TraceContext
      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
      See Also:
    • startTrace

      public ActiveTrace startTrace(String label, Object... labelFormatArgs)
      Description copied from interface: TraceContext
      Starts a new sub-trace within this trace context. Ends the currently active trace of this trace context, if there is one.

      v *

      Specified by:
      startTrace in interface TraceContext
      Parameters:
      label - the label to use for this trace; may contain placeholders
      labelFormatArgs - the format arguments for the placeholders in the label
      Returns:
      an ActiveTrace that can be used in a try-with-resource
    • getActiveTrace

      public ActiveTrace getActiveTrace()
      Description copied from interface: TraceContext
      Returns the deepest currently active trace of the current context or a no-op dummy if none is available.
      Specified by:
      getActiveTrace in interface TraceContext
      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: TraceContext
      Closes this trace context. Closing a trace context is the responsibility of the one opening it.

      Overridden from AutoCloseable.close() to remove thrown Exception.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface TraceContext