def test_stacktrace_filtered_for_elasticapm(client, django_elasticapm_client):
with mock.patch(
"elasticapm.traces.TransactionsStore.should_collect") as should_collect:
should_collect.return_value = False
with override_settings(**middleware_setting(django.VERSION,
['elasticapm.contrib.django.middleware.TracingMiddleware'])):
resp = client.get(reverse("render-heavy-template"))
assert resp.status_code == 200
transactions = django_elasticapm_client.instrumentation_store.get_all()
assert transactions[0]['result'] == 'HTTP 2xx'
spans = transactions[0]['spans']
expected_signatures = ['transaction', 'list_users.html',
'something_expensive']
assert spans[1]['name'] == 'list_users.html'
# Top frame should be inside django rendering
assert spans[1]['stacktrace'][0]['module'].startswith('django.template')
评论列表
文章目录