Propagator - BinaryFormatPropagator¶
-
class
opencensus.trace.propagation.binary_format.
BinaryFormatPropagator
[source]¶ Bases:
object
- This propagator contains the method for serializing and deserializing
SpanContext using a binary format.
- See: https://github.com/census-instrumentation/opencensus-specs/blob/
master/encodings/BinaryEncoding.md
- Example:
- [SpanContext]
- trace_id: hex string with length 32.
e.g. 'a0b72ca15c1a4bd18962d0ac59dc90b9'
- span_id: hex string with length 16.
e.g. 'a0b72ca15c1a4bd1'
- enabled (trace option): bool.
e.g. True
- [Binary Format]
- trace_id: Bytes with length 16.
e.g. b' ·,¡KÑbЬYܹ'
- span_id: Bytes with length 8.
e.g. b'ðgª
- ©·'
- trace_option: Byte with length 1.
e.g. b''
-
from_header
(binary)[source]¶ Generate a SpanContext object using the trace context header. The value of enabled parsed from header is int. Need to convert to bool.
- Parameters
binary (bytes) -- Trace context header which was extracted from the request headers.
- Return type
- Returns
SpanContext generated from the trace context header.
-
to_header
(span_context)[source]¶ Convert a SpanContext object to header in binary format.
- Parameters
span_context (
SpanContext
) -- SpanContext object.- Return type
bytes
- Returns
A trace context header in binary format.
-
class
opencensus.trace.propagation.binary_format.
Header
(version_id, trace_id_field_id, trace_id, span_id_field_id, span_id, trace_option_field_id, trace_option)¶ Bases:
tuple
-
span_id
¶ Alias for field number 4
-
span_id_field_id
¶ Alias for field number 3
-
trace_id
¶ Alias for field number 2
-
trace_id_field_id
¶ Alias for field number 1
-
trace_option
¶ Alias for field number 6
-
trace_option_field_id
¶ Alias for field number 5
-
version_id
¶ Alias for field number 0
-