code: def to_headers(self, span_context):
          
  
          if not span_context.span_id:
              span_id = INVALID_SPAN_ID
          else:
              span_id = span_context.span_id
  
          sampled = span_context.trace_options.enabled
  
          return {
              _TRACE_ID_KEY: span_context.trace_id,
              _SPAN_ID_KEY: span_id,
              _SAMPLED_KEY: '1' if sampled else '0'
          }
docs: Convert a SpanContext object to B3 propagation headers.
  
          :type span_context:
              :class:`~opencensus.trace.span_context.SpanContext`
          :param span_context: SpanContext object.
  
          :rtype: dict
          :returns: B3 propagation headers.