Package datadog.trace.api
Class DDTraceId
java.lang.Object
datadog.trace.api.DDTraceId
- Direct Known Subclasses:
DD128bTraceId,DD64bTraceId
Class encapsulating the 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.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DDTraceIdfrom(long id) Creates a new64-bit TraceIdfrom the givenlonginterpreted as the bits of the unsigned 64-bit id.static DDTraceIdCreates a new64-bit TraceIdfrom the givenString representation.static DDTraceIdCreates a newDDTraceIdfrom the givenhexadecimal representation.abstract Stringabstract StringtoHexStringPadded(int size) Returns the lower-case zero-paddedhexadecimal Stringrepresentation of theDDTraceId.abstract longReturns the high-order 64 bits of 128-bitDDTraceIdas un unsignedlong.abstract longtoLong()Returns the low-order 64 bits of theDDTraceIdas an unsignedlong.abstract StringtoString()
-
Field Details
-
ZERO
Invalid TraceId value used to denote no TraceId. -
ONE
Convenience constant used from tests
-
-
Constructor Details
-
DDTraceId
public DDTraceId()
-
-
Method Details
-
from
Creates a new64-bit TraceIdfrom the givenlonginterpreted as the bits of the unsigned 64-bit id. This means that values larger thanLong.MAX_VALUEwill be represented as negative numbers.- Parameters:
id- Thelongrepresenting the bits of the unsigned 64-bit id.- Returns:
- A new
DDTraceIdinstance.
-
from
Creates a new64-bit TraceIdfrom the givenString representation.- Parameters:
s- TheString representationof aDDTraceId.- Returns:
- A new
DDTraceIdinstance. - Throws:
NumberFormatException- If the givenStringdoes not represent a valid number.
-
fromHex
Creates a newDDTraceIdfrom the givenhexadecimal representation.- Parameters:
s- The hexadecimalStringrepresentation of aDD128bTraceIdto parse.- Returns:
- A new
DDTraceIdinstance. - Throws:
NumberFormatException- If the givenhexadecimal Stringdoes not represent a valid number.
-
toString
-
toHexString
-
toHexStringPadded
Returns the lower-case zero-paddedhexadecimal Stringrepresentation of theDDTraceId. The size will be rounded up to16or32characters. This hexadecimalStringwill not be cached.- 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 abstract long toLong()Returns the low-order 64 bits of theDDTraceIdas an unsignedlong. This means that values larger thanLong.MAX_VALUEwill be represented as negative numbers.- Returns:
- The low-order 64 bits of the
DDTraceIdas an unsignedlong.
-
toHighOrderLong
public abstract long toHighOrderLong()Returns the high-order 64 bits of 128-bitDDTraceIdas un unsignedlong. This means that values larger thanLong.MAX_VALUEwill be represented as negative numbers.
-