Interface Span

All Superinterfaces:
SpanCustomizer

public interface Span extends SpanCustomizer
This API was heavily influenced by Brave. Parts of its documentation were taken directly from Brave.

Span is a single unit of work that needs to be started and stopped. Contains timing information and events and tags.

Since:
1.0.0
  • Field Details

    • NOOP

      static final Span NOOP
      A noop implementation.
  • Method Details

    • isNoop

      boolean isNoop()
      Returns:
      true when no recording is done and nothing is reported to an external system. However, this span should still be injected into outgoing requests. Use this flag to avoid performing expensive computation.
    • context

      TraceContext context()
      Returns:
      TraceContext corresponding to this span.
    • start

      Span start()
      Starts this span.
      Returns:
      this span
    • name

      Span name(String name)
      Sets a name on this span.
      Specified by:
      name in interface SpanCustomizer
      Parameters:
      name - name to set on the span
      Returns:
      this span
    • event

      Span event(String value)
      Sets an event on this span.
      Specified by:
      event in interface SpanCustomizer
      Parameters:
      value - event name to set on the span
      Returns:
      this span
    • event

      Span event(String value, long time, TimeUnit timeUnit)
      Sets an event on this span.
      Parameters:
      value - event name to set on the span
      time - timestamp of the event
      timeUnit - timestamp's time unit
      Returns:
      this span
    • tag

      Span tag(String key, String value)
      Sets a tag on this span.
      Specified by:
      tag in interface SpanCustomizer
      Parameters:
      key - tag key
      value - tag value
      Returns:
      this span
    • error

      Span error(Throwable throwable)
      Records an exception for this span.
      Parameters:
      throwable - to record
      Returns:
      this span
    • end

      void end()
      Ends the span. The span gets stopped and recorded if not noop.
    • end

      void end(long time, TimeUnit timeUnit)
      Ends the span. The span gets stopped and recorded if not noop.
      Parameters:
      time - timestamp
      timeUnit - time unit of the timestamp
    • abandon

      void abandon()
      Ends the span. The span gets stopped but does not get recorded.
    • remoteServiceName

      Span remoteServiceName(String remoteServiceName)
      Sets the remote service name for the span.
      Parameters:
      remoteServiceName - remote service name
      Returns:
      this span
    • remoteIpAndPort

      Span remoteIpAndPort(String ip, int port)
      Sets the remote url on the span.
      Parameters:
      ip - remote ip
      port - remote port
      Returns:
      this span
      Since:
      1.0.0