Package datadog.trace.api
Class DD128bTraceId
java.lang.Object
datadog.trace.api.DDTraceId
datadog.trace.api.DD128bTraceId
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic DD128bTraceIdfrom(long highOrderBits, long lowOrderBits) Create a new 128-bitDD128bTraceIdfrom the givenlongs interpreted as high order and low order bits of the 128-bit id.static DD128bTraceIdCreate a new 128-bitDD128bTraceIdfrom the given hexadecimalStringrepresentation.static DD128bTraceIdCreate a new 128-bitDD128bTraceIdfrom the given hexadecimalStringrepresentation.inthashCode()Returns the lower-case zero-padded 32 hexadecimal charactersStringrepresentation of theDD128bTraceId.toHexStringPadded(int size) Returns the lower-case zero-paddedhexadecimal Stringrepresentation of theDDTraceId.longReturns the high-order 64 bits of 128-bitDDTraceIdas un unsignedlong.longtoLong()Returns the low-order 64 bits of theDDTraceIdas an unsignedlong.toString()
-
Field Details
-
ZERO
-
-
Method Details
-
from
Create a new 128-bitDD128bTraceIdfrom the givenlongs interpreted as high order and low order bits of the 128-bit id.- Parameters:
highOrderBits- Alongrepresenting the high-order bits of theDD128bTraceId.lowOrderBits- Alongrepresenting the random id low-order bits.- Returns:
- The created TraceId instance.
-
fromHex
Create a new 128-bitDD128bTraceIdfrom the given hexadecimalStringrepresentation.- Parameters:
s- The hexadecimalStringrepresentation to parse (a 32 lower-case hexadecimal characters maximum).- Returns:
- The created TraceId instance.
- Throws:
NumberFormatException- If the hexadecimalStringrepresentation is not valid.
-
fromHex
public static DD128bTraceId fromHex(String s, int start, int length, boolean lowerCaseOnly) throws NumberFormatException Create a new 128-bitDD128bTraceIdfrom the given hexadecimalStringrepresentation.- Parameters:
s- The string containing the hexadecimalStringrepresentation to parse (32 lower or higher-case hexadecimal characters maximum).start- The start index of the hexadecimalStringrepresentation to parse.length- The length of the hexadecimalStringrepresentation to parse.lowerCaseOnly- Whether the hexadecimal characters to parse are lower-case only or not.- Returns:
- The created TraceId instance.
- Throws:
NumberFormatException- If the hexadecimalStringrepresentation is not valid.
-
toHexString
Returns the lower-case zero-padded 32 hexadecimal charactersStringrepresentation of theDD128bTraceId.- Specified by:
toHexStringin classDDTraceId- Returns:
- A lower-case zero-padded 32 hexadecimal characters
Stringrepresentation of theDD128bTraceIdinstance.
-
toHexStringPadded
Description copied from class:DDTraceIdReturns the lower-case zero-paddedhexadecimal Stringrepresentation of theDDTraceId. The size will be rounded up to16or32characters. This hexadecimalStringwill not be cached.- Specified by:
toHexStringPaddedin classDDTraceId- Parameters:
size- The size in characters of the zero-paddedString(rounded up to16or32).- Returns:
- A lower-case zero-padded
String representationrepresentation of theDDTraceIdinstance.
-
toLong
public long toLong()Description copied from class:DDTraceIdReturns the low-order 64 bits of theDDTraceIdas an unsignedlong. This means that values larger thanLong.MAX_VALUEwill be represented as negative numbers. -
toHighOrderLong
public long toHighOrderLong()Description copied from class:DDTraceIdReturns the high-order 64 bits of 128-bitDDTraceIdas un unsignedlong. This means that values larger thanLong.MAX_VALUEwill be represented as negative numbers.- Specified by:
toHighOrderLongin classDDTraceId- Returns:
- The high-order 64 bits of the 128-bit
DDTraceIdas an unsignedlong,0for 64-bitDDTraceIdonly.
-
equals
-
hashCode
public int hashCode() -
toString
Description copied from class:DDTraceId
-