Exemple #1
0
def test_successful_celery_task_instrumentation(django_elasticapm_client):
    register_instrumentation(django_elasticapm_client)
    t = successful_task.delay()
    assert t.state == "SUCCESS"
    assert len(django_elasticapm_client.events[TRANSACTION]) == 1
    transaction = django_elasticapm_client.events[TRANSACTION][0]
    assert transaction["name"] == "tests.contrib.django.testapp.tasks.successful_task"
    assert transaction["type"] == "celery"
    assert transaction["result"] == "SUCCESS"
Exemple #2
0
def test_successful_celery_task_instrumentation(django_elasticapm_client):
    register_instrumentation(django_elasticapm_client)
    with mock.patch("elasticapm.traces.TransactionsStore.should_collect"
                    ) as should_collect_mock:
        should_collect_mock.return_value = True
        t = successful_task.delay()
    assert t.state == "SUCCESS"
    assert len(django_elasticapm_client.events[0]["transactions"]) == 1
    transaction = django_elasticapm_client.events[0]["transactions"][0]
    assert transaction[
        "name"] == "tests.contrib.django.testapp.tasks.successful_task"
    assert transaction["type"] == "celery"
    assert transaction["result"] == "SUCCESS"
Exemple #3
0
def test_successful_celery_task_instrumentation(django_elasticapm_client):
    register_instrumentation(django_elasticapm_client)
    with mock.patch('elasticapm.traces.TransactionsStore.should_collect'
                    ) as should_collect_mock:
        should_collect_mock.return_value = True
        t = successful_task.delay()
    assert t.state == 'SUCCESS'
    assert len(django_elasticapm_client.events[0]['transactions']) == 1
    transaction = django_elasticapm_client.events[0]['transactions'][0]
    assert transaction[
        'name'] == 'tests.contrib.django.testapp.tasks.successful_task'
    assert transaction['type'] == 'celery'
    assert transaction['result'] == 'SUCCESS'