Class TestSpanData.Builder

java.lang.Object
io.opentelemetry.sdk.testing.trace.TestSpanData.Builder
Enclosing class:
TestSpanData

public abstract static class TestSpanData.Builder extends Object
A Builder class for TestSpanData.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • build

      public TestSpanData build()
      Create a new SpanData instance from the data in this.
      Returns:
      a new SpanData instance
    • setSpanContext

      public abstract TestSpanData.Builder setSpanContext(io.opentelemetry.api.trace.SpanContext spanContext)
      Set the SpanContext on this builder.
      Parameters:
      spanContext - the SpanContext.
      Returns:
      this builder (for chaining).
    • setParentSpanContext

      public abstract TestSpanData.Builder setParentSpanContext(io.opentelemetry.api.trace.SpanContext parentSpanContext)
      The parent span context associated for this span, which may be null.
      Parameters:
      parentSpanContext - the SpanId of the parent
      Returns:
      this.
    • setResource

      public abstract TestSpanData.Builder setResource(io.opentelemetry.sdk.resources.Resource resource)
      Set the Resource associated with this span. Must not be null.
      Parameters:
      resource - the Resource that generated this span.
      Returns:
      this
    • setInstrumentationLibraryInfo

      public abstract TestSpanData.Builder setInstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo instrumentationLibraryInfo)
      Sets the instrumentation library of the tracer which created this span. Must not be null.
      Parameters:
      instrumentationLibraryInfo - the instrumentation library of the tracer which created this span.
      Returns:
      this
    • setName

      public abstract TestSpanData.Builder setName(String name)
      Set the name of the span. Must not be null.
      Parameters:
      name - the name.
      Returns:
      this
    • setStartEpochNanos

      public abstract TestSpanData.Builder setStartEpochNanos(long epochNanos)
      Set the start timestamp of the span.
      Parameters:
      epochNanos - the start epoch timestamp in nanos.
      Returns:
      this
    • setEndEpochNanos

      public abstract TestSpanData.Builder setEndEpochNanos(long epochNanos)
      Set the end timestamp of the span.
      Parameters:
      epochNanos - the end epoch timestamp in nanos.
      Returns:
      this
    • setAttributes

      public abstract TestSpanData.Builder setAttributes(io.opentelemetry.api.common.Attributes attributes)
      Set the attributes that are associated with this span, in the form of Attributes.
      Parameters:
      attributes - Attributes for this span.
      Returns:
      this
      See Also:
      • Attributes
    • setEvents

      public abstract TestSpanData.Builder setEvents(List<io.opentelemetry.sdk.trace.data.EventData> events)
      Set timed events that are associated with this span. Must not be null, may be empty.
      Parameters:
      events - A List<Event> of events associated with this span.
      Returns:
      this
      See Also:
      • EventData
    • setStatus

      public abstract TestSpanData.Builder setStatus(io.opentelemetry.sdk.trace.data.StatusData status)
      Set the status for this span. Must not be null.
      Parameters:
      status - The Status of this span.
      Returns:
      this
    • setKind

      public abstract TestSpanData.Builder setKind(io.opentelemetry.api.trace.SpanKind kind)
      Set the kind of span. Must not be null.
      Parameters:
      kind - The Kind of span.
      Returns:
      this
    • setLinks

      public abstract TestSpanData.Builder setLinks(List<io.opentelemetry.sdk.trace.data.LinkData> links)
      Set the links associated with this span. Must not be null, may be empty.
      Parameters:
      links - A List<Link>
      Returns:
      this
    • setHasEnded

      public final TestSpanData.Builder setHasEnded(boolean hasEnded)
      Sets to true if the span has been ended.
      Parameters:
      hasEnded - A boolean indicating if the span has been ended.
      Returns:
      this
    • setTotalRecordedEvents

      public abstract TestSpanData.Builder setTotalRecordedEvents(int totalRecordedEvents)
      Set the total number of events recorded on this span.
      Parameters:
      totalRecordedEvents - The total number of events recorded.
      Returns:
      this
    • setTotalRecordedLinks

      public abstract TestSpanData.Builder setTotalRecordedLinks(int totalRecordedLinks)
      Set the total number of links recorded on this span.
      Parameters:
      totalRecordedLinks - The total number of links recorded.
      Returns:
      this
    • setTotalAttributeCount

      public abstract TestSpanData.Builder setTotalAttributeCount(int totalAttributeCount)
      Set the total number of attributes recorded on this span.
      Parameters:
      totalAttributeCount - The total number of attributes recorded.
      Returns:
      this