Generate a SpanContext object using the information in the carrier.

        :type carrier: dict
        :param carrier: The carrier which has the trace_id, span_id, options
                        information for creating a SpanContext.

        :rtype: :class:`~opencensus.trace.span_context.SpanContext`
        :returns: SpanContext generated from the carrier.

def from_carrier(self, carrier):
        """Generate a SpanContext object using the information in the carrier.

        :type carrier: dict
        :param carrier: The carrier which has the trace_id, span_id, options
                        information for creating a SpanContext.

        :rtype: :class:`~opencensus.trace.span_context.SpanContext`
        :returns: SpanContext generated from the carrier.
        """
        trace_id = None
        span_id = None
        trace_options = None

        for key in carrier:
            key = key.lower()
            if key == _TRACE_ID_KEY:
                trace_id = carrier[key]
            if key == _SPAN_ID_KEY:
                span_id = carrier[key]
            if key == _TRACE_OPTIONS_KEY:
                trace_options = bool(carrier[key])

        if trace_options is None:
            trace_options = DEFAULT_TRACE_OPTIONS

        return SpanContext(
            trace_id=trace_id,
            span_id=span_id,
            trace_options=TraceOptions(trace_options),
            from_header=True)