Django Agent - Ignoring spans related to templates

Is there any configuration to ignore specific span names? Our Django template has a big HTML table and each cell in the has the {% include xxx.htm %} and APM reports the metrics for each cell which is over 2000 entires.

Using the latest version(7.3.1) of ELK+APM in Elastic Cloud
Django Version: 1.11.17
Python Version: 3.7
APM Agent version: 5.1.1

Hi @Sivasubramaniam_Arun!

That's an interesting use case! I'm afraid at the moment, your best option will be to completely disable instrumentation of Django templates. You can do this by setting the environment variable SKIP_INSTRUMENT_DJANGO_TEMPLATE to any value for your Django processes(es).

A bit more long term, I was considering extending our processors to not just modify events, but be able to completely drop an event by returning False. If/Once that is implemented, a processor to drop these spans would look like this:

from elasticapm.conf.constants import SPAN
from elasticapm.processors import for_events


@for_events(SPAN)
def drop_table_includes(client, event):
    if event["name"] == "quarter_cell_tool_tip.htm":
        return False
    return event

I'll open an issue to propose this change with our processors.