Class DD128bTraceId

java.lang.Object
datadog.trace.api.DDTraceId
datadog.trace.api.DD128bTraceId

public class DD128bTraceId extends DDTraceId
Class encapsulating the unsigned 128-bit id used for TraceIds.

It contains parsing and formatting to string for both decimal and hexadecimal representations. The string representations are either kept from parsing, or generated on demand and cached.

DD128bTraceId can represent either a 128-bit TraceId or a 64-bit TraceId. For 128-bit TraceId, highOrderBits contains a 32-bit timestamp store on the 32 higher bits and lowOrderBits contains a unique and random 64-bit id. For 64-bit TraceId, highOrderBits is set to 0 and lowOrderBits contains a unique and random 63-bit id.

  • Field Details

  • Method Details

    • from

      public static DD128bTraceId from(long highOrderBits, long lowOrderBits)
      Create a new 128-bit DD128bTraceId from the given longs interpreted as high order and low order bits of the 128-bit id.
      Parameters:
      highOrderBits - A long representing the high-order bits of the DD128bTraceId.
      lowOrderBits - A long representing the random id low-order bits.
      Returns:
      The created TraceId instance.
    • fromHex

      public static DD128bTraceId fromHex(String s) throws NumberFormatException
      Create a new 128-bit DD128bTraceId from the given hexadecimal String representation.
      Parameters:
      s - The hexadecimal String representation to parse (a 32 lower-case hexadecimal characters maximum).
      Returns:
      The created TraceId instance.
      Throws:
      NumberFormatException - If the hexadecimal String representation is not valid.
    • fromHex

      public static DD128bTraceId fromHex(String s, int start, int length, boolean lowerCaseOnly) throws NumberFormatException
      Create a new 128-bit DD128bTraceId from the given hexadecimal String representation.
      Parameters:
      s - The string containing the hexadecimal String representation to parse (32 lower or higher-case hexadecimal characters maximum).
      start - The start index of the hexadecimal String representation to parse.
      length - The length of the hexadecimal String representation to parse.
      lowerCaseOnly - Whether the hexadecimal characters to parse are lower-case only or not.
      Returns:
      The created TraceId instance.
      Throws:
      NumberFormatException - If the hexadecimal String representation is not valid.
    • toHexString

      public String toHexString()
      Returns the lower-case zero-padded 32 hexadecimal characters String representation of the DD128bTraceId.
      Specified by:
      toHexString in class DDTraceId
      Returns:
      A lower-case zero-padded 32 hexadecimal characters String representation of the DD128bTraceId instance.
    • toHexStringPadded

      public String toHexStringPadded(int size)
      Description copied from class: DDTraceId
      Returns the lower-case zero-padded hexadecimal String representation of the DDTraceId. The size will be rounded up to 16 or 32 characters. This hexadecimal String will not be cached.
      Specified by:
      toHexStringPadded in class DDTraceId
      Parameters:
      size - The size in characters of the zero-padded String (rounded up to 16 or 32).
      Returns:
      A lower-case zero-padded String representation representation of the DDTraceId instance.
    • toLong

      public long toLong()
      Description copied from class: DDTraceId
      Returns the low-order 64 bits of the DDTraceId as an unsigned long. This means that values larger than Long.MAX_VALUE will be represented as negative numbers.
      Specified by:
      toLong in class DDTraceId
      Returns:
      The low-order 64 bits of the DDTraceId as an unsigned long.
    • toHighOrderLong

      public long toHighOrderLong()
      Description copied from class: DDTraceId
      Returns the high-order 64 bits of 128-bit DDTraceId as un unsigned long. This means that values larger than Long.MAX_VALUE will be represented as negative numbers.
      Specified by:
      toHighOrderLong in class DDTraceId
      Returns:
      The high-order 64 bits of the 128-bit DDTraceId as an unsigned long, 0 for 64-bit DDTraceId only.
    • equals

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

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

      public String toString()
      Description copied from class: DDTraceId
      Returns a 64-bit only decimal String representation of the DDTraceId. The String will be cached.
      Specified by:
      toString in class DDTraceId
      Returns:
      A cached 64-bit only decimal String representation of the DDTraceId instance.