Interface ReadableSpan

All Known Subinterfaces:
ReadWriteSpan

public interface ReadableSpan
SDK representation of a Span that can be read.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    getAttribute(io.opentelemetry.api.common.AttributeKey<T> key)
    Returns the value for the given AttributeKey, or null if not found.
    io.opentelemetry.sdk.common.InstrumentationLibraryInfo
    default io.opentelemetry.sdk.common.InstrumentationScopeInfo
    Returns the instrumentation scope specified when creating the tracer which produced this span.
    io.opentelemetry.api.trace.SpanKind
    Returns the kind of the span.
    long
    Returns the latency of the Span in nanos.
    Returns the name of the Span.
    io.opentelemetry.api.trace.SpanContext
    Returns the parent SpanContext of the Span, or SpanContext.getInvalid() if this is a root span.
    io.opentelemetry.api.trace.SpanContext
    Returns the SpanContext of the Span.
    boolean
    Returns whether this Span has already been ended.
    This converts this instance into an immutable SpanData instance, for use in export.
  • Method Details

    • getSpanContext

      io.opentelemetry.api.trace.SpanContext getSpanContext()
      Returns the SpanContext of the Span.

      Equivalent with Span.getSpanContext().

      Returns:
      the SpanContext of the Span.
    • getParentSpanContext

      io.opentelemetry.api.trace.SpanContext getParentSpanContext()
      Returns the parent SpanContext of the Span, or SpanContext.getInvalid() if this is a root span.
      Returns:
      the parent SpanContext of the Span
    • getName

      String getName()
      Returns the name of the Span.

      The name can be changed during the lifetime of the Span by using the Span.updateName(String) so this value cannot be cached.

      Note: the implementation of this method performs locking to ensure thread-safe behavior.

      Returns:
      the name of the Span.
    • toSpanData

      SpanData toSpanData()
      This converts this instance into an immutable SpanData instance, for use in export.
      Returns:
      an immutable SpanData instance.
    • getInstrumentationLibraryInfo

      @Deprecated io.opentelemetry.sdk.common.InstrumentationLibraryInfo getInstrumentationLibraryInfo()
      Returns the instrumentation library specified when creating the tracer which produced this span.
      Returns:
      an instance of InstrumentationLibraryInfo describing the instrumentation library
    • getInstrumentationScopeInfo

      default io.opentelemetry.sdk.common.InstrumentationScopeInfo getInstrumentationScopeInfo()
      Returns the instrumentation scope specified when creating the tracer which produced this span.
      Returns:
      an instance of InstrumentationScopeInfo describing the instrumentation scope
    • hasEnded

      boolean hasEnded()
      Returns whether this Span has already been ended.

      Note: the implementation of this method performs locking to ensure thread-safe behavior.

      Returns:
      true if the span has already been ended, false if not.
    • getLatencyNanos

      long getLatencyNanos()
      Returns the latency of the Span in nanos. If still active then returns now() - start time.

      Note: the implementation of this method performs locking to ensure thread-safe behavior.

      Returns:
      the latency of the Span in nanos.
    • getKind

      io.opentelemetry.api.trace.SpanKind getKind()
      Returns the kind of the span.
      Returns:
      the kind of the span.
    • getAttribute

      @Nullable <T> T getAttribute(io.opentelemetry.api.common.AttributeKey<T> key)
      Returns the value for the given AttributeKey, or null if not found.

      The attribute values can be changed during the lifetime of the Span by using Span.setAttribute(java.lang.String, java.lang.String)} so this value cannot be cached.

      Note: the implementation of this method performs locking to ensure thread-safe behavior.

      Returns:
      the value for the given AttributeKey, or null if not found.