Disable monitoring of new relic in django view

I am using the Django framework (version 1.5.1) with almost 25 internal applications, each with 7 to 15 different views, quite a few.

So, to keep track of RPM, request time, etc, and optime code response I am using New Relic service (free) and it is very handy BUT to track template / request response time before loading it does javascript injection .

Ok, it's not bad, as long as you send email daily with the html page , their damn on earth because the js injected into the html literature eats / destroys the html.

If you are sending this mail manually, perhaps you can check the content before sending, but in my case it is crontab taks, so this is not a solution for me.

The official docs have a disable_browser_autorum function that I only need, BUT (again) you can use the newrelic.disable_browser_autorum variable on the WSGI server , but I'm running gunicorn server with supervisord , so it's not good.

But there is also a variable newrelic.agent.disable_browser_autorum (flag = True) that you have to insert into the structure view and works alongside html quotes.

{% load staticfiles newrelic_tags %}
<!DOCTYPE html>
<html lang="{{ LANGUAGE_CODE }}">
<head>
    <meta charset="utf-8" />
    {% newrelic_browser_timing_header %}
<body>
  . 
  .
  .

   {% newrelic_browser_timing_footer %}
</body>
</html>

      

But there is no information on how to do this, and I also did tests myself to try and understand how it works.

I'm not a big python or django developer, but from experience it should be something like

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)

        >> HERE DO SOMETHING LIKE self.request.something =newrelic.agent.disable_browser_autorum(flag=True)<<
        return context

      

Can someone give me a hand with this? Any suggestion is greatly appreciated.

PS: I've already posted a question on the official New Relic community, but no luck so far.

+3


source to share


1 answer


Well thanks to my colleague and @Daniel Roseman, my problem is 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 newrelic is an "environment variable", so just putting it there it will work.

So what.

+4


source







All Articles