Class BinaryFormatImpl
java.lang.Object
io.opencensus.trace.propagation.BinaryFormat
io.opencensus.implcore.trace.propagation.BinaryFormatImpl
Implementation of the
BinaryFormat.
BinaryFormat format:
- Binary value: <version_id><version_format>
- version_id: 1-byte representing the version id.
- For version_id = 0:
- version_format: <field><field>
- field_format: <field_id><field_format>
- Fields:
- TraceId: (field_id = 0, len = 16, default = "0000000000000000") - 16-byte array representing the trace_id.
- SpanId: (field_id = 1, len = 8, default = "00000000") - 8-byte array representing the span_id.
- TraceOptions: (field_id = 2, len = 1, default = "0") - 1-byte array representing the trace_options.
- Fields MUST be encoded using the field id order (smaller to higher).
- Valid value example:
- {0, 0, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 1, 97, 98, 99, 100, 101, 102, 103, 104, 2, 1}
- version_id = 0;
- trace_id = {64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79}
- span_id = {97, 98, 99, 100, 101, 102, 103, 104};
- trace_options = {1};
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intUseTraceOptions.DEFAULTunless its optional field is present.private static final byteprivate static final intVersion, Trace and Span IDs are required fields.private static final byte(package private) static final intprivate static final intprivate static final byte(package private) static final intprivate static final intprivate static final byte(package private) static final intprivate static final intprivate static final Tracestateprivate static final byteprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromByteArray(byte[] bytes) Parses theSpanContextfrom a byte array using the binary format.byte[]toByteArray(SpanContext spanContext) Serializes aSpanContextinto a byte array using the binary format.Methods inherited from class BinaryFormat
fromBinaryValue, toBinaryValue
-
Field Details
-
TRACESTATE_DEFAULT
-
VERSION_ID
private static final byte VERSION_ID- See Also:
-
VERSION_ID_OFFSET
private static final int VERSION_ID_OFFSET- See Also:
-
ID_SIZE
private static final byte ID_SIZE- See Also:
-
TRACE_ID_FIELD_ID
private static final byte TRACE_ID_FIELD_ID- See Also:
-
TRACE_ID_FIELD_ID_OFFSET
static final int TRACE_ID_FIELD_ID_OFFSET- See Also:
-
TRACE_ID_OFFSET
private static final int TRACE_ID_OFFSET- See Also:
-
SPAN_ID_FIELD_ID
private static final byte SPAN_ID_FIELD_ID- See Also:
-
SPAN_ID_FIELD_ID_OFFSET
static final int SPAN_ID_FIELD_ID_OFFSET- See Also:
-
SPAN_ID_OFFSET
private static final int SPAN_ID_OFFSET- See Also:
-
TRACE_OPTION_FIELD_ID
private static final byte TRACE_OPTION_FIELD_ID- See Also:
-
TRACE_OPTION_FIELD_ID_OFFSET
static final int TRACE_OPTION_FIELD_ID_OFFSET- See Also:
-
TRACE_OPTIONS_OFFSET
private static final int TRACE_OPTIONS_OFFSET- See Also:
-
REQUIRED_FORMAT_LENGTH
private static final int REQUIRED_FORMAT_LENGTHVersion, Trace and Span IDs are required fields.- See Also:
-
ALL_FORMAT_LENGTH
private static final int ALL_FORMAT_LENGTHUseTraceOptions.DEFAULTunless its optional field is present.- See Also:
-
-
Constructor Details
-
BinaryFormatImpl
BinaryFormatImpl()
-
-
Method Details
-
toByteArray
Description copied from class:BinaryFormatSerializes aSpanContextinto a byte array using the binary format.- Overrides:
toByteArrayin classBinaryFormat- Parameters:
spanContext- theSpanContextto serialize.- Returns:
- the serialized binary value.
-
fromByteArray
Description copied from class:BinaryFormatParses theSpanContextfrom a byte array using the binary format.- Overrides:
fromByteArrayin classBinaryFormat- Parameters:
bytes- a binary encoded buffer from which theSpanContextwill be parsed.- Returns:
- the parsed
SpanContext. - Throws:
SpanContextParseException- if the version is not supported or the input is invalid
-