django_tests.py 文件源码

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

项目:apm-agent-python 作者: elastic 项目源码 文件源码
def test_request_metrics_301_append_slash(django_elasticapm_client, client):
    django_elasticapm_client.instrumentation_store.get_all()  # clear the store

    # enable middleware wrapping
    django_elasticapm_client.config.instrument_django_middleware = True

    from elasticapm.contrib.django.middleware import TracingMiddleware
    TracingMiddleware._elasticapm_instrumented = False

    with override_settings(
        APPEND_SLASH=True,
        **middleware_setting(django.VERSION, [
            'elasticapm.contrib.django.middleware.TracingMiddleware',
            'django.middleware.common.CommonMiddleware',
        ])
    ):
        client.get(reverse('elasticapm-no-error-slash')[:-1])
    transactions = django_elasticapm_client.instrumentation_store.get_all()
    assert transactions[0]['name'] in (
        # django <= 1.8
        'GET django.middleware.common.CommonMiddleware.process_request',
        # django 1.9+
        'GET django.middleware.common.CommonMiddleware.process_response',
    )
    assert transactions[0]['result'] == 'HTTP 3xx'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号