Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up New Relic for Django development server

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!

like image 406
Bentley4 Avatar asked Dec 21 '12 00:12

Bentley4


1 Answers

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.

like image 107
Alasdair Avatar answered Sep 19 '22 13:09

Alasdair