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 Summary

    Modifier and Type
    Method
    Description
    Kind of this span.
    parent(SpanContext spanContext)
    Parent span of the new span.
    default Span
    Build and start the span with current timestamp.
    start(Instant instant)
    Start the span with an explicit timestamp.
    default B
    tag(Tag<?> tag)
    Add a tag.
    tag(String key, Boolean value)
    Add a boolean tag.
    tag(String key, Number value)
    Add a number tag.
    tag(String key, String value)
    Add a string tag.
    default <T> T
    unwrap(Class<T> type)
    Unwrap this builder instance into a known type.

    Methods inherited from interface Builder

    build, get, identity, update
    Modifier and Type
    Method
    Description
    Build the instance from this builder.
    default Span
    get()
     
    default B
    Instance of this builder as the correct type.
    default B
    update(Consumer<B> consumer)
    Update the builder in a fluent API way.
  • 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