def test_get_span(self): tracer = PyramidTracer(DummyTracer()) req = DummyRequest() tracer._apply_tracing(req, []) self.assertIsNotNone(tracer.get_span(req), '#B0') self.assertIsNone(tracer.get_span(DummyRequest()), '#B1') self.assertEqual(1, len(tracer._current_spans), '#B2')
def test_decorator_exc(self): base_tracer = DummyTracer() tracer = PyramidTracer(base_tracer) req = DummyRequest() @tracer.trace('method') def sample_func(req): raise ValueError('Testing exception') try: sample_func(req) except ValueError: pass self.assertIsNone(tracer.get_span(req), '#A0') self.assertEqual(1, len(base_tracer.spans), '#A1') self.assertTrue(base_tracer.spans[0]._is_finished, '#A2') self.assertEqual({ 'component': 'pyramid', 'error': 'true', 'method': 'GET', }, base_tracer.spans[0]._tags, '#A2')
def test_get_span_none(self): tracer = PyramidTracer(DummyTracer()) self.assertIsNone(tracer.get_span(DummyRequest()), '#A0')