Propagator - GoogleCloudFormatPropagator¶
-
class
opencensus.trace.propagation.google_cloud_format.
GoogleCloudFormatPropagator
[source]¶ Bases:
object
This class is for converting the trace header in google cloud format and generate a SpanContext, or converting a SpanContext to a google cloud format header. Later we will add implementation for supporting other format like binary format and zipkin, opencensus format.
-
from_header
(header)[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
header (str) -- Trace context header which was extracted from the HTTP request headers.
- Return type
- Returns
SpanContext generated from the trace context header.
-
from_headers
(headers)[source]¶ Generate a SpanContext object using the trace context header.
- Parameters
headers (dict) -- HTTP request headers.
- Return type
- Returns
SpanContext generated from the trace context header.
-
to_header
(span_context)[source]¶ Convert a SpanContext object to header string.
- Parameters
span_context (
SpanContext
) -- SpanContext object.- Return type
str
- Returns
A trace context header string in google cloud format.
-
to_headers
(span_context)[source]¶ Convert a SpanContext object to HTTP request headers.
- Parameters
span_context (
SpanContext
) -- SpanContext object.- Return type
dict
- Returns
Trace context headers in google cloud format.
-