Class DelegatingSpanData

java.lang.Object
io.opentelemetry.sdk.trace.data.DelegatingSpanData
All Implemented Interfaces:
SpanData

public abstract class DelegatingSpanData extends Object implements SpanData
A SpanData which delegates all methods to another SpanData. Extend this class to modify the SpanData that will be exported, for example by creating a delegating SpanExporter which wraps SpanData with a custom implementation.

 // class SpanDataWithClientType extends DelegatingSpanData {
 //
 //   private final Attributes attributes;
 //
 //   SpanDataWithClientType(SpanData delegate) {
 //     super(delegate);
 //     String clientType = ClientConfig.parseUserAgent(
 //       delegate.getAttributes().get(SemanticAttributes.USER_AGENT_ORIGINAL).getStringValue());
 //     Attributes.Builder newAttributes = Attributes.builder(delegate.getAttributes());
 //     newAttributes.setAttribute("client_type", clientType);
 //     attributes = newAttributes.build();
 //   }
 //
 //   @Override
 //   public Attributes getAttributes() {
 //     return attributes;
 //   }
 // }
 
  • Constructor Details

    • DelegatingSpanData

      protected DelegatingSpanData(SpanData delegate)
  • Method Details

    • getSpanContext

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

      public io.opentelemetry.api.trace.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 io.opentelemetry.sdk.resources.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 io.opentelemetry.sdk.common.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 io.opentelemetry.sdk.common.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 io.opentelemetry.api.trace.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 io.opentelemetry.api.common.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.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object