def test_inject_extract(self): """Test Inject / Extract.""" tracer = WavefrontTracer(ConsoleReporter(), self.application_tags) span = tracer.start_span('test_op') self.assertIsNotNone(span) span.set_baggage_item("customer", "test_customer") span.set_baggage_item("request_type", "mobile") carrier = {} tracer.inject(span.context, Format.TEXT_MAP, carrier) span.finish() ctx = tracer.extract(Format.TEXT_MAP, carrier) self.assertEqual("test_customer", ctx.get_baggage_item("customer")) self.assertEqual("mobile", ctx.get_baggage_item("request_type"))
def test_inject_extract(self): """Test Inject / Extract.""" tracer = WavefrontTracer(ConsoleReporter(), self.application_tags, samplers=[ConstantSampler(True)]) span = tracer.start_span('test_op') self.assertIsNotNone(span) span.set_baggage_item('customer', 'test_customer') span.set_baggage_item('request_type', 'mobile') carrier = {} tracer.inject(span.context, opentracing.propagation.Format.TEXT_MAP, carrier) span.finish() ctx = tracer.extract(opentracing.propagation.Format.TEXT_MAP, carrier) self.assertTrue(ctx.is_sampled()) self.assertTrue(ctx.get_sampling_decision()) self.assertEqual('test_customer', ctx.get_baggage_item('customer')) self.assertEqual('mobile', ctx.get_baggage_item('request_type'))