Class SpanWrapper

java.lang.Object
io.opentelemetry.sdk.trace.SpanWrapper
All Implemented Interfaces:
SpanData
Direct Known Subclasses:
AutoValue_SpanWrapper

@Immutable abstract class SpanWrapper extends Object implements SpanData
Immutable class that stores SpanData based on a SdkSpan.

This class stores a reference to a mutable SdkSpan (delegate) which it uses only the immutable parts from, and a copy of all the mutable parts.

When adding a new field to SdkSpan, store a copy if and only if the field is mutable in the SdkSpan. Otherwise retrieve it from the referenced SdkSpan.

  • Constructor Details

    • SpanWrapper

      SpanWrapper()
  • Method Details

    • delegate

      abstract SdkSpan delegate()
    • resolvedLinks

      abstract List<LinkData> resolvedLinks()
    • resolvedEvents

      abstract List<EventData> resolvedEvents()
    • attributes

      abstract Attributes attributes()
    • totalAttributeCount

      abstract int totalAttributeCount()
    • totalRecordedEvents

      abstract int totalRecordedEvents()
    • totalRecordedLinks

      abstract int totalRecordedLinks()
    • status

      abstract StatusData status()
    • name

      abstract String name()
    • endEpochNanos

      abstract long endEpochNanos()
    • internalHasEnded

      abstract boolean internalHasEnded()
    • create

      static SpanWrapper create(SdkSpan delegate, List<LinkData> links, List<EventData> events, Attributes attributes, int totalAttributeCount, int totalRecordedEvents, int totalRecordedLinks, StatusData status, String name, long endEpochNanos, boolean hasEnded)
      Note: the collections that are passed into this creator method are assumed to be immutable to preserve the overall immutability of the class.
    • getSpanContext

      public SpanContext getSpanContext()
      Description copied from interface: SpanData
      Returns the SpanContext of the Span.
      Specified by:
      getSpanContext in interface SpanData
    • getParentSpanContext

      public SpanContext getParentSpanContext()
      Description copied from interface: SpanData
      Returns the parent SpanContext. If the span is a root span, the SpanContext returned will be invalid.
      Specified by:
      getParentSpanContext in interface SpanData
    • getResource

      public Resource getResource()
      Description copied from interface: SpanData
      Returns the resource of this Span.
      Specified by:
      getResource in interface SpanData
      Returns:
      the resource of this Span.
    • getInstrumentationLibraryInfo

      @Deprecated public InstrumentationLibraryInfo getInstrumentationLibraryInfo()
      Deprecated.
      Description copied from interface: SpanData
      Returns the instrumentation library specified when creating the tracer which produced this Span.
      Specified by:
      getInstrumentationLibraryInfo in interface SpanData
      Returns:
      an instance of InstrumentationLibraryInfo
    • getInstrumentationScopeInfo

      public InstrumentationScopeInfo getInstrumentationScopeInfo()
      Description copied from interface: SpanData
      Returns the instrumentation scope specified when creating the tracer which produced this Span.
      Specified by:
      getInstrumentationScopeInfo in interface SpanData
      Returns:
      an instance of InstrumentationScopeInfo
    • getName

      public String getName()
      Description copied from interface: SpanData
      Returns the name of this Span.
      Specified by:
      getName in interface SpanData
      Returns:
      the name of this Span.
    • getKind

      public SpanKind getKind()
      Description copied from interface: SpanData
      Returns the kind of this Span.
      Specified by:
      getKind in interface SpanData
      Returns:
      the kind of this Span.
    • getStartEpochNanos

      public long getStartEpochNanos()
      Description copied from interface: SpanData
      Returns the start epoch timestamp in nanos of this Span.
      Specified by:
      getStartEpochNanos in interface SpanData
      Returns:
      the start epoch timestamp in nanos of this Span.
    • getAttributes

      public Attributes getAttributes()
      Description copied from interface: SpanData
      Returns the attributes recorded for this Span.
      Specified by:
      getAttributes in interface SpanData
      Returns:
      the attributes recorded for this Span.
    • getEvents

      public List<EventData> getEvents()
      Description copied from interface: SpanData
      Returns the timed events recorded for this Span.
      Specified by:
      getEvents in interface SpanData
      Returns:
      the timed events recorded for this Span.
    • getLinks

      public List<LinkData> getLinks()
      Description copied from interface: SpanData
      Returns links recorded for this Span.
      Specified by:
      getLinks in interface SpanData
      Returns:
      links recorded for this Span.
    • getStatus

      public StatusData getStatus()
      Description copied from interface: SpanData
      Returns the Status.
      Specified by:
      getStatus in interface SpanData
      Returns:
      the Status.
    • getEndEpochNanos

      public long getEndEpochNanos()
      Description copied from interface: SpanData
      Returns the end epoch timestamp in nanos of this Span.
      Specified by:
      getEndEpochNanos in interface SpanData
      Returns:
      the end epoch timestamp in nanos of this Span.
    • hasEnded

      public boolean hasEnded()
      Description copied from interface: SpanData
      Returns whether this Span has already been ended.
      Specified by:
      hasEnded in interface SpanData
      Returns:
      true if the span has already been ended, false if not.
    • getTotalRecordedEvents

      public int getTotalRecordedEvents()
      Description copied from interface: SpanData
      The total number of EventData events that were recorded on this span. This number may be larger than the number of events that are attached to this span, if the total number recorded was greater than the configured maximum value. See: SpanLimits.getMaxNumberOfEvents()
      Specified by:
      getTotalRecordedEvents in interface SpanData
      Returns:
      The total number of events recorded on this span.
    • getTotalRecordedLinks

      public int getTotalRecordedLinks()
      Description copied from interface: SpanData
      The total number of LinkData links that were recorded on this span. This number may be larger than the number of links that are attached to this span, if the total number recorded was greater than the configured maximum value. See: SpanLimits.getMaxNumberOfLinks()
      Specified by:
      getTotalRecordedLinks in interface SpanData
      Returns:
      The total number of links recorded on this span.
    • getTotalAttributeCount

      public int getTotalAttributeCount()
      Description copied from interface: SpanData
      The total number of attributes that were recorded on this span. This number may be larger than the number of attributes that are attached to this span, if the total number recorded was greater than the configured maximum value. See: SpanLimits.getMaxNumberOfAttributes()
      Specified by:
      getTotalAttributeCount in interface SpanData
      Returns:
      The total number of attributes on this span.
    • toString

      public final String toString()
      Overrides:
      toString in class Object