Record Class SpanContext

java.lang.Object
java.lang.Record
org.microproxy.otel.SpanContext
Record Components:
traceIdHigh - the trace id's first 8 bytes
traceIdLow - the trace id's last 8 bytes
spanId - the span id
flags - the trace flags, of which bit 0 says whether the trace is sampled
traceState - the tracestate list, normalized, or an empty string
remote - whether the context came from another process

public record SpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote) extends Record
What a propagator carries between processes: a 128-bit trace id, a 64-bit span id, the trace flags (bit 0: sampled) and the W3C tracestate, as OpenTelemetry's SpanContext.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The sampled trace flag.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote)
    Checks the parts.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the value of the flags record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns whether the trace is sampled.
    boolean
    Returns whether the ids are valid: neither is all zeros.
    boolean
    Returns the value of the remote record component.
    long
    Returns the value of the spanId record component.
    Returns the span id as 16 lower-case hex digits.
    Returns a string representation of this record class.
    Returns the trace id as 32 lower-case hex digits.
    long
    Returns the value of the traceIdHigh record component.
    long
    Returns the value of the traceIdLow record component.
    Returns the value of the traceState record component.
    withSpan(long spanId, boolean sampled)
    Returns this context with another span id and sampled flag, as the proxy's own span.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • SpanContext

      public SpanContext(long traceIdHigh, long traceIdLow, long spanId, int flags, String traceState, boolean remote)
      Checks the parts.
      Parameters:
      traceIdHigh - the trace id's first 8 bytes
      traceIdLow - the trace id's last 8 bytes
      spanId - the span id
      flags - the trace flags
      traceState - the tracestate list, or null for none
      remote - whether the context came from another process
  • Method Details

    • isValid

      public boolean isValid()
      Returns whether the ids are valid: neither is all zeros.
      Returns:
      whether the ids are valid: neither is all zeros
    • isSampled

      public boolean isSampled()
      Returns whether the trace is sampled.
      Returns:
      whether the trace is sampled
    • traceIdHex

      public String traceIdHex()
      Returns the trace id as 32 lower-case hex digits.
      Returns:
      the trace id as 32 lower-case hex digits
    • spanIdHex

      public String spanIdHex()
      Returns the span id as 16 lower-case hex digits.
      Returns:
      the span id as 16 lower-case hex digits
    • withSpan

      public SpanContext withSpan(long spanId, boolean sampled)
      Returns this context with another span id and sampled flag, as the proxy's own span.
      Parameters:
      spanId - the span's id
      sampled - whether the trace is sampled
      Returns:
      this context with another span id and sampled flag, as the proxy's own span
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • traceIdHigh

      public long traceIdHigh()
      Returns the value of the traceIdHigh record component.
      Returns:
      the value of the traceIdHigh record component
    • traceIdLow

      public long traceIdLow()
      Returns the value of the traceIdLow record component.
      Returns:
      the value of the traceIdLow record component
    • spanId

      public long spanId()
      Returns the value of the spanId record component.
      Returns:
      the value of the spanId record component
    • flags

      public int flags()
      Returns the value of the flags record component.
      Returns:
      the value of the flags record component
    • traceState

      public String traceState()
      Returns the value of the traceState record component.
      Returns:
      the value of the traceState record component
    • remote

      public boolean remote()
      Returns the value of the remote record component.
      Returns:
      the value of the remote record component