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 voidcopyFrom(Id other)booleandataEquals(byte[] data, int offset)booleanequals(java.lang.Object o)intfromBytes(byte[] bytes, int offset)Sets the id based on a byte arrayvoidfromHexString(java.lang.String hexEncodedString, int offset)voidfromLongs(long... values)longgetLeastSignificantBits()Returns the last 8 bytes of this id as along.inthashCode()booleanisEmpty()static Idnew128BitId()static Idnew64BitId()longreadLong(int offset)Converts the next 8 bytes, starting from the offset, to alongvoidresetState()resets pooled object state so it can be reusedvoidsetToRandomValue()voidsetToRandomValue(java.util.Random random)inttoBytes(byte[] bytes, int offset)java.lang.StringtoString()voidwriteAsHex(com.dslplatform.json.JsonWriter jw)voidwriteAsHex(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'sdataoffset- 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:Recyclableresets pooled object state so it can be reused- Specified by:
resetStatein interfaceRecyclable
-
copyFrom
public void copyFrom(Id other)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
dataEquals
public boolean dataEquals(byte[] data, int offset)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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
-
-