[Django]-Disable monitoring for new relic in django views

4👍

Well thanks to my colleague & @Daniel Roseman’s help my problem was solved, it was a simple solution:

import newrelic.agent
. . .

class EmailView(DetailView):
    template_name = 'email/daily-newsletter.html'
    model = News

    def get_queryset(self):
        return News.objects.filter(date=datetime.date.today())

    def get_context_data(self, **kwargs):
        context = super(EmailView, self).get_context_data(**kwargs)
        context['related_news'] = NewsRelated.objects.get(related=self.id)

        newrelic.agent.disable_browser_autorum(flag=True)
        return context

But then my colleague commented that the newrelic it’s an ‘enviroment variable’ so just bi putting it there it will work.

So that’s that.

👤Madox

Leave a comment