def test_distributed_context(self):
    previous_propagator = get_global_textmap()
    try:
        set_global_textmap(MockTextMapPropagator())
        result = self.perform_request(self.URL)
        self.assertEqual(result.text, 'Hello!')
        span = self.assert_span()
        headers = dict(httpretty.last_request().headers)
        self.assertIn(MockTextMapPropagator.TRACE_ID_KEY, headers)
        self.assertEqual(str(span.get_span_context().trace_id), headers[MockTextMapPropagator.TRACE_ID_KEY])
        self.assertIn(MockTextMapPropagator.SPAN_ID_KEY, headers)
        self.assertEqual(str(span.get_span_context().span_id), headers[MockTextMapPropagator.SPAN_ID_KEY])
    finally:
        set_global_textmap(previous_propagator)
def test_distributed_context(self):
    previous_propagator = get_global_textmap()
    try:
        set_global_textmap(MockTextMapPropagator())
        result = self.perform_request(self.URL)
        self.assertEqual(result.text, 'Hello!')
        span = self.assert_span()
        headers = dict(httpretty.last_request().headers)
        self.assertIn(MockTextMapPropagator.TRACE_ID_KEY, headers)
        self.assertEqual(str(span.get_span_context().trace_id), headers[MockTextMapPropagator.TRACE_ID_KEY])
        self.assertIn(MockTextMapPropagator.SPAN_ID_KEY, headers)
        self.assertEqual(str(span.get_span_context().span_id), headers[MockTextMapPropagator.SPAN_ID_KEY])
    finally:
        set_global_textmap(previous_propagator)