示例#1
0
    def test_apply_tracing_operation_name(self):
        tracer = PyramidTracer(DummyTracer())
        req = DummyRequest()
        req.matched_route = DummyRoute('testing_foo')

        span = tracer._apply_tracing(req, [])
        tracer._finish_tracing(req)
        self.assertEqual('/', span.operation_name)
示例#2
0
    def test_finish(self):
        tracer = PyramidTracer(DummyTracer())
        req = DummyRequest()
        req.matched_route = DummyRoute()

        span = tracer._apply_tracing(req, [])
        tracer._finish_tracing(req)
        self.assertTrue(span._is_finished)
示例#3
0
    def test_apply_tracing_matched_route(self):
        tracer = PyramidTracer(DummyTracer())
        req = DummyRequest()
        req.matched_route = DummyRoute('foo')

        span = tracer._apply_tracing(req, [])
        tracer._finish_tracing(req)
        self.assertEqual({
            'component': 'pyramid',
            'pyramid.route': 'foo',
        }, span._tags, '#A0')
示例#4
0
    def test_apply_tracing_operation_name_func(self):
        def test_func(request):
            self.assertIsNotNone(request)
            return 'testing_name'

        tracer = PyramidTracer(DummyTracer(), operation_name_func=test_func)
        req = DummyRequest()
        req.matched_route = DummyRoute('testing_foo')

        span = tracer._apply_tracing(req, [])
        tracer._finish_tracing(req)
        self.assertEqual('testing_name', span.operation_name)
示例#5
0
    def test_apply_tracing_attrs(self):
        tracer = PyramidTracer(DummyTracer())
        req = DummyRequest()

        # Make sure component is available since the start.
        span = tracer._apply_tracing(req, [])
        self.assertEqual({'component': 'pyramid'}, span._tags, 'A#0')
        tracer._finish_tracing(req)
        self.assertEqual({'component': 'pyramid'}, span._tags, '#A1')

        span = tracer._apply_tracing(req, ['dont', 'exist'])
        tracer._finish_tracing(req)
        self.assertEqual({'component': 'pyramid'}, span._tags, '#B0')

        span = tracer._apply_tracing(req, ['host', 'path'])
        tracer._finish_tracing(req)
        self.assertEqual({
            'component': 'pyramid',
            'host': 'example.com:80',
            'path': '/'
        }, span._tags, '#C0')
示例#6
0
 def test_finish_none(self):
     tracer = PyramidTracer(DummyTracer())
     tracer._finish_tracing(DummyRequest())