Ejemplo n.º 1
0
    def test_span_delete(self):
        # ensure the helper removes properly a propagated Span
        @self.app.task
        def fn_task():
            return 42

        # propagate a Span
        task_id = "7c6731af-9533-40c3-83a9-25b58f0d837f"
        span = self.tracer.trace("celery.run")
        attach_span(fn_task, task_id, span)
        # delete the Span
        weak_dict = getattr(fn_task, "__dd_task_span")
        detach_span(fn_task, task_id)
        assert weak_dict.get((task_id, False)) is None
Ejemplo n.º 2
0
    def test_span_delete(self):
        # ensure the helper removes properly a propagated Span
        @self.app.task
        def fn_task():
            return 42

        # propagate a Span
        task_id = '7c6731af-9533-40c3-83a9-25b58f0d837f'
        span = self.tracer.trace('celery.run')
        attach_span(fn_task, task_id, span)
        # delete the Span
        weak_dict = getattr(fn_task, '__dd_task_span')
        detach_span(fn_task, task_id)
        ok_(weak_dict.get(task_id) is None)
Ejemplo n.º 3
0
    def test_span_delete_empty(self):
        # ensure the helper works even if the Task doesn't have
        # a propagation
        @self.app.task
        def fn_task():
            return 42

        # delete the Span
        exception = None
        task_id = "7c6731af-9533-40c3-83a9-25b58f0d837f"
        try:
            detach_span(fn_task, task_id)
        except Exception as e:
            exception = e
        assert exception is None