Python agent and Web2py

Web2py is an open-source framework for creating web-based Python applications. You can integrate New Relic with your Web2py appl to monitor your app's performance.

Integrate with Web2py

To integrate your Web2py application with New Relic:

  1. Install the New Relic Python agent
  2. Test the agent
  3. Follow the procedures that match your Web2py setup:

    Runweb2py command

    If you run your web application using the runweb2py command, use the following command:

    NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program runweb2py

    newrelic-admin is a wrapper script that allows the New Relic Python agent to monitor your app. For more on running wrapper scripts, see Running the wrapper script.

    Apache/mod_wsgi

    When using Apache/mod_wsgi, you must manually insert code in the WSGI script file you are using in order to initialize the New Relic Python agent. If your WSGI script file is the wsgihandler.py file, immediately before the import gluon.main line in that file, add:

    import newrelic.agent
    newrelic.agent.initialize('/some/path/newrelic.ini')

    For more on using mod_wsgi with New Relic, see Python agent and mod_wsgi.

    Gunicorn

    A standard Gunicorn installation contains the following command:

    gunicorn wsgihandler:application

    Replace that line with this one:

    NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program gunicorn wsgihandler:application

    For more on using Gunicorn with New Relic, see Python agent and Gunicorn.

    uWSGI

    A standard uWSGI installation contains the following command:

    uwsgi --socket /tmp/uwsgi.sock wsgihandler.py

    Replace that line with this one:

    NEW_RELIC_CONFIG_FILE=/some/path/newrelic.ini newrelic-admin run-program uwsgi --socket /tmp/uwsgi.sock --single-interpreter --enable-threads wsgihandler.py

    For more on using uWSGI with New Relic, see Python agent and uWSGI.

These Web2py integration procedures are variations on the standard New Relic Python agent integration procedure. For a more detailed look at the integration process, see Python agent integration.

For more help

Additional documentation resources include:

Join the discussion about Python in the New Relic Online Technical Community! The Technical Community is a public platform to discuss and troubleshoot your New Relic toolset.

If you need additional help, get support at support.newrelic.com.