Class Id
- java.lang.Object
-
- co.elastic.apm.agent.impl.transaction.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFrom(Id other)
boolean
dataEquals(byte[] data, int offset)
boolean
equals(java.lang.Object o)
int
fromBytes(byte[] bytes, int offset)
Sets the id based on a byte arrayvoid
fromHexString(java.lang.String hexEncodedString, int offset)
void
fromLongs(long... values)
long
getLeastSignificantBits()
Returns the last 8 bytes of this id as along
.int
hashCode()
boolean
isEmpty()
static Id
new128BitId()
static Id
new64BitId()
long
readLong(int offset)
Converts the next 8 bytes, starting from the offset, to along
void
resetState()
resets pooled object state so it can be reusedvoid
setToRandomValue()
void
setToRandomValue(java.util.Random random)
int
toBytes(byte[] bytes, int offset)
java.lang.String
toString()
void
writeAsHex(com.dslplatform.json.JsonWriter jw)
void
writeAsHex(java.lang.StringBuilder sb)
-
-
-
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'sdata
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 interfaceRecyclable
-
copyFrom
public void copyFrom(Id other)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
dataEquals
public boolean dataEquals(byte[] data, int offset)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 along
.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 along
-
-