title: Python: fetching urllib3 request headers
body: <p>We are injecting tracing information into request headers of all the http request calls in our API client library which is implemented based on urllib3</p>
  <pre><code>def _init_jaeger_tracer():
      '''Jaeger tracer initialization'''
      config = Config(
          config={
              'sampler': {
                  'type': 'const',
                  'param': 1,
              },
          },
          service_name=&quot;session&quot;
          )
      return config.new_tracer()
  
  class APIObject(rest.APIObject):
      '''Class for injecting traces into urllib3 request headers'''
      def __init__(self, configuration):
          print(&quot;RESTClientObject child class called####&quot;)
          self._tracer = None
          super().__init__(configuration)
          self._tracer = _init_jaeger_tracer()
  
      # pylint: disable=W0221
      def request(self, method, url, *args, **kwargs):
          lower_method = method.lower()
          with self._tracer.start_active_span('requests.{}'.format(lower_method)) as scope:
              span = scope.span
              span.set_tag(tags.SPAN_KIND, tags.SPAN_KIND_RPC_CLIENT)
              span.set_tag(tags.COMPONENT, 'request')
              span.set_tag(tags.HTTP_METHOD, lower_method)
              span.set_tag(tags.HTTP_URL, url)
              headers = kwargs.setdefault('headers', {})
              self._tracer.inject(span.context, Format.HTTP_HEADERS, headers)
      return r
  </code></pre>
  <p>After such implementation, urllib3 request headers look like this,</p>
  <pre><code>headers = {
      'Content-Type': 'application/json', 
      'User-Agent': 'API-Generator/1.0.0/python', 
      # **
      'uber-trace-id': '30cef3e816482516:1a4fed2c4863b2f6:0:1'
      # **
  }
  </code></pre>
  <p>Now we have to obtain trace-id from the injected request header.</p>
  <p>In python &quot;requests&quot; library we have &quot;response.request.headers&quot; attribute to return request headers</p>
  <p>In urllib3 i could not find a way return request headers for further processing</p>
  <p>Could any of you share some thoughts</p>
  <p>Now from this request headers, we need to fetch the 'uber-trace-id' and its value for further building URL.</p>