def test_request_metrics_301_prepend_www(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(
PREPEND_WWW=True,
**middleware_setting(django.VERSION, [
'elasticapm.contrib.django.middleware.TracingMiddleware',
'django.middleware.common.CommonMiddleware',
])
):
client.get(reverse('elasticapm-no-error'))
transactions = django_elasticapm_client.instrumentation_store.get_all()
assert transactions[0]['name'] == 'GET django.middleware.common.CommonMiddleware.process_request'
assert transactions[0]['result'] == 'HTTP 3xx'
评论列表
文章目录