Interface Span.Builder<B extends Span.Builder<B>>

Type Parameters:
B - type of the builder that implements this interface, to have correct return types of builder methods
All Superinterfaces:
Builder<B,Span>, Supplier<Span>
Enclosing interface:
Span

public static interface Span.Builder<B extends Span.Builder<B>> extends Builder<B,Span>
Fluent API builder to create a new Span.
  • Method Details

    • parent

      B parent(SpanContext spanContext)
      Parent span of the new span.
      Parameters:
      spanContext - span context to be the parent of this span
      Returns:
      updated builder instance
    • kind

      B kind(Span.Kind kind)
      Kind of this span.
      Parameters:
      kind - kind to use
      Returns:
      updated builder instance
    • tag

      default B tag(Tag<?> tag)
      Add a tag.
      Parameters:
      tag - tag to add (or set)
      Returns:
      updated builder instance
    • tag

      B tag(String key, String value)
      Add a string tag.
      Parameters:
      key - tag key
      value - tag value
      Returns:
      updated builder instance
    • tag

      B tag(String key, Boolean value)
      Add a boolean tag.
      Parameters:
      key - tag key
      value - tag value
      Returns:
      updated builder instance
    • tag

      B tag(String key, Number value)
      Add a number tag.
      Parameters:
      key - tag key
      value - tag value
      Returns:
      updated builder instance
    • start

      default Span start()
      Build and start the span with current timestamp.
      Returns:
      newly created and started span
    • start

      Span start(Instant instant)
      Start the span with an explicit timestamp.
      Parameters:
      instant - when the span started
      Returns:
      newly created and started span
    • unwrap

      default <T> T unwrap(Class<T> type)
      Unwrap this builder instance into a known type. This method limits abstraction and will not allow replacement of tracer implementation.
      Type Parameters:
      T - type of the builder
      Parameters:
      type - type to unwrap to
      Returns:
      unwrapped instance
      Throws:
      IllegalArgumentException - when the expected type is not the actual type, or the builder cannot be coerced into that type