Class Id

  • All Implemented Interfaces:
    Recyclable

    public class Id
    extends java.lang.Object
    implements Recyclable
    A 128 bit globally unique ID of the whole trace forest
    • Method Detail

      • new128BitId

        public static Id new128BitId()
      • new64BitId

        public static Id new64BitId()
      • setToRandomValue

        public void setToRandomValue()
      • setToRandomValue

        public void setToRandomValue​(java.util.Random random)
      • fromHexString

        public void fromHexString​(java.lang.String hexEncodedString,
                                  int offset)
      • fromBytes

        public int fromBytes​(byte[] bytes,
                             int offset)
        Sets the id based on a byte array
        Parameters:
        bytes - the byte array used to fill this id's data
        offset - the offset in the byte array
        Returns:
        the number of read bytes which is equivalent to getLength()
      • toBytes

        public int toBytes​(byte[] bytes,
                           int offset)
      • fromLongs

        public void fromLongs​(long... values)
      • resetState

        public void resetState()
        Description copied from interface: Recyclable
        resets pooled object state so it can be reused
        Specified by:
        resetState in interface Recyclable
      • copyFrom

        public void copyFrom​(Id other)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • dataEquals

        public boolean dataEquals​(byte[] data,
                                  int offset)
      • hashCode

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

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

        public boolean isEmpty()
      • writeAsHex

        public void writeAsHex​(com.dslplatform.json.JsonWriter jw)
      • writeAsHex

        public void writeAsHex​(java.lang.StringBuilder sb)
      • getLeastSignificantBits

        public long getLeastSignificantBits()
        Returns the last 8 bytes of this id as a long.

        The least significant bits (the right part) of an id is preferred to be used for making random sampling decisions.

        "There are systems that make random sampling decisions based on the value of trace-id. So to increase interoperability it is recommended to keep the random part on the right side of trace-id value."

        Returns:
        the last 8 bytes of this id as a long
        See Also:
        W3C trace context spec
      • readLong

        public long readLong​(int offset)
        Converts the next 8 bytes, starting from the offset, to a long