Package io.opentelemetry.api.trace
Class SpanId
- java.lang.Object
-
- io.opentelemetry.api.trace.SpanId
-
@Immutable public final class SpanId extends Object
Helper methods for dealing with a span identifier. A valid span identifier is an 8-byte array with at least one non-zero byte. In base-16 representation, a 16 character hex String, where at least one of the characters is not a '0'.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longasLong(CharSequence src)Convert the the given hex spanId into a long representation.static byte[]bytesFromHex(String src, int srcOffset)Returns aSpanIdbuilt from a lowercase base16 representation.static StringbytesToHex(byte[] spanId)Encode the bytes as base-16 (hex), padded with '0's on the left.static StringfromLong(long id)Generate a validSpanIdfrom the given long value.static intgetHexLength()Returns the length of the base16 (hex) representation of theSpanId.static StringgetInvalid()Returns the invalidSpanId.static intgetSize()Returns the size in bytes of theSpanId.static booleanisValid(String spanId)Returns whether the span identifier is valid.
-
-
-
Method Detail
-
getSize
public static int getSize()
Returns the size in bytes of theSpanId.- Returns:
- the size in bytes of the
SpanId.
-
getHexLength
public static int getHexLength()
Returns the length of the base16 (hex) representation of theSpanId.
-
getInvalid
public static String getInvalid()
Returns the invalidSpanId. All bytes are 0.- Returns:
- the invalid
SpanId.
-
bytesFromHex
public static byte[] bytesFromHex(String src, int srcOffset)
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.
-
isValid
public static boolean isValid(String spanId)
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.
-
bytesToHex
public static String bytesToHex(byte[] spanId)
Encode the bytes as base-16 (hex), padded with '0's on the left.
-
asLong
public static long asLong(CharSequence src)
Convert the the given hex spanId into a long representation.
-
-