예제 #1
0
def test_failing_celery_task(django_elasticapm_client):
    register_exception_tracking(django_elasticapm_client)
    t = failing_task.delay()
    assert t.state == "FAILURE"
    assert len(django_elasticapm_client.events[ERROR]) == 1
    assert len(django_elasticapm_client.events[TRANSACTION]) == 1
    error = django_elasticapm_client.events[ERROR][0]
    assert error["culprit"] == "tests.contrib.django.testapp.tasks.failing_task"
    assert error["exception"]["message"] == "ValueError: foo"
    assert error["exception"]["handled"] is False

    transaction = django_elasticapm_client.events[TRANSACTION][0]
    assert transaction["name"] == "tests.contrib.django.testapp.tasks.failing_task"
    assert transaction["type"] == "celery"
    assert transaction["result"] == "FAILURE"
예제 #2
0
def test_failing_celery_task(django_elasticapm_client):
    register_exception_tracking(django_elasticapm_client)
    with mock.patch("elasticapm.traces.TransactionsStore.should_collect"
                    ) as should_collect_mock:
        should_collect_mock.return_value = True
        t = failing_task.delay()
    assert t.state == "FAILURE"
    assert len(django_elasticapm_client.events) == 2
    error = django_elasticapm_client.events[0]["errors"][0]
    assert error[
        "culprit"] == "tests.contrib.django.testapp.tasks.failing_task"
    assert error["exception"]["message"] == "ValueError: foo"
    assert error["exception"]["handled"] is False

    transaction = django_elasticapm_client.events[1]["transactions"][0]
    assert transaction[
        "name"] == "tests.contrib.django.testapp.tasks.failing_task"
    assert transaction["type"] == "celery"
    assert transaction["result"] == "FAILURE"
예제 #3
0
def test_failing_celery_task(django_elasticapm_client):
    register_exception_tracking(django_elasticapm_client)
    with mock.patch('elasticapm.traces.TransactionsStore.should_collect'
                    ) as should_collect_mock:
        should_collect_mock.return_value = True
        t = failing_task.delay()
    assert t.state == 'FAILURE'
    assert len(django_elasticapm_client.events) == 2
    error = django_elasticapm_client.events[0]['errors'][0]
    assert error[
        'culprit'] == 'tests.contrib.django.testapp.tasks.failing_task'
    assert error['exception']['message'] == 'ValueError: foo'
    assert error['handled'] is False

    transaction = django_elasticapm_client.events[1]['transactions'][0]
    assert transaction[
        'name'] == 'tests.contrib.django.testapp.tasks.failing_task'
    assert transaction['type'] == 'celery'
    assert transaction['result'] == 'FAILURE'