Setting up New Relic for Django development server
Asked Answered
J

1

18

I am using Django and trying out New Relic. Is it possible to monitor the Django development server? I can only seem to find help on setting up New Relic with production servers.

Edit

'How to' for future reference:

(I used Django1.4)

  1. Follow this: https://newrelic.com/docs/python/python-agent-installation

  2. As the last step of that guide (Integration with your Application) change your wsgi.py file to the following:

    import newrelic.agent
    
    newrelic.agent.initialize('/home/username/path/to/myproject/newrelic-1.9.0.21/newrelic.ini')
    
    import os
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
    
    from django.core.wsgi import get_wsgi_application
    
    application = get_wsgi_application()
    application = newrelic.agent.wsgi_application()(application)
    

Now sign in to your account on the New Relic platform, make a few requests to your development server and see the changes on the the platform. Grats, you made it!

Joinder answered 21/12, 2012 at 0:4 Comment(3)
@Alasdair newrelic.agent.initialize('/home/username/path/to/myproject/newrelic-1.9.0.21/newrelic.ini') newrelic.ini is supposed to be present int the python executable location right? Not sure if this is obsolete now.Cella
@Cella The newrelic.agent.initialize() line was added by Bentley4 after I answered the question, so I can't help with that. If you're stuck, I would ask a new question instead of adding comments to a 6 year old question.Aeropause
I got it to working. I have to point it to the newrelic.ini present in the python executable location. Thanks @AeropauseCella
A
11

As of Django 1.4, the startproject command creates a wsgi file that the runserver command will use.

If you have an older Django project that does not have a wsgi file, you can create one as described in the Django docs, and set WSGI_APPLICATION in your settings.py file.

You should be able to set up new relic by modifying this wsgi file as described by the New Relic docs for Python agent integration.

Aeropause answered 21/12, 2012 at 8:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.