django_tests.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:apm-agent-python 作者: elastic 项目源码 文件源码
def test_transaction_metrics(django_elasticapm_client, client):
    django_elasticapm_client.instrumentation_store.get_all()  # clear the store
    with override_settings(**middleware_setting(
            django.VERSION, ['elasticapm.contrib.django.middleware.TracingMiddleware']
    )):
        assert len(django_elasticapm_client.instrumentation_store) == 0
        client.get(reverse('elasticapm-no-error'))
        assert len(django_elasticapm_client.instrumentation_store) == 1

        transactions = django_elasticapm_client.instrumentation_store.get_all()

        assert len(transactions) == 1
        transaction = transactions[0]
        assert transaction['duration'] > 0
        assert transaction['result'] == 'HTTP 2xx'
        assert transaction['name'] == 'GET tests.contrib.django.testapp.views.no_error'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号