Class SpanContext


  • @Immutable
    public final class SpanContext
    extends java.lang.Object
    A class that represents a span context. A span context contains the state that must propagate to child Spans and across process boundaries. It contains the identifiers (a trace_id and span_id) associated with the Span and a set of options.
    Since:
    0.5
    • Field Detail

      • TRACESTATE_DEFAULT

        private static final Tracestate TRACESTATE_DEFAULT
      • traceId

        private final TraceId traceId
      • spanId

        private final SpanId spanId
      • INVALID

        public static final SpanContext INVALID
        The invalid SpanContext.
        Since:
        0.5
    • Method Detail

      • create

        @Deprecated
        public static SpanContext create​(TraceId traceId,
                                         SpanId spanId,
                                         TraceOptions traceOptions)
        Creates a new SpanContext with the given identifiers and options.
        Parameters:
        traceId - the trace identifier of the span context.
        spanId - the span identifier of the span context.
        traceOptions - the trace options for the span context.
        Returns:
        a new SpanContext with the given identifiers and options.
      • create

        public static SpanContext create​(TraceId traceId,
                                         SpanId spanId,
                                         TraceOptions traceOptions,
                                         Tracestate tracestate)
        Creates a new SpanContext with the given identifiers and options.
        Parameters:
        traceId - the trace identifier of the span context.
        spanId - the span identifier of the span context.
        traceOptions - the trace options for the span context.
        tracestate - the trace state for the span context.
        Returns:
        a new SpanContext with the given identifiers and options.
        Since:
        0.16
      • getTraceId

        public TraceId getTraceId()
        Returns the trace identifier associated with this SpanContext.
        Returns:
        the trace identifier associated with this SpanContext.
        Since:
        0.5
      • getSpanId

        public SpanId getSpanId()
        Returns the span identifier associated with this SpanContext.
        Returns:
        the span identifier associated with this SpanContext.
        Since:
        0.5
      • getTraceOptions

        public TraceOptions getTraceOptions()
        Returns the TraceOptions associated with this SpanContext.
        Returns:
        the TraceOptions associated with this SpanContext.
        Since:
        0.5
      • getTracestate

        public Tracestate getTracestate()
        Returns the Tracestate associated with this SpanContext.
        Returns:
        the Tracestate associated with this SpanContext.
        Since:
        0.5
      • isValid

        public boolean isValid()
        Returns true if this SpanContext is valid.
        Returns:
        true if this SpanContext is valid.
        Since:
        0.5
      • equals

        public boolean equals​(@Nullable
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object