public abstract class DDTraceId extends Object
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.
Modifier and Type | Field and Description |
---|---|
static DDTraceId |
ONE
Convenience constant used from tests
|
static DDTraceId |
ZERO
Invalid TraceId value used to denote no TraceId.
|
Constructor and Description |
---|
DDTraceId() |
Modifier and Type | Method and Description |
---|---|
static DDTraceId |
from(long id)
Creates a new
64-bit TraceId from the given long interpreted as
the bits of the unsigned 64-bit id. |
static DDTraceId |
from(String s)
Creates a new
64-bit TraceId from the given String
representation . |
static DDTraceId |
fromHex(String s)
Creates a new
DDTraceId from the given hexadecimal
representation . |
abstract String |
toHexString()
|
abstract String |
toHexStringPadded(int size)
Returns the lower-case zero-padded
hexadecimal String representation of
the DDTraceId . |
abstract long |
toHighOrderLong()
Returns the high-order 64 bits of 128-bit
DDTraceId as un unsigned long . |
abstract long |
toLong()
Returns the low-order 64 bits of the
DDTraceId as an unsigned long . |
abstract String |
toString()
|
public static final DDTraceId ZERO
public static final DDTraceId ONE
public static DDTraceId from(long id)
64-bit TraceId
from the given long
interpreted as
the bits of the unsigned 64-bit id. This means that values larger than Long.MAX_VALUE
will be represented as negative numbers.id
- The long
representing the bits of the unsigned 64-bit id.DDTraceId
instance.public static DDTraceId from(String s) throws NumberFormatException
64-bit TraceId
from the given String
representation
.s
- The String representation
of a DDTraceId
.DDTraceId
instance.NumberFormatException
- If the given String
does not represent a valid number.public static DDTraceId fromHex(String s) throws NumberFormatException
DDTraceId
from the given hexadecimal
representation
.s
- The hexadecimal String
representation of a DD128bTraceId
to parse.DDTraceId
instance.NumberFormatException
- If the given hexadecimal String
does not
represent a valid number.public abstract String toString()
public abstract String toHexString()
public abstract String toHexStringPadded(int size)
hexadecimal String
representation of
the DDTraceId
. The size will be rounded up to 16
or 32
characters. This hexadecimal String
will not be cached.size
- The size in characters of the zero-padded String
(rounded up to 16
or 32
).String representation
representation of
the DDTraceId
instance.public abstract long toLong()
DDTraceId
as an unsigned long
. This means
that values larger than Long.MAX_VALUE
will be represented as negative numbers.DDTraceId
as an unsigned long
.public abstract long toHighOrderLong()
DDTraceId
as un unsigned long
. This
means that values larger than Long.MAX_VALUE
will be represented as negative numbers.