Class SpanId
java.lang.Object
io.opencensus.trace.SpanId
- All Implemented Interfaces:
Comparable<SpanId>
A class that represents a span identifier. A valid span identifier is an 8-byte array with at
least one non-zero byte.
- Since:
- 0.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final longstatic final SpanIdThe invalidSpanId.private static final longstatic final intThe size in bytes of theSpanId. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidcopyBytesTo(byte[] dest, int destOffset) Copies the byte array representations of theSpanIdinto thedestbeginning at thedestOffsetoffset.voidcopyLowerBase16To(char[] dest, int destOffset) Copies the lowercase base16 representations of theSpanIdinto thedestbeginning at thedestOffsetoffset.booleanstatic SpanIdfromBytes(byte[] src) Returns aSpanIdbuilt from a byte representation.static SpanIdfromBytes(byte[] src, int srcOffset) Returns aSpanIdwhose representation is copied from thesrcbeginning at thesrcOffsetoffset.static SpanIdReturns aSpanIdbuilt from a lowercase base16 representation.static SpanIdfromLowerBase16(CharSequence src, int srcOffset) Returns aSpanIdbuilt from a lowercase base16 representation.static SpanIdgenerateRandomId(Random random) Generates a new randomSpanId.byte[]getBytes()Returns the byte representation of theSpanId.inthashCode()booleanisValid()Returns whether the span identifier is valid.Returns the lowercase base16 encoding of thisSpanId.toString()
-
Field Details
-
SIZE
public static final int SIZEThe size in bytes of theSpanId.- Since:
- 0.5
- See Also:
-
INVALID
-
BASE16_SIZE
private static final int BASE16_SIZE- See Also:
-
INVALID_ID
private static final long INVALID_ID- See Also:
-
id
private final long id
-
-
Constructor Details
-
SpanId
private SpanId(long id)
-
-
Method Details
-
fromBytes
Returns aSpanIdbuilt from a byte representation.- Parameters:
src- the representation of theSpanId.- Returns:
- a
SpanIdwhose representation is given by thesrcparameter. - Throws:
NullPointerException- ifsrcis null.IllegalArgumentException- ifsrc.lengthis notSIZE.- Since:
- 0.5
-
fromBytes
Returns aSpanIdwhose representation is copied from thesrcbeginning at thesrcOffsetoffset.- Parameters:
src- the buffer where the representation of theSpanIdis copied.srcOffset- the offset in the buffer where the representation of theSpanIdbegins.- Returns:
- a
SpanIdwhose representation is copied from the buffer. - Throws:
NullPointerException- ifsrcis null.IndexOutOfBoundsException- ifsrcOffset+SpanId.SIZEis greater thansrc.length.- Since:
- 0.5
-
fromLowerBase16
Returns aSpanIdbuilt from a lowercase base16 representation.- Parameters:
src- the lowercase base16 representation.- Returns:
- a
SpanIdbuilt from a lowercase base16 representation. - Throws:
NullPointerException- ifsrcis null.IllegalArgumentException- ifsrc.lengthis not2 * SpanId.SIZEOR if thestrhas invalid characters.- Since:
- 0.11
-
fromLowerBase16
Returns aSpanIdbuilt from a lowercase base16 representation.- Parameters:
src- the lowercase base16 representation.srcOffset- the offset in the buffer where the representation of theSpanIdbegins.- Returns:
- a
SpanIdbuilt from a lowercase base16 representation. - Throws:
NullPointerException- ifsrcis null.IllegalArgumentException- if not enough characters in thesrcfrom thesrcOffset.- Since:
- 0.11
-
generateRandomId
-
getBytes
public byte[] getBytes()Returns the byte representation of theSpanId.- Returns:
- the byte representation of the
SpanId. - Since:
- 0.5
-
copyBytesTo
public void copyBytesTo(byte[] dest, int destOffset) Copies the byte array representations of theSpanIdinto thedestbeginning at thedestOffsetoffset.- Parameters:
dest- the destination buffer.destOffset- the starting offset in the destination buffer.- Throws:
NullPointerException- ifdestis null.IndexOutOfBoundsException- ifdestOffset+SpanId.SIZEis greater thandest.length.- Since:
- 0.5
-
copyLowerBase16To
public void copyLowerBase16To(char[] dest, int destOffset) Copies the lowercase base16 representations of theSpanIdinto thedestbeginning at thedestOffsetoffset.- Parameters:
dest- the destination buffer.destOffset- the starting offset in the destination buffer.- Throws:
IndexOutOfBoundsException- ifdestOffset + 2 * SpanId.SIZEis greater thandest.length.- Since:
- 0.18
-
isValid
public boolean isValid()Returns whether the span identifier is valid. A valid span identifier is an 8-byte array with at least one non-zero byte.- Returns:
trueif the span identifier is valid.- Since:
- 0.5
-
toLowerBase16
Returns the lowercase base16 encoding of thisSpanId.- Returns:
- the lowercase base16 encoding of this
SpanId. - Since:
- 0.11
-
equals
-
hashCode
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<SpanId>
-